struct shared_table {
struct stktable *table; /* stick table to sync */
struct stksess *ts; /* next sticky session to send (only during a full resync) */
- unsigned int bucket; /* current bucket explored (only during a full resync) */
+ unsigned int init_bucket; /* starting bucket (only during a full resync) */
+ unsigned int bucket; /* current bucket (only during a full resync) */
unsigned int resync_end; /* date to stop resync (session with expiration beyond this date are ignored during resync) */
int local_id;
int remote_id;
new_pushed = 1;
/* This stick-table was already fully sync */
- if (st->bucket >= CONFIG_HAP_TBL_BUCKETS)
+ if (st->ts == NULL && st->bucket == st->init_bucket && tick_isset(st->resync_end))
goto out;
/* Be sure to set the stop point to not resync infinitly */
HA_RWLOCK_RDUNLOCK(STK_TABLE_LOCK, &st->table->buckets[st->bucket].sh_lock);
st->bucket++;
if (st->bucket >= CONFIG_HAP_TBL_BUCKETS)
+ st->bucket = 0;
+ if (st->bucket == st->init_bucket)
break;
goto next;
}
for (st = peer->tables; st; st = st->next) {
st->ts = NULL;
st->bucket = 0;
- st->resync_end = TICK_ETERNITY;
+ st->bucket = st->init_bucket = statistical_prng_range(CONFIG_HAP_TBL_BUCKETS - 1);
st->flags = 0;
}
st->last_get = st->last_acked = 0;
st->last_pushed = HA_ATOMIC_LOAD(&st->update);
st->ts = NULL;
- st->bucket = 0;
+ st->bucket = st->init_bucket = statistical_prng_range(CONFIG_HAP_TBL_BUCKETS - 1);
st->resync_end = TICK_ETERNITY;
st->flags = 0;
}