]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd: ignore both EINTR and EAGAIN 21564/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 29 Nov 2021 18:33:55 +0000 (03:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 30 Nov 2021 14:06:43 +0000 (23:06 +0900)
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-device/device-monitor.c
src/libsystemd/sd-resolve/sd-resolve.c

index bce123ae1c6b904d6e3e8507c79924b762d08b12..14951ccb3306eaf2527ae8d4b5a419ef737a9c70 100644 (file)
@@ -149,7 +149,7 @@ static int bus_socket_write_auth(sd_bus *b) {
         }
 
         if (k < 0)
-                return errno == EAGAIN ? 0 : -errno;
+                return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
 
         iovec_advance(b->auth_iovec, &b->auth_index, (size_t) k);
         return 1;
@@ -301,7 +301,7 @@ static int verify_external_token(sd_bus *b, const char *p, size_t l) {
         uid_t u;
         int r;
 
-        /* We don't do any real authentication here. Instead, if 
+        /* We don't do any real authentication here. Instead, if
          * the owner of this bus wanted authentication they should have
          * checked SO_PEERCRED before even creating the bus object. */
 
@@ -565,10 +565,11 @@ static int bus_socket_read_auth(sd_bus *b) {
                 } else
                         handle_cmsg = true;
         }
-        if (k == -EAGAIN)
-                return 0;
-        if (k < 0)
+        if (k < 0) {
+                if (ERRNO_IS_TRANSIENT(k))
+                        return 0;
                 return (int) k;
+        }
         if (k == 0) {
                 if (handle_cmsg)
                         cmsg_close_all(&mh); /* paranoia, we shouldn't have gotten any fds on EOF */
@@ -1073,7 +1074,7 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) {
         }
 
         if (k < 0)
-                return errno == EAGAIN ? 0 : -errno;
+                return ERRNO_IS_TRANSIENT(errno) ? 0 : -errno;
 
         *idx += (size_t) k;
         return 1;
@@ -1230,10 +1231,11 @@ int bus_socket_read_message(sd_bus *bus) {
                 } else
                         handle_cmsg = true;
         }
-        if (k == -EAGAIN)
-                return 0;
-        if (k < 0)
+        if (k < 0) {
+                if (ERRNO_IS_TRANSIENT(k))
+                        return 0;
                 return (int) k;
+        }
         if (k == 0) {
                 if (handle_cmsg)
                         cmsg_close_all(&mh); /* On EOF we shouldn't have gotten an fd, but let's make sure */
index a446c27583ef228a34e71e0acad531faffe46ff0..524d10b9d801ae6ca77c3b72389cedf4ac157c71 100644 (file)
@@ -445,7 +445,7 @@ int device_monitor_receive_device(sd_device_monitor *m, sd_device **ret) {
 
         buflen = recvmsg(m->sock, &smsg, 0);
         if (buflen < 0) {
-                if (errno != EINTR)
+                if (ERRNO_IS_TRANSIENT(errno))
                         log_debug_errno(errno, "sd-device-monitor: Failed to receive message: %m");
                 return -errno;
         }
index ad637bcf1db6a61af8d3ce0ef76463e3e3737727..fdc09ff20f766f616d9aa8d8606523b7c204ebb5 100644 (file)
@@ -418,7 +418,7 @@ static void* thread_worker(void *p) {
 
                 length = recv(resolve->fds[REQUEST_RECV_FD], &buf, sizeof buf, 0);
                 if (length < 0) {
-                        if (errno == EINTR)
+                        if (ERRNO_IS_TRANSIENT(errno))
                                 continue;
 
                         break;
@@ -847,7 +847,7 @@ _public_ int sd_resolve_process(sd_resolve *resolve) {
 
         l = recv(resolve->fds[RESPONSE_RECV_FD], &buf, sizeof buf, 0);
         if (l < 0) {
-                if (errno == EAGAIN)
+                if (ERRNO_IS_TRANSIENT(errno))
                         return 0;
 
                 return -errno;