unsigned int heartbeat; /* next heartbeat timer */
unsigned int confirm; /* confirm message counter */
unsigned int last_hdshk; /* Date of the last handshake. */
+ unsigned int last_update; /* Date of last update sent */
uint32_t rx_hbt; /* received heartbeats counter */
uint32_t tx_hbt; /* transmitted heartbeats counter */
uint32_t no_hbt; /* no received heartbeat counter */
attached to this table */
unsigned int current; /* number of sticky sessions currently in table */
THREAD_ALIGN(64);
-
+ unsigned int last_update; /* Date of the last update inserted in the list */
struct mt_list updates; /* list of sticky updates sequence */
struct mt_list *pend_updts; /* list of updates to be added to the update sequence list, one per thread-group */
struct tasklet *updt_task;/* tasklet responsible for pushing the pending updates into the tree */
p->last.id = st->update_id;
st->update_id++;
p->flags &= ~PEER_F_SYNCHED;
+ p->last_update = now_ms;
/* identifier may not needed in next update message */
new_pushed = 0;
/* Awake session if there is data to push */
for (st = peer->tables; st ; st = st->next) {
- struct stksess *ts;
- struct mt_list back;
-
- // TODO: may be handled via an atomic flags ?
- MT_LIST_FOR_EACH_ENTRY_LOCKED(ts, &st->last->upd, upd, back) {
- if (&ts->upd == &st->table->updates)
- break;
- if (&ts->upd != &st->table->updates && ts->updt_type == STKSESS_UPDT_LOCAL) {
- update_to_push = 1;
- break;
- }
- }
+ if (tick_is_le(peer->last_update, st->table->last_update))
+ update_to_push = 1;
+
if (update_to_push == 1) {
/* wake up the peer handler to push local updates */
/* There is no need to send a heartbeat message
/* current peer connection is active and established
* wake up all peer handlers to push remaining local updates */
for (st = peer->tables; st ; st = st->next) {
- struct stksess *ts;
- struct mt_list back;
- int wakeup = 0;
-
- MT_LIST_FOR_EACH_ENTRY_LOCKED(ts, &st->last->upd, upd, back) {
- if (&ts->upd != &st->table->updates && ts->updt_type == STKSESS_UPDT_LOCAL) {
- wakeup = 1;
- break;
- }
- }
- if (wakeup) {
+ if (tick_is_le(peer->last_update, st->table->last_update)) {
appctx_wakeup(peer->appctx);
break;
}
if (i > 0) {
/* We did at least one update, let's wake the sync task */
+ table->last_update = now_ms;
task_wakeup(table->sync_task, TASK_WOKEN_MSG);
}
return t;
for (i = 0; i < global.nbtgroups; i++)
MT_LIST_INIT(&t->pend_updts[i]);
t->updt_task = tasklet_new();
+ t->last_update = TICK_ETERNITY;
if (!t->updt_task)
goto mem_error;
t->updt_task->context = t;