diff --git a/src/box/replication.cc b/src/box/replication.cc index c99151c7e9bf4e341c2d490785b7d8f7d0fd8318..0005eb661a7d8f69e8cad85049b6f8f72f1f7bde 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -898,15 +898,9 @@ applier_on_connect_f(struct trigger *trigger, void *event) struct replicaset_connect_state *state = on_connect->state; struct applier *applier = (struct applier *)event; - switch (applier->state) { - case APPLIER_OFF: - case APPLIER_STOPPED: - state->failed++; - break; - case APPLIER_CONNECTED: - state->connected++; - break; - default: + if (applier->state != APPLIER_OFF && + applier->state != APPLIER_STOPPED && + applier->state != APPLIER_CONNECTED) { return 0; } fiber_cond_signal(&state->wakeup); @@ -961,6 +955,18 @@ replicaset_is_connected(struct replicaset_connect_state *state, return true; } } + /* Update connected and failed counters. */ + state->connected = 0; + state->failed = 0; + for (int i = 0; i < count; i++) { + struct applier *applier = appliers[i]; + if (applier->state == APPLIER_CONNECTED) { + state->connected++; + } else if (applier->state == APPLIER_STOPPED || + applier->state == APPLIER_OFF) { + state->failed++; + } + } if (state->connected == count) return true; /*