Skip to content

Commit

Permalink
MINOR: peers: avoid re-scheduling of pending stick-table's updates st…
Browse files Browse the repository at this point in the history
…ill not pushed.
  • Loading branch information
EmericBr authored and wtarreau committed Jun 16, 2015
1 parent cc10329 commit aaf5860
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions include/types/stick_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ struct stktable {
struct task *sync_task; /* sync task */
unsigned int update;
unsigned int localupdate;
unsigned int commitupdate;/* used to identify the latest local updates
pending for sync */
unsigned int syncing; /* number of sync tasks watching this table now */
union {
struct peers *p; /* sync peers */
Expand Down
6 changes: 4 additions & 2 deletions src/peers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1233,13 +1233,13 @@ static void peer_io_handler(struct appctx *appctx)
if (!eb) {
eb = eb32_first(&st->table->updates);
if (!eb || ((int)(eb->key - st->last_pushed) <= 0)) {
st->last_pushed = st->table->localupdate;
st->table->commitupdate = st->last_pushed = st->table->localupdate;
break;
}
}

if ((int)(eb->key - st->table->localupdate) > 0) {
st->last_pushed = st->table->localupdate;
st->table->commitupdate = st->last_pushed = st->table->localupdate;
break;
}

Expand All @@ -1262,6 +1262,8 @@ static void peer_io_handler(struct appctx *appctx)
goto switchstate;
}
st->last_pushed = ts->upd.key;
if ((int)(st->last_pushed - st->table->commitupdate) > 0)
st->table->commitupdate = st->last_pushed;
/* identifier may not needed in next update message */
new_pushed = 0;

Expand Down
19 changes: 12 additions & 7 deletions src/stick_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,19 @@ struct stksess *stktable_touch(struct stktable *t, struct stksess *ts, int local
task_queue(t->exp_task);
}

/* If sync is enabled and update is local */
if (t->sync_task && local) {
ts->upd.key = ++t->update;
t->localupdate = t->update;
eb32_delete(&ts->upd);
eb = eb32_insert(&t->updates, &ts->upd);
if (eb != &ts->upd) {
eb32_delete(eb);
eb32_insert(&t->updates, &ts->upd);
/* If this entry was already pushed to a peer
We want to push it again */
if ((int)(ts->upd.key - t->commitupdate) <= 0) {
ts->upd.key = ++t->update;
t->localupdate = t->update;
eb32_delete(&ts->upd);
eb = eb32_insert(&t->updates, &ts->upd);
if (eb != &ts->upd) {
eb32_delete(eb);
eb32_insert(&t->updates, &ts->upd);
}
}
task_wakeup(t->sync_task, TASK_WOKEN_MSG);
}
Expand Down

0 comments on commit aaf5860

Please sign in to comment.