diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-27 15:26:13 +0200 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-04-27 15:26:13 +0200 |
commit | 3dc6331aee4d2d37c03fdcd52e62762463c1a00f (patch) | |
tree | 144837ab26dd9b1d91b9f39c99116d95ea2fa566 | |
parent | 22546add19e02028dcca81ad453c1306cae51081 (diff) | |
parent | f616f2de10769af0c6d2a394f9c9b615ab891922 (diff) | |
download | samba-3dc6331aee4d2d37c03fdcd52e62762463c1a00f.tar.gz samba-3dc6331aee4d2d37c03fdcd52e62762463c1a00f.tar.xz samba-3dc6331aee4d2d37c03fdcd52e62762463c1a00f.zip |
merged broadcast messages from ronnie
(This used to be ctdb commit bc20a7de280dbaa5e8ceb5493c51c059aa80d41c)
-rw-r--r-- | ctdb/common/ctdb_daemon.c | 2 | ||||
-rw-r--r-- | ctdb/common/ctdb_message.c | 35 | ||||
-rw-r--r-- | ctdb/include/ctdb_private.h | 5 |
3 files changed, 29 insertions, 13 deletions
diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index 0e810a0b2e..00baa4dd91 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -266,7 +266,7 @@ static void daemon_request_message_from_client(struct ctdb_client *client, 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; diff --git a/ctdb/common/ctdb_message.c b/ctdb/common/ctdb_message.c index 70fcf00c4d..95df3c2c8d 100644 --- a/ctdb/common/ctdb_message.c +++ b/ctdb/common/ctdb_message.c @@ -39,16 +39,11 @@ static int ctdb_dispatch_message(struct ctdb_context *ctdb, uint32_t srvid, TDB_ /* 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 @@ int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn, 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; diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index bfa16101d7..848941f84b 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -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 */ |