diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-09-25 16:04:01 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-09-25 23:27:04 +0200 |
commit | a4edf0335d9d07dabe0e8ca4560fafb934d4dffd (patch) | |
tree | a357006227b536997325b1390225235ccdcf42b6 /src | |
parent | Merge pull request #29315 from poettering/strgrowpad0 (diff) | |
download | systemd-a4edf0335d9d07dabe0e8ca4560fafb934d4dffd.tar.xz systemd-a4edf0335d9d07dabe0e8ca4560fafb934d4dffd.zip |
varlink: move O_NONBLOCK setting to varlink_server_listen_fd(), and set O_CLOEXEC too
Let's move setting of O_NONBLOCK into varlink_server_listen_fd() and out
of varlink_server_create_listen_fd_socket(). The latter has two callers:
varlink_server_listen_fd() and varlink_server_listen_address(), which
guarantees O_CLOEXEC+O_NONBLOCK anyway, hence no neet to repeat the
logic.
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/varlink.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/shared/varlink.c b/src/shared/varlink.c index fd28655c5a..132903df2d 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -2682,10 +2682,6 @@ static int varlink_server_create_listen_fd_socket(VarlinkServer *s, int fd, Varl assert(fd >= 0); assert(ret_ss); - r = fd_nonblock(fd, true); - if (r < 0) - return r; - ss = new(VarlinkServerSocket, 1); if (!ss) return log_oom_debug(); @@ -2716,6 +2712,14 @@ int varlink_server_listen_fd(VarlinkServer *s, int fd) { assert_return(s, -EINVAL); assert_return(fd >= 0, -EBADF); + r = fd_nonblock(fd, true); + if (r < 0) + return r; + + r = fd_cloexec(fd, true); + if (r < 0) + return r; + r = varlink_server_create_listen_fd_socket(s, fd, &ss); if (r < 0) return r; |