merge from tridge
[martins/samba.git] / ctdb / common / ctdb.c
index 4b47a6e2a1d7d78ace344466f06e6eed515c2e5a..6ae32f5a0fb7df749d039848c331eccb6db47ef5 100644 (file)
@@ -105,6 +105,7 @@ static int ctdb_add_node(struct ctdb_context *ctdb, char *nstr)
 
        if (ctdb_same_address(&ctdb->address, &node->address)) {
                ctdb->vnn = node->vnn;
+               node->flags |= NODE_FLAGS_CONNECTED;
        }
 
        ctdb->num_nodes++;
@@ -252,6 +253,18 @@ void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t length)
                                hdr->generation));
                        break;
                }
+               /* if we are in recovery mode we discard all traffic
+                  until the cluster has recovered.
+               */
+               if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
+                       DEBUG(0,(__location__ " ctdb request %d of type"
+                               " %d length %d from node %d to %d"
+                               " while we are in recovery mode\n", 
+                               hdr->reqid, hdr->operation, hdr->length, 
+                                hdr->srcnode, hdr->destnode));
+                       break;
+               }
+
                ctdb->status.count.req_call++;
                ctdb_request_call(ctdb, hdr);
                break;
@@ -266,11 +279,6 @@ void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t length)
                ctdb_reply_error(ctdb, hdr);
                break;
 
-       case CTDB_REPLY_REDIRECT:
-               ctdb->status.count.reply_redirect++;
-               ctdb_reply_redirect(ctdb, hdr);
-               break;
-
        case CTDB_REQ_DMASTER:
                ctdb->status.count.req_dmaster++;
                ctdb_request_dmaster(ctdb, hdr);
@@ -326,6 +334,7 @@ void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length)
 static void ctdb_node_dead(struct ctdb_node *node)
 {
        node->ctdb->num_connected--;
+       node->flags &= ~NODE_FLAGS_CONNECTED;
        DEBUG(1,("%s: node %s is dead: %d connected\n", 
                 node->ctdb->name, node->name, node->ctdb->num_connected));
 }
@@ -336,6 +345,7 @@ static void ctdb_node_dead(struct ctdb_node *node)
 static void ctdb_node_connected(struct ctdb_node *node)
 {
        node->ctdb->num_connected++;
+       node->flags |= NODE_FLAGS_CONNECTED;
        DEBUG(1,("%s: connected to %s - %d connected\n", 
                 node->ctdb->name, node->name, node->ctdb->num_connected));
 }
@@ -443,6 +453,7 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
 
        ctdb = talloc_zero(ev, struct ctdb_context);
        ctdb->ev = ev;
+       ctdb->recovery_mode = CTDB_RECOVERY_NORMAL;
        ctdb->upcalls = &ctdb_upcalls;
        ctdb->idr = idr_init(ctdb);
        ctdb->max_lacount = CTDB_DEFAULT_MAX_LACOUNT;