Logging: Fix breakage when freeing the log ringbuffer
authorMartin Schwenke <martin@meltin.net>
Wed, 6 Feb 2013 03:15:11 +0000 (14:15 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 7 Feb 2013 00:26:29 +0000 (11:26 +1100)
commit00db5fa00474f8a83f1aa3b603fd756cc9b49ff4
treedce6ba042dcc8fb65af943093219452fd24fe77a
parentb940e3a24daa73ca9b2896b7a449240136442b53
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>
common/ctdb_fork.c
common/ctdb_logging.c
include/ctdb_private.h
server/ctdb_recoverd.c