diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2008-05-11 14:28:33 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2008-05-11 14:28:33 +1000 |
commit | adf40341a7a818336939631b0b8d399699013744 (patch) | |
tree | 80c06348a333e3331f24ee591a3b7cfdaa566122 /ctdb/server/ctdb_daemon.c | |
parent | ac9b9679bb84bd3612764ae686f944e8a701664e (diff) | |
download | samba-adf40341a7a818336939631b0b8d399699013744.tar.gz samba-adf40341a7a818336939631b0b8d399699013744.tar.xz samba-adf40341a7a818336939631b0b8d399699013744.zip |
ctdb->methods becomes NULL when we shutdown the transport.
If we shutdown the transport and CTDB later decides to send a command out
for queueing, the call to ctdb->methods->allocate_pkt() will SEGV.
This could trigger for example when we are in the process of shuttind down CTDBD and have already shutdown the transport but we are still waiting for the
"shutdown" eventscripts to finish.
If the event scripts now take much much longer to execute for some reason, this
race condition becomes much more probable.
Decorate all dereferencing of ctdb->methods-> with a check that ctdb->menthods is non-NULL
(This used to be ctdb commit c4c2c53918da6fb566d6e9cbd6b02e61ae2921e7)
Diffstat (limited to 'ctdb/server/ctdb_daemon.c')
-rw-r--r-- | ctdb/server/ctdb_daemon.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 93af56c176..326ab60e0d 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -71,6 +71,11 @@ static void print_exit_message(void) /* called when the "startup" event script has finished */ static void ctdb_start_transport(struct ctdb_context *ctdb) { + if (ctdb->methods == NULL) { + DEBUG(DEBUG_ALERT,(__location__ " startup event finished but transport is DOWN.\n")); + ctdb_fatal(ctdb, "transport is not initialized but startup completed"); + } + /* start the transport running */ if (ctdb->methods->start(ctdb) != 0) { DEBUG(DEBUG_ALERT,("transport failed to start!\n")); @@ -689,6 +694,11 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork) return -1; } + if (ctdb->methods == NULL) { + DEBUG(DEBUG_ALERT,(__location__ " Can not initialize transport. ctdb->methods is NULL\n")); + ctdb_fatal(ctdb, "transport is unavailable. can not initialize."); + } + /* initialise the transport */ if (ctdb->methods->initialise(ctdb) != 0) { ctdb_fatal(ctdb, "transport failed to initialise"); @@ -743,6 +753,12 @@ struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb, length = MAX(length, slength); size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1); + if (ctdb->methods == NULL) { + DEBUG(DEBUG_ERR,(__location__ " Unable to allocate transport packet for operation %u of length %u. Transport is DOWN.\n", + operation, (unsigned)length)); + return NULL; + } + hdr = (struct ctdb_req_header *)ctdb->methods->allocate_pkt(mem_ctx, size); if (hdr == NULL) { DEBUG(DEBUG_ERR,("Unable to allocate transport packet for operation %u of length %u\n", |