]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/activate/activate.c
tree-wide: port users over to use new ERRNO_IS_ACCEPT_AGAIN() call
[thirdparty/systemd.git] / src / activate / activate.c
index 9a83bc7f24378e9f0484a2e1007c3892af71c76a..473366fb2022824f96291945a6875c4b9f4c24e2 100644 (file)
@@ -10,6 +10,7 @@
 #include "sd-daemon.h"
 
 #include "alloc-util.h"
+#include "errno-util.h"
 #include "escape.h"
 #include "fd-util.h"
 #include "log.h"
@@ -21,6 +22,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
+#include "util.h"
 
 static char** arg_listen = NULL;
 static bool arg_accept = false;
@@ -73,7 +75,9 @@ static int open_sockets(int *epoll_fd, bool accept) {
                         except[fd] = fd;
 
                 log_close();
-                close_all_fds(except, 3 + n);
+                r = close_all_fds(except, 3 + n);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to close all file descriptors: %m");
         }
 
         /** Note: we leak some fd's on error here. I doesn't matter
@@ -267,11 +271,15 @@ static int do_accept(const char* name, char **argv, char **envp, int fd) {
         _cleanup_close_ int fd_accepted = -1;
 
         fd_accepted = accept4(fd, NULL, NULL, 0);
-        if (fd_accepted < 0)
+        if (fd_accepted < 0) {
+                if (ERRNO_IS_ACCEPT_AGAIN(errno))
+                        return 0;
+
                 return log_error_errno(errno, "Failed to accept connection on fd:%d: %m", fd);
+        }
 
-        getsockname_pretty(fd_accepted, &local);
-        getpeername_pretty(fd_accepted, true, &peer);
+        (void) getsockname_pretty(fd_accepted, &local);
+        (void) getpeername_pretty(fd_accepted, true, &peer);
         log_info("Connection from %s to %s", strna(peer), strna(local));
 
         return fork_and_exec_process(name, argv, envp, fd_accepted);