MINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed.

This commit is contained in:
Emeric Brun 2015-06-15 17:23:30 +02:00 committed by Willy Tarreau
parent cc103299c7
commit aaf5860fd6
3 changed files with 18 additions and 9 deletions

View File

@ -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 */

View File

@ -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;
}
@ -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;

View File

@ -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);
}