diff --git a/include/haproxy/stick_table-t.h b/include/haproxy/stick_table-t.h index c0665e0bd..cfef4e2c7 100644 --- a/include/haproxy/stick_table-t.h +++ b/include/haproxy/stick_table-t.h @@ -112,6 +112,15 @@ enum { #define STKCTR_TRACK_BACKEND 1 #define STKCTR_TRACK_CONTENT 2 +/* type of the sticky session in the updates tree */ +enum { + STKSESS_UPDT_NONE = 0, /* unset, only if table is not used by the peers */ + STKSESS_UPDT_LOCAL, /* the sticky session is locally updated */ + STKSESS_UPDT_REMOTE, /* the sticky session is remotely updated */ + STKSESS_UPDT_MARKER, /* not a true sticky session, only used a marker*/ +}; + + /* stick_table extra data. This is mainly used for casting or size computation */ union stktable_data { /* standard types for easy casting */ @@ -153,7 +162,7 @@ struct stksess { struct eb32_node exp; /* ebtree node used to hold the session in expiration tree */ struct eb32_node upd; /* ebtree node used to hold the update sequence tree */ struct mt_list pend_updts;/* list of entries to be inserted/moved in the update sequence tree */ - int updt_is_local; /* is the update a local one ? */ + unsigned int updt_type; /* One of STKSESS_UPDT_* value */ struct ebmb_node key; /* ebtree node used to hold the session in table */ /* WARNING! do not put anything after , it's used by the key */ }; diff --git a/src/stick_table.c b/src/stick_table.c index 5532fc679..73ecc5892 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -268,6 +268,7 @@ static struct stksess *__stksess_init(struct stktable *t, struct stksess * ts) ts->key.node.leaf_p = NULL; ts->exp.node.leaf_p = NULL; ts->upd.node.leaf_p = NULL; + ts->updt_type = STKSESS_UPDT_NONE; MT_LIST_INIT(&ts->pend_updts); ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire)); HA_RWLOCK_INIT(&ts->lock); @@ -627,13 +628,13 @@ void stktable_touch_with_exp(struct stktable *t, struct stksess *ts, int local, * scheduled for at least one peer. */ if (!ts->upd.node.leaf_p || _HA_ATOMIC_LOAD(&ts->seen)) { - _HA_ATOMIC_STORE(&ts->updt_is_local, 1); + _HA_ATOMIC_STORE(&ts->updt_type, STKSESS_UPDT_LOCAL); did_append = MT_LIST_TRY_APPEND(&t->pend_updts[tgid - 1], &ts->pend_updts); } } else { if (!ts->upd.node.leaf_p) { - _HA_ATOMIC_STORE(&ts->updt_is_local, 0); + _HA_ATOMIC_STORE(&ts->updt_type, STKSESS_UPDT_REMOTE); did_append = MT_LIST_TRY_APPEND(&t->pend_updts[tgid - 1], &ts->pend_updts); } } @@ -828,7 +829,7 @@ struct task *stktable_add_pend_updates(struct task *t, void *ctx, unsigned int s empty_tgid = 0; if (cur_tgid == global.nbtgroups) cur_tgid = 0; - is_local = stksess->updt_is_local; + is_local = (stksess->updt_type == STKSESS_UPDT_LOCAL); stksess->seen = 0; if (is_local) { stksess->upd.key = ++table->update;