From 7a5254ae69c946ba6e9c3b1b1efdf1c6c083fe64 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 4 Feb 2010 09:45:32 +1100 Subject: [PATCH] add two new debug controls to send and receive messages ctdb msglisten and msgsend (This used to be ctdb commit 8c89aac20260dc7f3746e29fe99f17422a77cb88) --- ctdb/tools/ctdb.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 00bef821858..9d6547c55c8 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -4118,6 +4118,69 @@ static int control_rddumpmemory(struct ctdb_context *ctdb, int argc, const char return 0; } +/* + send a message to a srvid + */ +static int control_msgsend(struct ctdb_context *ctdb, int argc, const char **argv) +{ + unsigned long srvid; + int ret; + TDB_DATA data; + + if (argc < 2) { + usage(); + } + + srvid = strtoul(argv[0], NULL, 0); + + data.dptr = (uint8_t *)discard_const(argv[1]); + data.dsize= strlen(argv[1]); + + ret = ctdb_send_message(ctdb, CTDB_BROADCAST_CONNECTED, srvid, data); + if (ret != 0) { + DEBUG(DEBUG_ERR,("Failed to send memdump request message to %u\n", options.pnn)); + return -1; + } + + return 0; +} + +/* + handler for msglisten +*/ +static void msglisten_handler(struct ctdb_context *ctdb, uint64_t srvid, + TDB_DATA data, void *private_data) +{ + int i; + + printf("Message received: "); + for (i=0;iev); + } + + return 0; +} + /* list all nodes in the cluster if the daemon is running, we read the data from the daemon. @@ -4316,6 +4379,8 @@ static const struct { { "setrecmasterrole", control_setrecmasterrole, false, false, "Set RECMASTER role to on/off", "{on|off}"}, { "setdbprio", control_setdbprio, false, false, "Set DB priority", " "}, { "getdbprio", control_getdbprio, false, false, "Get DB priority", ""}, + { "msglisten", control_msglisten, false, false, "Listen on a srvid port for messages", ""}, + { "msgsend", control_msgsend, false, false, "Send a message to srvid", " "}, }; /*