1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-10 11:35:07 -05:00

multi: handle connection state winsock events

Learn from the way Cygwin handles and maps the WinSock events
to simulate correct and complete poll and select behaviour
according to Richard W. Stevens Network Programming book.

Reviewed-by: Jay Satiro
Reviewed-by: Marcel Raad

Follow up to #5634
Closes #5867
This commit is contained in:
Marc Hoersken 2020-08-26 22:13:21 +02:00
parent a2c85bb8e4
commit 003e81e2a3
No known key found for this signature in database
GPG Key ID: 61E03CBED7BC859E

View File

@ -1184,7 +1184,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
#ifdef USE_WINSOCK
if(SOCKET_READABLE(sockbunch[i], 0) > 0)
timeout_ms = 0;
mask |= FD_READ;
mask |= (FD_READ|FD_ACCEPT|FD_CLOSE);
#else
ufds[nfds].fd = sockbunch[i];
ufds[nfds].events = POLLIN;
@ -1196,7 +1196,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
#ifdef USE_WINSOCK
if(SOCKET_WRITABLE(sockbunch[i], 0) > 0)
timeout_ms = 0;
mask |= FD_WRITE;
mask |= (FD_WRITE|FD_CONNECT|FD_CLOSE);
#else
ufds[nfds].fd = sockbunch[i];
ufds[nfds].events = POLLOUT;
@ -1226,7 +1226,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
pre_poll.events = 0;
pre_poll.revents = 0;
if(extra_fds[i].events & CURL_WAIT_POLLIN) {
events |= FD_READ;
events |= (FD_READ|FD_ACCEPT|FD_CLOSE);
pre_poll.events |= POLLIN;
}
if(extra_fds[i].events & CURL_WAIT_POLLPRI) {
@ -1234,7 +1234,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
pre_poll.events |= POLLPRI;
}
if(extra_fds[i].events & CURL_WAIT_POLLOUT) {
events |= FD_WRITE;
events |= (FD_WRITE|FD_CONNECT|FD_CLOSE);
pre_poll.events |= POLLOUT;
}
if(Curl_poll(&pre_poll, 1, 0) > 0) {
@ -1299,9 +1299,9 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
mask = extra_fds[i].revents;
if(WSAEnumNetworkEvents(extra_fds[i].fd, multi->wsa_event,
&events) == 0) {
if(events.lNetworkEvents & FD_READ)
if(events.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE))
mask |= CURL_WAIT_POLLIN;
if(events.lNetworkEvents & FD_WRITE)
if(events.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE))
mask |= CURL_WAIT_POLLOUT;
if(events.lNetworkEvents & FD_OOB)
mask |= CURL_WAIT_POLLPRI;