summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-06 22:27:20 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-06 23:03:12 +0100
commit29a5ca9baa58e55c4d9e1d008cdd014aa9c3c3e1 (patch)
tree9f458e7d196ab5e5305266097dc4181a1e72403a /src
parentffcfcb6b2c068a5869cffad8a59d72b888bcb940 (diff)
activate: get rid of redundant definiton of fd_cloexec()
Diffstat (limited to 'src')
-rw-r--r--src/activate/activate.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c
index 43ab458812..8b282bda7f 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -55,26 +55,6 @@ static int add_epoll(int epoll_fd, int fd) {
return r;
}
-static int set_nocloexec(int fd) {
- int flags;
-
- flags = fcntl(fd, F_GETFD);
- if (flags < 0) {
- log_error("Querying flags for fd:%d: %m", fd);
- return -errno;
- }
-
- if (!(flags & FD_CLOEXEC))
- return 0;
-
- if (fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) < 0) {
- log_error("Settings flags for fd:%d: %m", fd);
- return -errno;
- }
-
- return 0;
-}
-
static int print_socket(const char* desc, int fd) {
int r;
SocketAddress addr = {
@@ -112,7 +92,7 @@ static int print_socket(const char* desc, int fd) {
}
static int open_sockets(int *epoll_fd, bool accept) {
- int n, fd;
+ int n, fd, r;
int count = 0;
char **address;
@@ -128,11 +108,9 @@ static int open_sockets(int *epoll_fd, bool accept) {
log_debug("Received descriptor fd:%d", fd);
print_socket("Listening on", fd);
- if (!arg_accept) {
- int r = set_nocloexec(fd);
- if (r < 0)
- return r;
- }
+ r = fd_cloexec(fd, arg_accept);
+ if (r < 0)
+ return r;
count ++;
}
@@ -160,8 +138,9 @@ static int open_sockets(int *epoll_fd, bool accept) {
return -errno;
}
+
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + count; fd++) {
- int r = add_epoll(*epoll_fd, fd);
+ r = add_epoll(*epoll_fd, fd);
if (r < 0)
return r;
}