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 0867d86..373ded4 100644
--- a/include/types/stick_table.h
+++ b/include/types/stick_table.h
@@ -154,6 +154,8 @@
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 3174929..d05d653 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1233,13 +1233,13 @@
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 @@
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 b68772c..7c1e857 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -251,14 +251,19 @@
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);
}