diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-18 11:55:54 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-04-18 11:55:54 +1000 |
commit | 7a02b09b01363fdf7e12f10eb46f18492823a2a9 (patch) | |
tree | 56baf130d0576610d5be1195884860ebc77d1993 | |
parent | aac20642b28ea19003606275cfa2b9902c4b566e (diff) | |
download | samba-7a02b09b01363fdf7e12f10eb46f18492823a2a9.tar.gz samba-7a02b09b01363fdf7e12f10eb46f18492823a2a9.tar.xz samba-7a02b09b01363fdf7e12f10eb46f18492823a2a9.zip |
started adding a cleaner daemon finish method
(This used to be ctdb commit 5ef0cd83d7f24616dad85cece485b770376ecd45)
-rw-r--r-- | ctdb/common/ctdb.c | 4 | ||||
-rw-r--r-- | ctdb/common/ctdb_client.c | 5 | ||||
-rw-r--r-- | ctdb/common/ctdb_daemon.c | 12 | ||||
-rw-r--r-- | ctdb/include/ctdb_private.h | 6 | ||||
-rw-r--r-- | ctdb/tests/ctdb_test.c | 7 | ||||
-rwxr-xr-x | ctdb/tests/test.sh | 12 |
6 files changed, 35 insertions, 11 deletions
diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index 60e1e6b90b..a086fc4cfd 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -255,6 +255,10 @@ void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t length) 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)); diff --git a/ctdb/common/ctdb_client.c b/ctdb/common/ctdb_client.c index aca243eda1..4e5e7701cc 100644 --- a/ctdb/common/ctdb_client.c +++ b/ctdb/common/ctdb_client.c @@ -434,6 +434,11 @@ void ctdb_connect_wait(struct ctdb_context *ctdb) 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) { diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index a4bb36d482..1e85440efd 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -611,3 +611,15 @@ void *ctdbd_allocate_pkt(struct ctdb_context *ctdb, size_t len) 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); + } +} diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 6736ee4ab7..bf6b96e635 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -117,6 +117,7 @@ struct ctdb_context { 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 @@ enum ctdb_operation { 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 @@ struct ctdb_req_message { uint8_t data[1]; }; +struct ctdb_req_finished { + struct ctdb_req_header hdr; +}; + struct ctdb_req_connect_wait { struct ctdb_req_header hdr; }; diff --git a/ctdb/tests/ctdb_test.c b/ctdb/tests/ctdb_test.c index dea9066eb2..e051305725 100644 --- a/ctdb/tests/ctdb_test.c +++ b/ctdb/tests/ctdb_test.c @@ -133,6 +133,8 @@ int main(int argc, const char *argv[]) /* 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 @@ int main(int argc, const char *argv[]) /* 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; diff --git a/ctdb/tests/test.sh b/ctdb/tests/test.sh index f119ad5b1b..b1ed1d20d7 100755 --- a/ctdb/tests/test.sh +++ b/ctdb/tests/test.sh @@ -4,17 +4,17 @@ killall -q ctdb_test 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 |