eventscript: remove cb_status, fix uninitialized bug when monitoring aborted
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Dec 2009 04:08:15 +0000 (14:38 +1030)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 17 Dec 2009 04:39:46 +0000 (15:39 +1100)
commit5d50f0e16948d18009f6623f132113f7273efc7f
tree02383aa2310d81f64becbca8f2dfbd45a6bc4d1e
parentb4365045797f520a7914afdb69ebd1a8dacfa0d9
eventscript: remove cb_status, fix uninitialized bug when monitoring aborted

Previously we updated cb_status a each script finished.  Since we're storing
the status anyway, we can calculate it by iterating the scripts array
itself, providing clear and uniform behavior on all code paths.

In particular, this fixes a longstanding bug when we abort monitor
scripts to run some other script: the cb_status was uninitialized.  In
this case, we need to hand *something* to the callback; 0 might make
us go healthy when we shouldn't.  So we use the last status (normally,
this will be the just-saved current status).

In addition, we make the case of failing the first fork for the script
and failing other script forks the same: the error is returned via the
callback and saved for viewing through 'ctdb scriptstatus'.

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