]> git.meshlink.io Git - meshlink/commitdiff
Handle EINTR when reading/writing to AIO fds.
authorGuus Sliepen <guus@meshlink.io>
Sat, 9 May 2020 20:41:23 +0000 (22:41 +0200)
committerGuus Sliepen <guus@meshlink.io>
Mon, 11 May 2020 19:36:12 +0000 (21:36 +0200)
src/meshlink.c

index 1118b8a5e6b31b5d24cda596b66117099fea661a..7c5bbd22741476532e0d17cdfbe992a7e2056276 100644 (file)
@@ -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) {
                        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));
 
                                /* 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 {
                                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));
                                /* 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));