------------------------------------------------------------ revno: 146 revision-id: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Andrew Tridgell <[EMAIL PROTECTED]> branch nick: tridge timestamp: Wed 2007-04-18 11:55:54 +1000 message: started adding a cleaner daemon finish method modified: common/ctdb.c ctdb.c-20061127094323-t50f58d65iaao5of-2 common/ctdb_client.c ctdb_client.c-20070411010216-3kd8v37k61steeya-1 common/ctdb_daemon.c ctdb_daemon.c-20070409200331-3el1kqgdb9m4ib0g-1 include/ctdb_private.h ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13 tests/ctdb_test.c ctdb_test.c-20061117234101-o3qt14umlg9en8z0-16 tests/test.sh test.sh-20061128065333-cla80zaxd9eb4o4a-2 === modified file 'common/ctdb.c' --- a/common/ctdb.c 2007-04-18 01:20:24 +0000 +++ b/common/ctdb.c 2007-04-18 01:55:54 +0000 @@ -255,6 +255,10 @@ ctdb_request_message(ctdb, hdr); break; + case CTDB_REQ_FINISHED: + ctdb_request_finished(ctdb, hdr); + break; + default: DEBUG(0,("%s: Packet with unknown operation %d\n", __location__, hdr->operation));
=== modified file 'common/ctdb_client.c' --- a/common/ctdb_client.c 2007-04-18 01:20:24 +0000 +++ b/common/ctdb_client.c 2007-04-18 01:55:54 +0000 @@ -434,6 +434,11 @@ r.hdr.operation = CTDB_REQ_CONNECT_WAIT; DEBUG(3,("ctdb_connect_wait: sending to ctdbd\n")); + + /* if the domain socket is not yet open, open it */ + if (ctdb->daemon.sd==-1) { + ux_socket_connect(ctdb); + } res = ctdb_queue_send(ctdb->daemon.queue, (uint8_t *)&r.hdr, r.hdr.length); if (res != 0) { === modified file 'common/ctdb_daemon.c' --- a/common/ctdb_daemon.c 2007-04-18 01:33:16 +0000 +++ b/common/ctdb_daemon.c 2007-04-18 01:55:54 +0000 @@ -611,3 +611,15 @@ return talloc_size(ctdb, size); } +/* + called when a CTDB_REQ_FINISHED packet comes in +*/ +void ctdb_request_finished(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) +{ + ctdb->num_finished++; + if (ctdb->num_finished == ctdb->num_nodes) { + /* all daemons have requested to finish - we now exit */ + DEBUG(1,("All daemons finished - exiting\n")); + _exit(0); + } +} === modified file 'include/ctdb_private.h' --- a/include/ctdb_private.h 2007-04-18 01:20:24 +0000 +++ b/include/ctdb_private.h 2007-04-18 01:55:54 +0000 @@ -117,6 +117,7 @@ uint32_t vnn; /* our own vnn */ uint32_t num_nodes; uint32_t num_connected; + uint32_t num_finished; unsigned flags; struct idr_context *idr; struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */ @@ -213,6 +214,7 @@ CTDB_REPLY_DMASTER = 4, CTDB_REPLY_ERROR = 5, CTDB_REQ_MESSAGE = 6, + CTDB_REQ_FINISHED = 7, /* only used on the domain socket */ CTDB_REQ_REGISTER = 1000, @@ -294,6 +296,10 @@ uint8_t data[1]; }; +struct ctdb_req_finished { + struct ctdb_req_header hdr; +}; + struct ctdb_req_connect_wait { struct ctdb_req_header hdr; }; === modified file 'tests/ctdb_test.c' --- a/tests/ctdb_test.c 2007-04-17 12:16:50 +0000 +++ b/tests/ctdb_test.c 2007-04-18 01:55:54 +0000 @@ -133,6 +133,8 @@ /* start the protocol running */ ret = ctdb_start(ctdb); + ctdb_connect_wait(ctdb); + ZERO_STRUCT(call); call.key.dptr = discard_const("test"); call.key.dsize = strlen("test")+1; @@ -171,11 +173,6 @@ /* go into a wait loop to allow other nodes to complete */ ctdb_wait_loop(ctdb); - /*talloc_report_full(ctdb, stdout);*/ - -/* sleep for a while so that our daemon will remaining alive for the other nodes in the cluster */ -sleep(10); - /* shut it down */ talloc_free(ctdb); return 0; === modified file 'tests/test.sh' --- a/tests/test.sh 2007-04-17 05:01:42 +0000 +++ b/tests/test.sh 2007-04-18 01:55:54 +0000 @@ -4,17 +4,17 @@ echo "Trying 2 nodes" -bin/ctdb_test --nlist tests/nodes.txt --listen 127.0.0.1:9001 & -bin/ctdb_test --nlist tests/nodes.txt --listen 127.0.0.2:9001 +$VALGRIND bin/ctdb_test --nlist tests/nodes.txt --listen 127.0.0.1:9001 & +$VALGRIND bin/ctdb_test --nlist tests/nodes.txt --listen 127.0.0.2:9001 sleep 3 killall ctdb_test echo "Trying 4 nodes" -bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.1:9001 & -bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.2:9001 & -bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.3:9001 & -bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.4:9001 +$VALGRIND bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.1:9001 & +$VALGRIND bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.2:9001 & +$VALGRIND bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.3:9001 & +$VALGRIND bin/ctdb_test --nlist tests/4nodes.txt --listen 127.0.0.4:9001 sleep 3 killall ctdb_test