From: Emeric Brun Date: Mon, 15 Jun 2015 15:23:30 +0000 (+0200) Subject: MINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed. X-Git-Tag: v1.6-dev2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaf5860fd634bb625ffd96095da143f711bc602b;p=thirdparty%2Fhaproxy.git MINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed. --- diff --git a/include/types/stick_table.h b/include/types/stick_table.h index 0867d86a74..373ded4dd0 100644 --- a/include/types/stick_table.h +++ b/include/types/stick_table.h @@ -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 */ diff --git a/src/peers.c b/src/peers.c index 3174929227..d05d653469 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1233,13 +1233,13 @@ incomplete: 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 @@ incomplete: 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; diff --git a/src/stick_table.c b/src/stick_table.c index b68772c081..7c1e857a8b 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -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); }