From 64db0bb3f32236b55746bf62002faca08a54e364 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 9 May 2020 22:41:23 +0200 Subject: [PATCH] Handle EINTR when reading/writing to AIO fds. --- src/meshlink.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/meshlink.c b/src/meshlink.c index 1118b8a5..7c5bbd22 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -3538,6 +3538,10 @@ static ssize_t channel_recv(struct utcp_connection *connection, const void *data ssize_t result = write(aio->fd, p, todo); if(result <= 0) { + if(result < 0 && errno == EINTR) { + continue; + } + /* Writing to fd failed, cancel just this AIO buffer. */ logger(mesh, MESHLINK_ERROR, "Writing to AIO fd %d failed: %s", aio->fd, strerror(errno)); @@ -3678,6 +3682,10 @@ static void channel_poll(struct utcp_connection *connection, size_t len) { todo = result; sent = utcp_send(connection, buf, todo); } else { + if(result < 0 && errno == EINTR) { + continue; + } + /* Reading from fd failed, cancel just this AIO buffer. */ if(result != 0) { logger(mesh, MESHLINK_ERROR, "Reading from AIO fd %d failed: %s", aio->fd, strerror(errno)); -- 2.39.5