]> git.ipfire.org Git - thirdparty/curl.git/commit
multi: implement wait using winsock events
authorrcombs <rcombs@rcombs.me>
Wed, 13 May 2020 23:49:57 +0000 (18:49 -0500)
committerMarc Hoersken <info@marc-hoersken.de>
Tue, 25 Aug 2020 10:11:24 +0000 (12:11 +0200)
commitd2a7d7c185f98df8f3e585e5620cbc0482e45fac
treeb59eea825facff1881cc7f4b5607235ae0c158ea
parent17f58c8d98a0de2e88d49cdba1cc1e0145cada91
multi: implement wait using winsock events

This avoids using a pair of TCP ports to provide wakeup functionality
for every multi instance on Windows, where socketpair() is emulated
using a TCP socket on loopback which could in turn lead to socket
resource exhaustion.

A previous version of this patch failed to account for how in WinSock,
FD_WRITE is set only once when writing becomes possible and not again
until after a send has failed due to the buffer filling. This contrasts
to how FD_READ and FD_OOB continue to be set until the conditions they
refer to no longer apply. This meant that if a user wrote some data to
a socket, but not enough data to completely fill its send buffer, then
waited on that socket to become writable, we'd erroneously stall until
their configured timeout rather than returning immediately.

This version of the patch addresses that issue by checking each socket
we're waiting on to become writable with select() before the wait, and
zeroing the timeout if it's already writable.

Assisted-by: Marc Hörsken
Reviewed-by: Marcel Raad
Reviewed-by: Daniel Stenberg
Tested-by: Gergely Nagy
Tested-by: Rasmus Melchior Jacobsen
Tested-by: Tomas Berger
Replaces #5397
Reverts #5632
Closes #5634
lib/multi.c
lib/multihandle.h