From rusty:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 14 Dec 2009 23:23:58 +0000 (10:23 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 14 Dec 2009 23:23:58 +0000 (10:23 +1100)
commit211ea7907e8e96041aa6f7d086551d64d065a8a3
treefeb9fe391e3e59e24735ce4d9fa53acc94607d6c
parent5c8e56fc7a518e115bceac257867739283cf6a1e
From rusty:

Subject: eventscript: fix spinning at 100% cpu when child exits.

ctdbd was spinning reading 0 from a pipe, as soon as the first
eventscript finishes.

This was caused by the intersection between a78b8ea7168e "Run only one
event for each epoll_wait/select call" and 32cfdc3aec34 "eventscript:
ctdb_fork_with_logging()".  Unavoidable mid-air collision, since both
worked fine and both were developed simultaneously.

When the script exits, we have two pipes open to it: one for any
stdout/stderr for logging (ctdb_log_handler), and one for the result
(ctdb_event_script_handler).  The latter frees everything, including
the log fd and event structure.

We used to get one callback to ctdb_log_handler, which got a harmless
0-length read, then one to ctdb_event_script_handler which cleaned up.
Now we only do one callback per poll, we need the logging function to
clean itself up so we can make process.

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