From 40a9dee4edc27bbfc03813ed3d410bbed44edc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 23 Oct 2022 13:42:12 +0200 Subject: [PATCH] Fix some EINTR handling --- README.md | 2 +- lib/src/http.c | 10 +++++++++- lib/src/stoppipe.c | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f306470..5be248c 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/src/http.c b/lib/src/http.c index f55c438..5c07802 100644 --- a/lib/src/http.c +++ b/lib/src/http.c @@ -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; diff --git a/lib/src/stoppipe.c b/lib/src/stoppipe.c index 7ad2d2a..003ad5d 100644 --- a/lib/src/stoppipe.c +++ b/lib/src/stoppipe.c @@ -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;