diff --git a/src/peers.c b/src/peers.c index b3a14e6a7..6f88c1925 100644 --- a/src/peers.c +++ b/src/peers.c @@ -886,6 +886,7 @@ switchstate: curpeer->confirm++; } else if (msg_head[1] == PEER_MSG_CTRL_RESYNCCONFIRM) { + struct shared_table *st; /* If stopping state */ if (stopping) { @@ -894,6 +895,10 @@ switchstate: appctx->st0 = PEER_SESS_ST_END; goto switchstate; } + for (st = curpeer->tables; st; st = st->next) { + st->update = st->last_pushed = st->teaching_origin; + st->flags = 0; + } /* reset teaching flags to 0 */ curpeer->flags &= PEER_TEACH_RESET; @@ -1224,25 +1229,6 @@ incomplete: } - /* Confirm finished or partial messages */ - while (curpeer->confirm) { - unsigned char msg[2]; - - /* There is a confirm messages to send */ - msg[0] = PEER_MSG_CLASS_CONTROL; - msg[1] = PEER_MSG_CTRL_RESYNCCONFIRM; - - /* message to buffer */ - repl = bi_putblk(si_ic(si), (char *)msg, sizeof(msg)); - if (repl <= 0) { - /* no more write possible */ - if (repl == -1) - goto full; - appctx->st0 = PEER_SESS_ST_END; - goto switchstate; - } - curpeer->confirm--; - } /* Need to request a resync */ @@ -1491,7 +1477,6 @@ incomplete: /* push local updates */ if (!eb || eb->key > st->teaching_origin) { st->flags |= SHTABLE_F_TEACH_STAGE2; - st->last_pushed = st->teaching_origin; break; } @@ -1548,6 +1533,26 @@ incomplete: curpeer->flags |= PEER_F_TEACH_FINISHED; } + /* Confirm finished or partial messages */ + while (curpeer->confirm) { + unsigned char msg[2]; + + /* There is a confirm messages to send */ + msg[0] = PEER_MSG_CLASS_CONTROL; + msg[1] = PEER_MSG_CTRL_RESYNCCONFIRM; + + /* message to buffer */ + repl = bi_putblk(si_ic(si), (char *)msg, sizeof(msg)); + if (repl <= 0) { + /* no more write possible */ + if (repl == -1) + goto full; + appctx->st0 = PEER_SESS_ST_END; + goto switchstate; + } + curpeer->confirm--; + } + /* noting more to do */ goto out; }