diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-06 22:30:35 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-06 23:03:12 +0100 |
commit | 175a3d25d0e8596d4ba0759aea3f89ee228e7d6d (patch) | |
tree | 95f09c22413d3109170fe0098ae1bdc1741c6354 /src/core/socket.c | |
parent | eceb8483e5a02e8e337486b89719a3b99cfcb7ce (diff) |
active: rework make_socket_fd() to be based on socket_address_listen()
Among other things this makes sure we set SO_REUSEADDR which is
immensely useful.
Diffstat (limited to 'src/core/socket.c')
-rw-r--r-- | src/core/socket.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index 887ea00fb2..03b8f927bb 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -993,46 +993,51 @@ static int socket_open_fds(Socket *s) { know_label = true; } - if ((r = socket_address_listen( - &p->address, - s->backlog, - s->bind_ipv6_only, - s->bind_to_device, - s->free_bind, - s->transparent, - s->directory_mode, - s->socket_mode, - label, - &p->fd)) < 0) + r = socket_address_listen( + &p->address, + SOCK_CLOEXEC|SOCK_NONBLOCK, + s->backlog, + s->bind_ipv6_only, + s->bind_to_device, + s->free_bind, + s->transparent, + s->directory_mode, + s->socket_mode, + label); + if (r < 0) goto rollback; + p->fd = r; socket_apply_socket_options(s, p->fd); } else if (p->type == SOCKET_SPECIAL) { - if ((r = special_address_create( - p->path, - &p->fd)) < 0) + r = special_address_create( + p->path, + &p->fd); + if (r < 0) goto rollback; } else if (p->type == SOCKET_FIFO) { - if ((r = fifo_address_create( - p->path, - s->directory_mode, - s->socket_mode, - &p->fd)) < 0) + r = fifo_address_create( + p->path, + s->directory_mode, + s->socket_mode, + &p->fd); + if (r < 0) goto rollback; socket_apply_fifo_options(s, p->fd); } else if (p->type == SOCKET_MQUEUE) { - if ((r = mq_address_create( - p->path, - s->socket_mode, - s->mq_maxmsg, - s->mq_msgsize, - &p->fd)) < 0) + r = mq_address_create( + p->path, + s->socket_mode, + s->mq_maxmsg, + s->mq_msgsize, + &p->fd); + if (r < 0) goto rollback; } else assert_not_reached("Unknown port type"); |