eventscript: remove cb_status, fix uninitialized bug when monitoring aborted
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 18 Dec 2009 03:24:40 +0000 (13:54 +1030)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 18 Dec 2009 03:48:35 +0000 (14:48 +1100)
commit2c84fe393ff2b961abf77d58a371c24db5ecb93b
treea847682f1fdf2cd3f951998e91134c6454c157e9
parent859e18db681dabe0990793d03f58e59a061aa8bb
eventscript: remove cb_status, fix uninitialized bug when monitoring aborted

(Reapplied with merge after accidental revert)

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