int stktable_init(struct stktable *t);
int stktable_parse_type(char **args, int *idx, unsigned long *type, size_t *key_size);
struct stksess *stktable_store(struct stktable *t, struct stksess *ts);
+struct stksess *stktable_touch(struct stktable *t, struct stksess *ts);
struct stksess *stktable_lookup(struct stktable *t, struct stksess *ts);
struct stksess *stktable_lookup_key(struct stktable *t, struct stktable_key *key);
struct stktable_key *stktable_fetch_key(struct proxy *px, struct session *l4,
return 0;
stktable_store(&px->table, ts);
}
- else if (px->table.expire) {
- /* if entries can expire, let's update the entry and the table */
- ts->expire = tick_add(now_ms, MS_TO_TICKS(px->table.expire));
- px->table.exp_task->expire = px->table.exp_next = tick_first(ts->expire, px->table.exp_next);
- task_queue(px->table.exp_task);
- }
+ else
+ stktable_touch(&px->table, ts);
ptr = stktable_data_ptr(&px->table, ts, STKTABLE_DT_CONN_CUM);
if (!ptr)
ts = stktable_lookup(s->store[i].table, s->store[i].ts);
if (ts) {
/* the entry already existed, we can free ours */
+ stktable_touch(s->store[i].table, s->store[i].ts);
stksess_free(s->store[i].table, s->store[i].ts);
}
else
return ebmb_entry(eb, struct stksess, key);
}
+/* Update the expiration timer for <ts> but do not touch its expiration node.
+ * The table's expiration timer is updated if set.
+ */
+struct stksess *stktable_touch(struct stktable *t, struct stksess *ts)
+{
+ ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
+ if (t->expire) {
+ t->exp_task->expire = t->exp_next = tick_first(ts->expire, t->exp_next);
+ task_queue(t->exp_task);
+ }
+ return ts;
+}
+
/* Insert new sticky session <ts> in the table. It is assumed that it does not
* yet exist (the caller must check this). The table's timeout is updated if it
* is set. <ts> is returned.
struct stksess *stktable_store(struct stktable *t, struct stksess *ts)
{
ebmb_insert(&t->keys, &ts->key, t->key_size);
-
- ts->exp.key = ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
+ stktable_touch(t, ts);
+ ts->exp.key = ts->expire;
eb32_insert(&t->exps, &ts->exp);
-
- if (t->expire) {
- t->exp_task->expire = t->exp_next = tick_first(ts->expire, t->exp_next);
- task_queue(t->exp_task);
- }
return ts;
}