recoverd: Make the SRVID request structure generic
authorMartin Schwenke <martin@meltin.net>
Fri, 16 Aug 2013 10:10:10 +0000 (20:10 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 19 Sep 2013 02:54:30 +0000 (12:54 +1000)
No need for a separate one for each SRVID.

Signed-off-by: Martin Schwenke <martin@meltin.net>
include/ctdb_private.h
server/ctdb_monitor.c
server/ctdb_recoverd.c
tools/ctdb.c

index 987502ef008d8d3732a19987dcb3797a703e3e6a..d300d8965512d7d8a86dfd0023fbbfaf64798066 100644 (file)
 #include <sys/socket.h>
 
 /*
 recovery daemon memdump reply address
* Structure to support SRVID requests and replies
  */
-struct rd_memdump_reply {
-       uint32_t pnn;
-       uint64_t srvid;
-};
-
-/*
-  description for a TAKEOVER_RUN message reply address
- */
-struct takeover_run_reply {
+struct srvid_request {
        uint32_t pnn;
        uint64_t srvid;
+       uint32_t data;
 };
 
 /*
index c23477d164122fec4f378edc253198eda773146c..acd68c834daf5751eec5040292286ac88e6f33bd 100644 (file)
@@ -113,7 +113,7 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
        uint32_t next_interval;
        int ret;
        TDB_DATA rddata;
-       struct takeover_run_reply rd;
+       struct srvid_request rd;
        const char *state_str = NULL;
 
        c.pnn = ctdb->pnn;
index 2d01e050ab8147d1c84c87d59c884e5bd5fb349e..ef80defa8917c59ba94bd9fb6f9215331d7a7dc7 100644 (file)
@@ -40,7 +40,7 @@ struct reloadips_all_reply *reload_all_ips_request = NULL;
 */
 struct ip_reallocate_list {
        struct ip_reallocate_list *next;
-       struct rd_memdump_reply *rd;
+       struct srvid_request *rd;
 };
 
 struct ctdb_banning_state {
@@ -2162,14 +2162,14 @@ static void mem_dump_handler(struct ctdb_context *ctdb, uint64_t srvid,
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        TDB_DATA *dump;
        int ret;
-       struct rd_memdump_reply *rd;
+       struct srvid_request *rd;
 
-       if (data.dsize != sizeof(struct rd_memdump_reply)) {
+       if (data.dsize != sizeof(struct srvid_request)) {
                DEBUG(DEBUG_ERR, (__location__ " Wrong size of return address.\n"));
                talloc_free(tmp_ctx);
                return;
        }
-       rd = (struct rd_memdump_reply *)data.dptr;
+       rd = (struct srvid_request *)data.dptr;
 
        dump = talloc_zero(tmp_ctx, TDB_DATA);
        if (dump == NULL) {
@@ -2441,9 +2441,9 @@ reload_all_ips(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, struct ctdb
 
 
 /*
-  handler for ip reallocate, just add it to the list of callers and 
+  handler for ip reallocate, just add it to the list of requests and 
   handle this later in the monitor_cluster loop so we do not recurse
-  with other callers to takeover_run()
+  with other requests to takeover_run()
 */
 static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid, 
                             TDB_DATA data, void *private_data)
@@ -2451,7 +2451,7 @@ static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid,
        struct ctdb_recoverd *rec = talloc_get_type(private_data, struct ctdb_recoverd);
        struct ip_reallocate_list *caller;
 
-       if (data.dsize != sizeof(struct rd_memdump_reply)) {
+       if (data.dsize != sizeof(struct srvid_request)) {
                DEBUG(DEBUG_ERR, (__location__ " Wrong size of return address.\n"));
                return;
        }
@@ -2464,7 +2464,7 @@ static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid,
        caller = talloc(rec->ip_reallocate_ctx, struct ip_reallocate_list);
        CTDB_NO_MEMORY_FATAL(ctdb, caller);
 
-       caller->rd   = (struct rd_memdump_reply *)talloc_steal(caller, data.dptr);
+       caller->rd   = (struct srvid_request *)talloc_steal(caller, data.dptr);
        caller->next = rec->reallocate_callers;
        rec->reallocate_callers = caller;
 
@@ -3112,7 +3112,7 @@ static int verify_local_ip_allocation(struct ctdb_context *ctdb, struct ctdb_rec
        }
 
        if (need_takeover_run) {
-               struct takeover_run_reply rd;
+               struct srvid_request rd;
                TDB_DATA data;
 
                DEBUG(DEBUG_CRIT,("Trigger takeoverrun\n"));
index 6ca340770fbb19aa9345cd7960a1e6961ba567f8..db4b1d31f23801c03cc4419845b720b5c3908331 100644 (file)
@@ -2005,7 +2005,7 @@ static int ipreallocate(struct ctdb_context *ctdb)
 {
        int ret;
        TDB_DATA data;
-       struct takeover_run_reply rd;
+       struct srvid_request rd;
        struct timeval tv;
 
        /* Time ticks to enable timeouts to be processed */
@@ -2015,6 +2015,7 @@ static int ipreallocate(struct ctdb_context *ctdb)
 
        rd.pnn = ctdb_get_pnn(ctdb);
        rd.srvid = getpid();
+       rd.data = 0;
 
        /* Register message port for reply from recovery master */
        ctdb_client_set_message_handler(ctdb, rd.srvid, ip_reallocate_handler, NULL);
@@ -5713,7 +5714,7 @@ static int control_rddumpmemory(struct ctdb_context *ctdb, int argc, const char
 {
        int ret;
        TDB_DATA data;
-       struct rd_memdump_reply rd;
+       struct srvid_request rd;
 
        rd.pnn = ctdb_get_pnn(ctdb);
        rd.srvid = getpid();