diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-05-30 15:43:25 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-05-30 15:43:25 +1000 |
commit | 1e72af9c5169c83f537d27c66c3cf3db015fce6b (patch) | |
tree | fa4ec47608b1497ad3a9767ac0a59b42d4b49fc8 /ctdb/tcp | |
parent | c833b06a35afd2de5edc237df0b1a461a649d9e3 (diff) | |
download | samba-1e72af9c5169c83f537d27c66c3cf3db015fce6b.tar.gz samba-1e72af9c5169c83f537d27c66c3cf3db015fce6b.tar.xz samba-1e72af9c5169c83f537d27c66c3cf3db015fce6b.zip |
close sockets when we exec scripts
(This used to be ctdb commit 0fac2164db4279db2d7d376a34be05b890304087)
Diffstat (limited to 'ctdb/tcp')
-rw-r--r-- | ctdb/tcp/tcp_connect.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c index fa249d5fba..0a9dc5106b 100644 --- a/ctdb/tcp/tcp_connect.c +++ b/ctdb/tcp/tcp_connect.c @@ -26,14 +26,6 @@ #include "../include/ctdb_private.h" #include "ctdb_tcp.h" -static void set_nonblocking(int fd) -{ - unsigned v; - v = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, v | O_NONBLOCK); -} - - /* called when a complete packet has come in - should not happen on this socket */ @@ -134,6 +126,7 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, tnode->fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); set_nonblocking(tnode->fd); + set_close_on_exec(tnode->fd); ZERO_STRUCT(sock_out); #ifdef HAVE_SOCK_SIN_LEN @@ -213,6 +206,7 @@ static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde, in->ctdb = ctdb; set_nonblocking(in->fd); + set_close_on_exec(in->fd); setsockopt(in->fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one)); @@ -322,6 +316,8 @@ int ctdb_tcp_listen(struct ctdb_context *ctdb) return -1; } + set_close_on_exec(ctcp->listen_fd); + setsockopt(ctcp->listen_fd,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(one)); /* we can either auto-bind to the first available address, or we can |