daemon: Protect against double free of callback state while shutting down
authorAmitay Isaacs <amitay@gmail.com>
Mon, 29 Oct 2012 03:56:10 +0000 (14:56 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Wed, 9 Jan 2013 03:39:23 +0000 (14:39 +1100)
commit4a6fa39ff96e10b1f36b0656ca27ea74f20ff110
tree58c489a5632be6bb2f3a15c810f0dbeef79b5f86
parent30299c387f3c9695afb716b3787035cf7c441333
daemon: Protect against double free of callback state while shutting down

When CTDB is shut down and monitoring has been stopped, monitor_context
gets freed and all the callback states hanging off it.  This includes
callback state for current_monitor, if the current monitor event has
not yet finished.  As a result, when the shutdown event is called,
current_monitor->callback state is not NULL, but it's actually freed
and it's a dangling reference.

So before executing callback function and freeing callback state check
if ctdb->monitor->monitor_context is not NULL.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 7d8546ee4353851f0543d0ca2c4c67cb0cc75aea)
ctdb/include/ctdb_private.h
ctdb/server/ctdb_monitor.c
ctdb/server/eventscript.c