eventscript: fix callback after free
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 25 Jul 2011 08:26:06 +0000 (17:56 +0930)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 28 Jul 2011 22:50:39 +0000 (08:50 +1000)
commit6fcd867cc835ef1ffc1c50964f135c346503d40c
tree491ef6a72d841d8e908affdf2f721f0e1b75bf83
parentaa8114a625a637277561a66c80bdece3c27e9e20
eventscript: fix callback after free

ctdb_event_script_callback() takes a mem_ctx arg which it doesn't use, but
the implication is pretty clear, that when that mem_ctx is freed, the callback
shouldn't happen.  Indeed, Ronnie reproduced a case where that callback
refers to freed memory, in the ip reallocation code under stress.

So attach the callback to the mem_ctx they give us, and remove it from the
script state structure when that's freed.  It's a bit weird, but it works.

CQ: S1026179
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
server/eventscript.c