diff options
author | Martin Schwenke <martin@meltin.net> | 2012-10-02 11:51:24 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2012-10-05 11:56:12 +1000 |
commit | 75347b8668c3e2e8b2b473c06a706cd3ba041c55 (patch) | |
tree | 2c56f03d55de5f82f1443207833dd390edb3fd71 /ctdb/common | |
parent | 2d719e5c84e3f898a992e97992c94a2ffb94e3a0 (diff) | |
download | samba-75347b8668c3e2e8b2b473c06a706cd3ba041c55.tar.gz samba-75347b8668c3e2e8b2b473c06a706cd3ba041c55.tar.xz samba-75347b8668c3e2e8b2b473c06a706cd3ba041c55.zip |
util: ctdb_fork() closes all sockets opened by the main daemon
Do some other hosuekeeping including stopping tevent.
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 212298279557a2833ef0f81809b4a5cdac72ca02)
Diffstat (limited to 'ctdb/common')
-rw-r--r-- | ctdb/common/ctdb_fork.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c index 81055c5fc92..24534e66c0a 100644 --- a/ctdb/common/ctdb_fork.c +++ b/ctdb/common/ctdb_fork.c @@ -37,6 +37,24 @@ pid_t ctdb_fork(struct ctdb_context *ctdb) return -1; } if (pid == 0) { + /* Close the Unix Domain socket and the TCP socket. + * This ensures that none of the child processes will + * look like the main daemon when it is not running. + * tevent needs to be stopped before closing sockets. + */ + if (ctdb->ev != NULL) { + talloc_free(ctdb->ev); + ctdb->ev = NULL; + } + if (ctdb->daemon.sd != -1) { + close(ctdb->daemon.sd); + ctdb->daemon.sd = -1; + } + if (ctdb->methods != NULL) { + ctdb->methods->shutdown(ctdb); + } + + /* The child does not need to be realtime */ if (ctdb->do_setsched) { ctdb_restore_scheduler(ctdb); } |