mirror of
https://github.com/curl/curl.git
synced 2026-06-14 03:05:41 +03:00
merge checks on Win/non-Win
This commit is contained in:
parent
613056afc3
commit
d2687af73a
3 changed files with 23 additions and 42 deletions
|
|
@ -1559,17 +1559,12 @@ static CURLcode cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|||
if(!curlx_sztouz(rv, pnwritten)) {
|
||||
int sockerr = SOCKERRNO;
|
||||
|
||||
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
|
||||
) {
|
||||
/* EWOULDBLOCK */
|
||||
|
|
@ -1625,16 +1620,12 @@ static CURLcode cf_socket_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
|
|||
if(!curlx_sztouz(rv, pnread)) {
|
||||
int sockerr = SOCKERRNO;
|
||||
|
||||
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)
|
||||
/* 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)
|
||||
#endif
|
||||
) {
|
||||
/* EWOULDBLOCK */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||
#ifndef CURL_WINDOWS_UWP
|
||||
rc = sread(per->infd, buffer, curlx_uztosi(sz * nmemb));
|
||||
if(rc < 0) {
|
||||
if(SOCKERRNO == SOCKEWOULDBLOCK) {
|
||||
if(SOCK_EWOULDBLOCK_EAGAIN(SOCKERRNO)) {
|
||||
errno = 0;
|
||||
config->readbusy = TRUE;
|
||||
return CURL_READFUNC_PAUSE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue