Fix some EINTR handling

This commit is contained in:
Florian Märkl 2022-10-23 13:42:12 +02:00
commit 40a9dee4ed
3 changed files with 15 additions and 3 deletions

View file

@ -146,7 +146,15 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_recv_http_header(int sock, char *buf, size_
return err;
}
int received = (int)recv(sock, buf, (int)buf_size, 0);
int received;
do
{
received = (int)recv(sock, buf, (int)buf_size, 0);
#if _WIN32
} while(false);
#else
} while(received < 0 && errno == EINTR);
#endif
if(received <= 0)
return received == 0 ? CHIAKI_ERR_DISCONNECTED : CHIAKI_ERR_NETWORK;

View file

@ -147,7 +147,11 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_select_single(ChiakiStopPipe *sto
timeout = &timeout_s;
}
int r = select(nfds, &rfds, write ? &wfds : NULL, NULL, timeout);
int r;
do
{
r = select(nfds, &rfds, write ? &wfds : NULL, NULL, timeout);
} while(r < 0 && errno == EINTR);
if(r < 0)
return CHIAKI_ERR_UNKNOWN;