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:46:42 +0000 (08:46 +1000)
commit1a184c487b2db160f84bca16d1c2e721ff0628eb
tree408ace12b599fc25232029d9ddf3bd71967a726a
parent6d7a6d81b9de77b1d0b1bd42e870e99922ef9f76
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