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));
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) {
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);
+ }
+}
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 */
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,
uint8_t data[1];
};
+struct ctdb_req_finished {
+ struct ctdb_req_header hdr;
+};
+
struct ctdb_req_connect_wait {
struct ctdb_req_header hdr;
};
/* 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;
/* 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;
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