int stktable_compatible_sample(struct sample_expr *expr, unsigned long table_type);
int stktable_get_data_type(char *name);
struct proxy *find_stktable(const char *name);
+int stktable_trash_oldest(struct stktable *t, int to_batch);
/* return allocation size for standard data type <type> */
static inline int stktable_type_size(int type)
struct task *sync_task; /* sync task */
unsigned int update;
unsigned int localupdate;
+ unsigned int syncing; /* number of sync tasks watching this table now */
union {
struct peers *p; /* sync peers */
char *name;
/* add DO NOT STOP flag if not present */
jobs++;
st->flags |= SHTABLE_F_DONOTSTOP;
+ st->table->syncing++;
}
/* disconnect all connected peers */
/* resync of new process was complete, current process can die now */
jobs--;
st->flags &= ~SHTABLE_F_DONOTSTOP;
+ st->table->syncing--;
}
}
else if (!ps->session) {
/* unable to resync new process, current process can die now */
jobs--;
st->flags &= ~SHTABLE_F_DONOTSTOP;
+ st->table->syncing--;
}
}
}
}
}
+ /* If the proxy holds a stick table, we need to purge all unused
+ * entries. These are all the ones in the table with ref_cnt == 0
+ * and all the ones in the pool used to allocate new entries. Any
+ * entry attached to an existing session waiting for a store will
+ * be in neither list. Any entry being dumped will have ref_cnt > 0.
+ * However we protect tables that are being synced to peers.
+ */
+ if (unlikely(stopping && p->state == PR_STSTOPPED && p->table.current)) {
+ if (!p->table.syncing) {
+ stktable_trash_oldest(&p->table, p->table.current);
+ pool_gc2();
+ }
+ if (p->table.current) {
+ /* some entries still remain, let's recheck in one second */
+ next = tick_first(next, tick_add(now_ms, 1000));
+ }
+ }
+
/* the rest below is just for frontends */
if (!(p->cap & PR_CAP_FE))
goto out;
* Trash oldest <to_batch> sticky sessions from table <t>
* Returns number of trashed sticky sessions.
*/
-static int stktable_trash_oldest(struct stktable *t, int to_batch)
+int stktable_trash_oldest(struct stktable *t, int to_batch)
{
struct stksess *ts;
struct eb32_node *eb;