Rev 202: merged broadcast messages from ronnie in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Fri Apr 27 13:26:14 GMT 2007


------------------------------------------------------------
revno: 202
revision-id: tridge at samba.org-20070427132613-jlz3n8rz4icubshz
parent: tridge at samba.org-20070427131436-wm4r5ylzeocpzs2z
parent: sahlberg at ronnie-20070427131617-80d257e288bc8ec6
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Fri 2007-04-27 15:26:13 +0200
message:
  merged broadcast messages from ronnie
modified:
  common/ctdb_daemon.c           ctdb_daemon.c-20070409200331-3el1kqgdb9m4ib0g-1
  common/ctdb_message.c          ctdb_message.c-20070208224107-9dnio7x7z33prrmt-1
  include/ctdb_private.h         ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13
    ------------------------------------------------------------
    revno: 197.1.5
    merged: sahlberg at ronnie-20070427131617-80d257e288bc8ec6
    parent: sahlberg at ronnie-20070427120812-5abf7503c3753756
    committer: Ronnie Sahlberg <sahlberg at ronnie>
    branch nick: ctdb
    timestamp: Fri 2007-04-27 23:16:17 +1000
    message:
      add a special VNN that means "all" nodes so that a message can be 
      broadcasted to all daemons in the cluster
      
      change the message dispatch routine for sending messages so that it 
      allows several clients to use the same srvid
      messages are then passed on to all clients that have that srvid
=== modified file 'common/ctdb_daemon.c'
--- a/common/ctdb_daemon.c	2007-04-27 08:43:52 +0000
+++ b/common/ctdb_daemon.c	2007-04-27 13:16:17 +0000
@@ -266,7 +266,7 @@
 		ctdb_request_message(client->ctdb, (struct ctdb_req_header *)c);
 		return;
 	}
-	
+
 	/* its for a remote node */
 	data.dptr = &c->data[0];
 	data.dsize = c->datalen;

=== modified file 'common/ctdb_message.c'
--- a/common/ctdb_message.c	2007-04-19 21:47:37 +0000
+++ b/common/ctdb_message.c	2007-04-27 13:16:17 +0000
@@ -39,16 +39,11 @@
 	/* XXX we need a must faster way of finding the matching srvid
 	   - maybe a tree? */
 	for (ml=ctdb->message_list;ml;ml=ml->next) {
-		if (ml->srvid == srvid || ml->srvid == CTDB_SRVID_ALL) break;
-	}
-	if (ml == NULL) {
-		DEBUG(1,(__location__ " daemon vnn:%d  no msg handler for srvid=%u\n", 
-			 ctdb_get_vnn(ctdb), srvid));
-		/* no registered message handler */
-		return -1;
+		if (ml->srvid == srvid || ml->srvid == CTDB_SRVID_ALL) {
+			ml->message_handler(ctdb, srvid, data, ml->message_private);
+		}
 	}
 
-	ml->message_handler(ctdb, srvid, data, ml->message_private);
 	return 0;
 }
 
@@ -141,8 +136,28 @@
 	r->srvid         = srvid;
 	r->datalen       = data.dsize;
 	memcpy(&r->data[0], data.dptr, data.dsize);
-	
-	ctdb_queue_packet(ctdb, &r->hdr);
+
+	if (vnn != CTDB_BROADCAST_VNN) {
+		ctdb_queue_packet(ctdb, &r->hdr);
+	} else {
+		struct ctdb_node *node;
+		int i;
+
+		/* this was a broadcast message
+		   loop over all other nodes and send them each a copy
+		*/
+		for (i=0; i<ctdb_get_num_nodes(ctdb); i++) {
+			node=ctdb->nodes[i];
+
+			/* we do not send the message to ourself */
+			if (node && node->vnn!=ctdb->vnn) {
+				r->hdr.destnode = node->vnn;
+				ctdb_queue_packet(ctdb, &r->hdr);
+			}
+		}
+		/* also make sure to dispatch the message locally */
+		ctdb_dispatch_message(ctdb, srvid, data);
+	}
 
 	talloc_free(r);
 	return 0;

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-04-27 13:14:36 +0000
+++ b/include/ctdb_private.h	2007-04-27 13:26:13 +0000
@@ -30,9 +30,10 @@
 #define CTDB_DS_ALIGNMENT 8
 
 
-#define CTDB_NULL_FUNC 0xf0000001
-#define CTDB_CURRENT_NODE 0xF0000001
+#define CTDB_NULL_FUNC     0xF0000001
 
+#define CTDB_CURRENT_NODE  0xF0000001
+#define CTDB_BROADCAST_VNN 0xF0000002
 /*
   an installed ctdb remote call
 */



More information about the samba-cvs mailing list