-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows, Curl_socket_check function will incorrectly report an error on sockets that have data available to read. #10501
Comments
Can you describe or show the logs of a concrete use case/scenario of such a wrongfully terminated connection? |
|
== Info: [1] Trying 127.0.0.1:12345... |
I modified select.c to print the revents that Curl_poll sets in Curl_socket_check? There are some extra lines in debug.txt that would be confusing if they don’t know that. |
POLLRDBAND does not seem to be an general error and on Windows the value for POLLIN is 768 and the value for POLLRDBAND is 512. Fixes curl#10501 Reported-by: opensslonzos-github on github Closes curl#10592
On Windows, the Curl_socket_check function will incorrectly report an error on sockets that have data available to read.
This is because on Windows, the value for POLLIN is 768 and the value for POLLRDBAND is 512.
In the function Curl_socket_check in select.c, curl checks [pollfd.revents & POLLRDBAND] to determine whether the socket is broken. But, if pollfd.revents = POLLIN, pollfd.revents & POLLRDBAND != 0. This leads to many connections being wrongfully terminated.
The bug can be fixed by changing lines 233 and 240 in lib/select.c from
if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
to
if(pfd[num].revents & (POLLPRI|POLLNVAL))
// (removing the POLLRDBAND check).Those lines check whether the socket is dead based on a call to poll.
If poll sets POLLIN, curl identifies that as an error because on Windows POLLIN = POLLRDNORM | POLLRDBAND.
curl/libcurl version
7.86
[curl -V output]
curl 7.86.0 (x86_64-pc-win32) libcurl/7.86.0 OpenSSL/1.1.1n zlib/1.2.12 WinIDN nghttp2/1.42.0
Release-Date: 2022-10-26
Protocols: http https smtp smtps
Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM SSL threadsafe UnixSockets
operating system
Windows 10
The text was updated successfully, but these errors were encountered: