]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
- don't try to send controls to dead nodes
authorAndrew Tridgell <tridge@samba.org>
Thu, 17 May 2007 13:23:41 +0000 (23:23 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 17 May 2007 13:23:41 +0000 (23:23 +1000)
- use only connected nodes in a traverse

(This used to be ctdb commit 9a676dd5d331022d946a56c52c42fc6985b93dbc)

ctdb/common/ctdb.c
ctdb/common/ctdb_control.c
ctdb/common/ctdb_recoverd.c
ctdb/common/ctdb_traverse.c
ctdb/include/ctdb.h
ctdb/include/ctdb_private.h

index 9fd967d8e627c00c90a7aa08fef85dd4b62c218c..15b2f06109d10359018be0dbb56081399153d235 100644 (file)
@@ -217,6 +217,21 @@ uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb)
        return ctdb->num_nodes;
 }
 
+/*
+  return the number of connected nodes
+*/
+uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb)
+{
+       int i;
+       uint32_t count=0;
+       for (i=0;i<ctdb->vnn_map->size;i++) {
+               if (ctdb->nodes[i]->flags & NODE_FLAGS_CONNECTED) {
+                       count++;
+               }
+       }
+       return count;
+}
+
 
 /*
   called by the transport layer when a packet comes in
index bc57a94b3c5fd7e9963e2c6df0b91c25ecbde22f..3c3a6d17d36493eb023ba4e3767abeb8aa5e2477 100644 (file)
@@ -395,6 +395,15 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
                return -1;
        }
 
+       if (destnode != CTDB_BROADCAST_VNNMAP && destnode != CTDB_BROADCAST_VNNMAP && 
+           (!ctdb_validate_vnn(ctdb, destnode) || 
+            !(ctdb->nodes[destnode]->flags & NODE_FLAGS_CONNECTED))) {
+               if (!(flags & CTDB_CTRL_FLAG_NOREPLY)) {
+                       callback(ctdb, -1, tdb_null, "ctdb_control to disconnected node", private_data);
+               }
+               return 0;
+       }
+
        /* the state is made a child of private_data if possible. This means any reply
           will be discarded if the private_data goes away */
        state = talloc(private_data?private_data:ctdb, struct ctdb_control_state);
index 9b5d04eb98fd91131cf5f11fa546a2417446c6c1..c813e69f168dc63948fc84c73612d46d66a17cb3 100644 (file)
@@ -447,6 +447,8 @@ static int do_recovery(struct ctdb_context *ctdb,
                return -1;
        }
 
+       /* send a message to all clients telling them that the cluster has been reconfigured */
+       ctdb_send_message(ctdb, CTDB_BROADCAST_ALL, CTDB_SRVID_RECONFIGURE, tdb_null);
 
        DEBUG(0, (__location__ " Recovery complete\n"));
        return 0;
@@ -465,7 +467,6 @@ static int send_election_request(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
        uint64_t srvid;
        
        srvid = CTDB_SRVTYPE_RECOVERY;
-       srvid <<= 32;
 
        emsg.vnn = vnn;
 
@@ -857,7 +858,6 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 
        /* register a message port for recovery elections */
        srvid = CTDB_SRVTYPE_RECOVERY;
-       srvid <<= 32;
        ctdb_set_message_handler(ctdb, srvid, election_handler, NULL);
 
        monitor_cluster(ctdb);
index 00c3c1b66e073ea48f6f24427e7aa87aeee3d9ea..53504215a4dabd4af0296e2492b601dc1fc480ba 100644 (file)
@@ -365,7 +365,7 @@ int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB
 
        if (key.dsize == 0 && data.dsize == 0) {
                state->null_count++;
-               if (state->null_count != ctdb_get_num_nodes(ctdb)) {
+               if (state->null_count != ctdb_get_num_connected_nodes(ctdb)) {
                        return 0;
                }
        }
index 782fda9f3360861a0d72572a5caa8f1f3366122f..a330f709a51564b4e0765152fbc32b2c46297566 100644 (file)
@@ -56,10 +56,16 @@ struct ctdb_call_info {
    a message handler ID meaning "give me all messages"
  */
 #define CTDB_SRVID_ALL (~(uint64_t)0)
+
 /*
   srvid type : RECOVERY
 */
-#define CTDB_SRVTYPE_RECOVERY  0x64766372
+#define CTDB_SRVTYPE_RECOVERY  0xF100000000000000LL
+
+/* 
+   a message handler ID meaning that the cluster has been reconfigured
+ */
+#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
 
 struct event_context;
 
index b0cd59d823faf630da98be87469770f519df2480..3188c51a6070f04f6a56ecdff962abbf0e1fc94d 100644 (file)
@@ -802,4 +802,6 @@ int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
 
 int ctdb_start_recoverd(struct ctdb_context *ctdb);
 
+uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb);
+
 #endif