Skip to content
Snippets Groups Projects
Commit 450b978d authored by Serge Petrenko's avatar Serge Petrenko Committed by Serge Petrenko
Browse files

replication: move connect_state calculations out from trigger

The idea is to simplify applier_on_connect_f as much as possible, so
that it only wakes the waiter up, but doesn't participate in any
decisions regarding the replicaset connection state.

In-scope-of #8509

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
parent 3aa441f8
No related branches found
No related tags found
No related merge requests found
......@@ -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;
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment