Rev 151: simpler shutdown process. The reply is not actually needed, and in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Wed Apr 18 05:35:41 GMT 2007


------------------------------------------------------------
revno: 151
revision-id: tridge at samba.org-20070418053541-815ac1776bf2937f
parent: tridge at samba.org-20070418052738-c581c86e6c27b24e
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Wed 2007-04-18 15:35:41 +1000
message:
  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.
modified:
  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
=== modified file 'common/ctdb_client.c'
--- a/common/ctdb_client.c	2007-04-18 04:08:45 +0000
+++ b/common/ctdb_client.c	2007-04-18 05:35:41 +0000
@@ -93,19 +93,6 @@
 }
 
 /*
-  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
  */
 static void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args)
@@ -121,9 +108,13 @@
 	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 @@
 		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));
 	}

=== modified file 'common/ctdb_daemon.c'
--- a/common/ctdb_daemon.c	2007-04-18 04:08:45 +0000
+++ b/common/ctdb_daemon.c	2007-04-18 05:35:41 +0000
@@ -197,7 +197,6 @@
 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 @@
 		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);

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-04-18 02:39:03 +0000
+++ b/include/ctdb_private.h	2007-04-18 05:35:41 +0000
@@ -222,8 +222,7 @@
 	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 */



More information about the samba-cvs mailing list