diff options
author | Martin Schwenke <martin@meltin.net> | 2013-02-06 14:15:11 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-02-07 11:26:29 +1100 |
commit | 689384a7b475fb6434ac022267d37414d73ad7b4 (patch) | |
tree | e9d3ae2c12c826e4c5fc6405c2e477c7b272fd61 /ctdb/common | |
parent | 140be1e267fee7a1ee1e711467ddd39597568241 (diff) | |
download | samba-689384a7b475fb6434ac022267d37414d73ad7b4.tar.gz samba-689384a7b475fb6434ac022267d37414d73ad7b4.tar.xz samba-689384a7b475fb6434ac022267d37414d73ad7b4.zip |
Logging: Fix breakage when freeing the log ringbuffer
Commit a82d3ec12f0fda16d6bfa8442a07595de897c10e broke fetching from
the log ringbuffer. The solution there is still generally good: there
is no need to keep the ringbuffer in children created by
ctdb_fork()... except for those special children that are created to
fetch data from the ringbuffer!
Introduce a new function ctdb_fork_no_free_ringbuffer() that does
everything ctdb_fork() needs to do except free the ringbuffer (i.e. it
is the old ctdb_fork() function). The new ctdb_fork() function just
calls that function and then frees the ringbuffer in the child.
This means all callers of ctdb_fork() have the convenience of having
the ringbuffer freed. There are 3 special cases:
* Forking the recovery daemon. We want to be able to fetch from the
ringbuffer there.
* The ringbuffer fetching code. Change the 2 calls in this code (main
daemon, recovery daemon) to call ctdb_fork_no_free_ringbuffer()
instead.
While we're here, clear the log ringbuffer when the recovery deamon is
forked, since it will contain a copy of the messages from the main
daemon.
Note to self: always test... even the most obvious patches... ;-)
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 00db5fa00474f8a83f1aa3b603fd756cc9b49ff4)
Diffstat (limited to 'ctdb/common')
-rw-r--r-- | ctdb/common/ctdb_fork.c | 15 | ||||
-rw-r--r-- | ctdb/common/ctdb_logging.c | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c index a11f75a6de5..9e3a06d889c 100644 --- a/ctdb/common/ctdb_fork.c +++ b/ctdb/common/ctdb_fork.c @@ -27,7 +27,7 @@ * This function forks a child process and drops the realtime * scheduler for the child process. */ -pid_t ctdb_fork(struct ctdb_context *ctdb) +pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb) { pid_t pid; char *process; @@ -60,8 +60,6 @@ pid_t ctdb_fork(struct ctdb_context *ctdb) } ctdb->can_send_controls = false; - ctdb_log_ringbuffer_free(); - return 0; } @@ -75,6 +73,17 @@ pid_t ctdb_fork(struct ctdb_context *ctdb) return pid; } +pid_t ctdb_fork(struct ctdb_context *ctdb) +{ + pid_t pid; + + pid = ctdb_fork_no_free_ringbuffer(ctdb); + if (pid == 0) { + ctdb_log_ringbuffer_free(); + } + + return pid; +} static void ctdb_sigchld_handler(struct tevent_context *ev, diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c index 105b4df5996..de5ca6e68f6 100644 --- a/ctdb/common/ctdb_logging.c +++ b/ctdb/common/ctdb_logging.c @@ -163,7 +163,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr) /* spawn a child process to marshall the huge log blob and send it back to the ctdb tool using a MESSAGE */ - child = ctdb_fork(ctdb); + child = ctdb_fork_no_free_ringbuffer(ctdb); if (child == (pid_t)-1) { DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n")); return -1; |