ngtcp2: fix unwanted close of file descriptor 0

... causing macOS to hand out 0 as next socket handle and failing on
further operations.

Reported-by: Sergey Fionov
Fixes #10593
Closes #10595
This commit is contained in:
Stefan Eissing 2023-02-23 16:54:02 +01:00 committed by Daniel Stenberg
parent 0242eba06e
commit f6fe54e21e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 2 additions and 14 deletions

View file

@ -253,19 +253,6 @@ static CURLcode socket_open(struct Curl_easy *data,
else {
/* opensocket callback not set, so simply create the socket now */
*sockfd = socket(addr->family, addr->socktype, addr->protocol);
if(!*sockfd && addr->socktype == SOCK_DGRAM) {
/* This is icky and seems, at least, to happen on macOS:
* we get sockfd == 0 and if called again, we get a valid one > 0.
* If we close the 0, we sometimes get failures in multi poll, as
* 0 seems also be the fd for the sockpair used for WAKEUP polling.
* Very strange. Maybe this code should be ifdef'ed for macOS, but
* on "real" OS, fd 0 is stdin and we never see that. So...
*/
fake_sclose(*sockfd);
*sockfd = socket(addr->family, addr->socktype, addr->protocol);
DEBUGF(infof(data, "QUIRK: UDP socket() gave handle 0, 2nd attempt %d",
(int)*sockfd));
}
}
if(*sockfd == CURL_SOCKET_BAD)