diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-11 14:05:01 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-04-11 14:05:01 +1000 |
commit | c658d5c1e886bca120ee5f0fdd2c55789083a51c (patch) | |
tree | 2eabb703123530a068182331708de3dfd71d1de8 /ctdb/common/ctdb_message.c | |
parent | ad1f17ab1c515cfb8ce892354b25fc9fc56e6440 (diff) | |
parent | 185cd326da46268aba068f37ad1741b7e6c30cbb (diff) | |
download | samba-c658d5c1e886bca120ee5f0fdd2c55789083a51c.tar.gz samba-c658d5c1e886bca120ee5f0fdd2c55789083a51c.tar.xz samba-c658d5c1e886bca120ee5f0fdd2c55789083a51c.zip |
merge from ronnie, plus complete the client side of inter-node messaging
(This used to be ctdb commit e605417436855d22343462acae4cbb79a374977e)
Diffstat (limited to 'ctdb/common/ctdb_message.c')
-rw-r--r-- | ctdb/common/ctdb_message.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/ctdb/common/ctdb_message.c b/ctdb/common/ctdb_message.c index 27c5c64bc0e..088f882dbd5 100644 --- a/ctdb/common/ctdb_message.c +++ b/ctdb/common/ctdb_message.c @@ -37,22 +37,30 @@ void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) { struct ctdb_req_message *c = (struct ctdb_req_message *)hdr; + struct ctdb_message_list *ml; TDB_DATA data; - if (ctdb->message_handler == NULL) { + + /* 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 == c->srvid) break; + } + if (ml == NULL) { printf("no msg handler\n"); /* no registered message handler */ return; } + data.dptr = &c->data[0]; data.dsize = c->datalen; - ctdb->message_handler(ctdb, c->srvid, data, ctdb->message_private); + ml->message_handler(ctdb, c->srvid, data, ml->message_private); } /* send a ctdb message */ -int ctdb_send_message(struct ctdb_context *ctdb, uint32_t vnn, +int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn, uint32_t srvid, TDB_DATA data) { struct ctdb_req_message *r; @@ -81,11 +89,25 @@ int ctdb_send_message(struct ctdb_context *ctdb, uint32_t vnn, } /* + send a ctdb message +*/ +int ctdb_send_message(struct ctdb_context *ctdb, uint32_t vnn, + uint32_t srvid, TDB_DATA data) +{ + if (ctdb->flags & CTDB_FLAG_DAEMON_MODE) { + return ctdb_client_send_message(ctdb, vnn, srvid, data); + } + return ctdb_daemon_send_message(ctdb, vnn, srvid, data); +} + + +/* when a client goes away, we need to remove its srvid handler from the list */ static int message_handler_destructor(struct ctdb_message_list *m) { DLIST_REMOVE(m->ctdb->message_list, m); + return 0; } /* |