ctdb-daemon: Handle failure immediately, do housekeeping later
commitd9f5a6ab0fba3c7ba77c93040c7e190877c3573d
authorMartin Schwenke <martin@meltin.net>
Fri, 26 Aug 2016 06:38:56 +0000 (26 16:38 +1000)
committerStefan Metzmacher <metze@samba.org>
Tue, 6 Sep 2016 06:22:17 +0000 (6 08:22 +0200)
treea7b82f61ee897c58912068277b50fa283ac8389d
parent41ca635abb14ee3fd881978d1559c284e2e4737a
ctdb-daemon: Handle failure immediately, do housekeeping later

The callback should never be called before an immediate return.  The
callback might reply to a control and the caller of
ctdb_event_script_callback_v() may not have assigned/stolen the
pointer to control structure into the private data.  Therefore,
calling the callback can dereference an uninitialised pointer to the
control structure when attempting to reply.

An event script isn't being run until the child has been forked.  So
update relevant state and set the destructor after this.

If the child can't be forked then free the state and return with an
error.  The callback will not be called and the caller will process
the error correctly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 582518c7e89b279e34147bdb0b04b73056fac048)
ctdb/server/eventscript.c