merge checks on Win/non-Win

This commit is contained in:
Viktor Szakats 2026-06-08 04:22:33 +02:00
parent 613056afc3
commit d2687af73a
No known key found for this signature in database
3 changed files with 23 additions and 42 deletions

View file

@ -232,16 +232,12 @@ static int wakeup_inet(curl_socket_t socks[2], bool nonblocking)
/* Do not block forever */
if(curlx_timediff_ms(curlx_now(), start) > (60 * 1000))
goto error;
if(
#ifdef USE_WINSOCK
/* This is how Windows does it */
(sockerr == SOCKEWOULDBLOCK)
#else
/* errno may be EWOULDBLOCK or on some systems EAGAIN when it
returned due to its inability to send off data without
blocking. We therefore treat both error codes the same here */
SOCK_EWOULDBLOCK_EAGAIN(sockerr) ||
(sockerr == SOCKEINTR) || (sockerr == SOCKEINPROGRESS)
/* errno may be EWOULDBLOCK or on some systems EAGAIN when it
returned due to its inability to send off data without
blocking. We therefore treat both error codes the same here */
if(SOCK_EWOULDBLOCK_EAGAIN(sockerr)
#ifndef USE_WINSOCK
|| (sockerr == SOCKEINTR) || (sockerr == SOCKEINPROGRESS)
#endif
) {
continue;
@ -320,15 +316,12 @@ int Curl_wakeup_signal(curl_socket_t socks[2])
err = 0;
if(wakeup_write(socks[1], buf, sizeof(buf)) < 0) {
err = SOCKERRNO;
#ifdef USE_WINSOCK
if(err == SOCKEWOULDBLOCK)
err = 0; /* wakeup is already ongoing */
#else
#ifndef USE_WINSOCK
if(err == SOCKEINTR)
continue;
#endif
if(SOCK_EWOULDBLOCK_EAGAIN(err))
err = 0; /* wakeup is already ongoing */
#endif
}
break;
}
@ -346,15 +339,12 @@ CURLcode Curl_wakeup_consume(curl_socket_t socks[2], bool all)
if(!rc)
break;
else if(rc < 0) {
#ifdef USE_WINSOCK
if(SOCKERRNO == SOCKEWOULDBLOCK)
break;
#else
#ifndef USE_WINSOCK
if(SOCKERRNO == SOCKEINTR)
continue;
#endif
if(SOCK_EWOULDBLOCK_EAGAIN(SOCKERRNO))
break;
#endif
result = CURLE_READ_ERROR;
break;
}