]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: avoid re-scheduling of pending stick-table's updates still not pushed.
authorEmeric Brun <ebrun@haproxy.com>
Mon, 15 Jun 2015 15:23:30 +0000 (17:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Jun 2015 14:11:12 +0000 (16:11 +0200)
include/types/stick_table.h
src/peers.c
src/stick_table.c

index 0867d86a74a7f880aacf9aa652547cf5f03a9a01..373ded4dd0831ae00b10a3dfdd0f60c0eb18b3ea 100644 (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 */
index 3174929227769e6c8dcaa94b719660a057c50929..d05d653469a0c7e3aa01cdf9b01cffa550143bec 100644 (file)
@@ -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;
 
index b68772c081ae7d40c5c01091dc0758630d6dba6b..7c1e857a8b1dfa7c5e782eeac03d8239377852a1 100644 (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);
        }