#define PEERS_F_RESYNC_LOCAL_FINISHED 0x00000001 /* Learn from local peer finished or no more needed */
#define PEERS_F_RESYNC_REMOTE_FINISHED 0x00000002 /* Learn from remote peer finished or no more needed */
#define PEERS_F_RESYNC_ASSIGN 0x00000004 /* A peer was assigned to learn our lesson */
-#define PEERS_F_DONOTSTOP 0x00000008 /* Main table sync task block process during soft stop to push data to new process */
-/* unsued 0x00000010..0x00080000 */
+/* unsued 0x00000008..0x00080000 */
#define PEERS_F_DBG_RESYNC_LOCALTIMEOUT 0x00100000 /* Timeout waiting for a full resync from a local node was experienced at lest once (for debugging purpose) */
#define PEERS_F_DBG_RESYNC_REMOTETIMEOUT 0x00200000 /* Timeout waiting for a full resync from a remote node was experienced at lest once (for debugging purpose) */
#define PEERS_F_DBG_RESYNC_LOCALABORT 0x00400000 /* Session aborted learning from a local node was experienced at lest once (for debugging purpose) */
/* prologue */
_(0);
/* flags */
- _(PEERS_F_RESYNC_LOCAL_FINISHED, _(PEERS_F_RESYNC_REMOTE_FINISHED, _(PEERS_F_RESYNC_ASSIGN, _(PEERS_F_DONOTSTOP,
+ _(PEERS_F_RESYNC_LOCAL_FINISHED, _(PEERS_F_RESYNC_REMOTE_FINISHED, _(PEERS_F_RESYNC_ASSIGN,
_(PEERS_F_DBG_RESYNC_LOCALTIMEOUT, _(PEERS_F_DBG_RESYNC_REMOTETIMEOUT,
_(PEERS_F_DBG_RESYNC_LOCALABORT, _(PEERS_F_DBG_RESYNC_REMOTEABORT,
_(PEERS_F_DBG_RESYNC_LOCALFINISHED, _(PEERS_F_DBG_RESYNC_REMOTEFINISHED,
_(PEERS_F_DBG_RESYNC_LOCALPARTIAL, _(PEERS_F_DBG_RESYNC_REMOTEPARTIAL,
- _(PEERS_F_DBG_RESYNC_LOCALASSIGN, _(PEERS_F_DBG_RESYNC_REMOTEABORT))))))))))))));
+ _(PEERS_F_DBG_RESYNC_LOCALASSIGN, _(PEERS_F_DBG_RESYNC_REMOTEABORT)))))))))))));
/* epilogue */
_(~0U);
return buf;
{
struct peer *ps;
struct shared_table *st;
-
+ static int dont_stop = 0;
/* For each peer */
for (ps = peers->remote; ps; ps = ps->next) {
*/
ps->flags &= ~PEER_F_WAIT_SYNCTASK_ACK;
- if ((state & TASK_WOKEN_SIGNAL) && !(peers->flags & PEERS_F_DONOTSTOP)) {
+ if ((state & TASK_WOKEN_SIGNAL) && !dont_stop) {
/* we're killing a connection, we must apply a random delay before
* retrying otherwise the other end will do the same and we can loop
* for a while.
/* We've just received the signal */
if (state & TASK_WOKEN_SIGNAL) {
- if (!(peers->flags & PEERS_F_DONOTSTOP)) {
+ if (!dont_stop) {
/* add DO NOT STOP flag if not present */
_HA_ATOMIC_INC(&jobs);
- peers->flags |= PEERS_F_DONOTSTOP;
+ dont_stop = 1;
/* Set resync timeout for the local peer and request a immediate reconnect */
peers->resync_timeout = tick_add(now_ms, MS_TO_TICKS(PEER_RESYNC_TIMEOUT));
ps = peers->local;
HA_SPIN_LOCK(PEER_LOCK, &ps->lock);
if (ps->flags & PEER_F_LOCAL_TEACH_COMPLETE) {
- if (peers->flags & PEERS_F_DONOTSTOP) {
+ if (dont_stop) {
/* resync of new process was complete, current process can die now */
_HA_ATOMIC_DEC(&jobs);
- peers->flags &= ~PEERS_F_DONOTSTOP;
+ dont_stop = 0;
for (st = ps->tables; st ; st = st->next)
HA_ATOMIC_DEC(&st->table->refcnt);
}
}
else {
/* connect to the local peer if we must push a local sync */
- if (peers->flags & PEERS_F_DONOTSTOP) {
+ if (dont_stop) {
peer_session_create(peers, ps);
}
}
}
else {
/* Other error cases */
- if (peers->flags & PEERS_F_DONOTSTOP) {
+ if (dont_stop) {
/* unable to resync new process, current process can die now */
_HA_ATOMIC_DEC(&jobs);
- peers->flags &= ~PEERS_F_DONOTSTOP;
+ dont_stop = 0;
for (st = ps->tables; st ; st = st->next)
HA_ATOMIC_DEC(&st->table->refcnt);
}