Fix some EINTR handling

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

View file

@ -8,7 +8,7 @@
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/c81ogebvsmo43dd3?svg=true)](https://ci.appveyor.com/project/thestr4ng3r/chiaki) [![builds.sr.ht Status](https://builds.sr.ht/~thestr4ng3r/chiaki.svg)](https://builds.sr.ht/~thestr4ng3r/chiaki?)
Chiaki is a Free and Open Source Software Client for PlayStation 4 and PlayStation 5 Remote Play
for Linux, FreeBSD, OpenBSD, Android, macOS, Windows, Nintendo Switch and potentially even more platforms.
for Linux, FreeBSD, OpenBSD, NetBSD, Android, macOS, Windows, Nintendo Switch and potentially even more platforms.
![Screenshot](assets/screenshot.png)

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;