summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-01-22 13:27:20 +1100
committerAmitay Isaacs <amitay@gmail.com>2013-02-05 14:42:19 +1100
commit11c75419cd1da2573fcd166c2a67cd0de085f168 (patch)
tree36cb6414bb749436380f076c1ee095b222b7d4e0
parent8dc3219e9b9977f9a07e7caa53299071002b20c2 (diff)
downloadsamba-11c75419cd1da2573fcd166c2a67cd0de085f168.tar.gz
samba-11c75419cd1da2573fcd166c2a67cd0de085f168.tar.xz
samba-11c75419cd1da2573fcd166c2a67cd0de085f168.zip
daemon: Make sure all the traverse children are terminated if traverse times out
When traverse times out, callback function is called with key and data set to tdb_null. This is also the way to signal end of traverse. So if the traverse times out, callback function treats it as traverse ended and frees state without calling the destructor. Keep track if the traverse timed out, so callback function can take appropriate action for traverse timeout and traverse end. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 35da9a7c2a0f5e54e61588c3c3455f06ebc66822)
-rw-r--r--ctdb/server/ctdb_traverse.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ctdb/server/ctdb_traverse.c b/ctdb/server/ctdb_traverse.c
index 54ee70f638..5b709dc52d 100644
--- a/ctdb/server/ctdb_traverse.c
+++ b/ctdb/server/ctdb_traverse.c
@@ -214,6 +214,7 @@ struct ctdb_traverse_all_handle {
ctdb_traverse_fn_t callback;
void *private_data;
uint32_t null_count;
+ bool timedout;
};
/*
@@ -243,6 +244,7 @@ static void ctdb_traverse_all_timeout(struct event_context *ev, struct timed_eve
DEBUG(DEBUG_ERR,(__location__ " Traverse all timeout on database:%s\n", state->ctdb_db->db_name));
CTDB_INCREMENT_STAT(state->ctdb, timeouts.traverse);
+ state->timedout = true;
state->callback(state->private_data, tdb_null, tdb_null);
}
@@ -288,6 +290,7 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
state->callback = callback;
state->private_data = start_state;
state->null_count = 0;
+ state->timedout = false;
talloc_set_destructor(state, ctdb_traverse_all_destructor);
@@ -549,9 +552,14 @@ static void traverse_start_callback(void *p, TDB_DATA key, TDB_DATA data)
ctdb_dispatch_message(state->ctdb, state->srvid, cdata);
if (key.dsize == 0 && data.dsize == 0) {
- /* end of traverse */
- talloc_set_destructor(state, NULL);
- talloc_free(state);
+ if (state->h->timedout) {
+ /* timed out, send TRAVERSE_KILL control */
+ talloc_free(state);
+ } else {
+ /* end of traverse */
+ talloc_set_destructor(state, NULL);
+ talloc_free(state);
+ }
}
}