From 60aeaec734190224a78b18cf63f8fd80258deea9 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Mon, 16 Nov 2020 10:18:53 -0800 Subject: [PATCH] hand EINTR in IXSelectInterruptPipe::notify and IXSelectInterruptPipe::read --- ixwebsocket/IXSelectInterruptPipe.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ixwebsocket/IXSelectInterruptPipe.cpp b/ixwebsocket/IXSelectInterruptPipe.cpp index a1734638..75c42f27 100644 --- a/ixwebsocket/IXSelectInterruptPipe.cpp +++ b/ixwebsocket/IXSelectInterruptPipe.cpp @@ -117,8 +117,14 @@ namespace ix int fd = _fildes[kPipeWriteIndex]; if (fd == -1) return false; + ssize_t ret = -1; + do + { + ret = ::write(fd, &value, sizeof(value)); + } while (ret == -1 && errno == EINTR); + // we should write 8 bytes for an uint64_t - return write(fd, &value, sizeof(value)) == 8; + return ret == 8; } // TODO: return max uint64_t for errors ? @@ -129,7 +135,12 @@ namespace ix int fd = _fildes[kPipeReadIndex]; uint64_t value = 0; - ::read(fd, &value, sizeof(value)); + + ssize_t ret = -1; + do + { + ret = ::read(fd, &value, sizeof(value)); + } while (ret == -1 && errno == EINTR); return value; }