From: Andrew Tridgell Date: Wed, 18 Apr 2007 05:35:41 +0000 (+1000) Subject: simpler shutdown process. The reply is not actually needed, and X-Git-Tag: tevent-0.9.20~348^2~2880 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ddf430b2f2229699f834a5bace056f73cc695809;p=thirdparty%2Fsamba.git simpler shutdown process. The reply is not actually needed, and occasionally leads to problems if an immediate send on the socket causes a context switch and the client exiting before the daemon. We now exit the client when the daemon goes away. (This used to be ctdb commit b7bed0088e700f25105ceea63640b38804f51e4d) --- diff --git a/ctdb/common/ctdb_client.c b/ctdb/common/ctdb_client.c index fb2018510d1..1eef235e00c 100644 --- a/ctdb/common/ctdb_client.c +++ b/ctdb/common/ctdb_client.c @@ -92,19 +92,6 @@ void ctdb_reply_fetch_lock(struct ctdb_context *ctdb, struct ctdb_req_header *hd state->state = CTDB_FETCH_LOCK_DONE; } -/* - called in the client when we receive a CTDB_REPLY_SHUTDOWN from the daemon - - This packet comes in response to a CTDB_REQ_SHUTDOWN request packet. It - contains any reply data from the call -*/ -void ctdb_reply_shutdown(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) -{ - talloc_free(ctdb); - - exit(10); -} - /* this is called in the client, when data comes in from the daemon */ @@ -121,9 +108,13 @@ static void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args) tmp_ctx = talloc_new(ctdb); talloc_steal(tmp_ctx, hdr); + if (cnt == 0) { + DEBUG(2,("Daemon has exited - shutting down client\n")); + exit(0); + } + if (cnt < sizeof(*hdr)) { - ctdb_set_error(ctdb, "Bad packet length %d in client\n", cnt); - exit(1); /* XXX - temporary for debugging */ + DEBUG(0,("Bad packet length %d in client\n", cnt)); goto done; } if (cnt != hdr->length) { @@ -159,10 +150,6 @@ static void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args) ctdb_reply_fetch_lock(ctdb, hdr); break; - case CTDB_REPLY_SHUTDOWN: - ctdb_reply_shutdown(ctdb, hdr); - break; - default: DEBUG(0,("bogus operation code:%d\n",hdr->operation)); } diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index cb05c4176b4..14019ea3f10 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -197,7 +197,6 @@ static void daemon_fetch_lock_complete(struct ctdb_call_state *state) static void daemon_request_shutdown(struct ctdb_client *client, struct ctdb_req_shutdown *f) { - struct ctdb_reply_shutdown rs; struct ctdb_context *ctdb = talloc_get_type(client->ctdb, struct ctdb_context); int len; uint32_t node; @@ -240,16 +239,6 @@ static void daemon_request_shutdown(struct ctdb_client *client, event_loop_once(ctdb->ev); } - /* send a shutdown reply back to the client */ - len = sizeof(struct ctdb_reply_shutdown); - ZERO_STRUCT(rs); - rs.hdr.length = len; - rs.hdr.ctdb_magic = CTDB_MAGIC; - rs.hdr.ctdb_version = CTDB_VERSION; - rs.hdr.operation = CTDB_REPLY_SHUTDOWN; - ctdb_queue_send(client->queue, (uint8_t *)&(rs.hdr), rs.hdr.length); - /* XXX we should wait here until the packet has been sent to the client */ - /* 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 3180366ff08..7b069e1331e 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -222,8 +222,7 @@ enum ctdb_operation { CTDB_REPLY_CONNECT_WAIT = 1002, CTDB_REQ_FETCH_LOCK = 1003, CTDB_REPLY_FETCH_LOCK = 1004, - CTDB_REQ_SHUTDOWN = 1005, - CTDB_REPLY_SHUTDOWN = 1006, + CTDB_REQ_SHUTDOWN = 1005 }; #define CTDB_MAGIC 0x43544442 /* CTDB */