mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-05 01:31:03 +01:00
MINOR: stktable: Use an enum to type a sticky session in the updates tree
Instead of using a boolean to know if an entry in the updates tree is local or not, an enum is used. This change will be mandatory when updates tree will be replaced by a list to be able to add markers owned by each peer. So now a sticky sessin has no type (STKSESS_UPDT_NONE) if it is not in the updates tree. STKSESS_UPDT_LOCAL is used for local entries and STKSESS_UPDT_REMOTE for remote ones. STKSESS_UPDT_MARKER is not used for now.
This commit is contained in:
parent
ded62e3ea4
commit
8d85f724fd
@ -112,6 +112,15 @@ enum {
|
|||||||
#define STKCTR_TRACK_BACKEND 1
|
#define STKCTR_TRACK_BACKEND 1
|
||||||
#define STKCTR_TRACK_CONTENT 2
|
#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 */
|
/* stick_table extra data. This is mainly used for casting or size computation */
|
||||||
union stktable_data {
|
union stktable_data {
|
||||||
/* standard types for easy casting */
|
/* 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 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 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 */
|
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 */
|
struct ebmb_node key; /* ebtree node used to hold the session in table */
|
||||||
/* WARNING! do not put anything after <keys>, it's used by the key */
|
/* WARNING! do not put anything after <keys>, it's used by the key */
|
||||||
};
|
};
|
||||||
|
|||||||
@ -268,6 +268,7 @@ static struct stksess *__stksess_init(struct stktable *t, struct stksess * ts)
|
|||||||
ts->key.node.leaf_p = NULL;
|
ts->key.node.leaf_p = NULL;
|
||||||
ts->exp.node.leaf_p = NULL;
|
ts->exp.node.leaf_p = NULL;
|
||||||
ts->upd.node.leaf_p = NULL;
|
ts->upd.node.leaf_p = NULL;
|
||||||
|
ts->updt_type = STKSESS_UPDT_NONE;
|
||||||
MT_LIST_INIT(&ts->pend_updts);
|
MT_LIST_INIT(&ts->pend_updts);
|
||||||
ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
|
ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
|
||||||
HA_RWLOCK_INIT(&ts->lock);
|
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.
|
* scheduled for at least one peer.
|
||||||
*/
|
*/
|
||||||
if (!ts->upd.node.leaf_p || _HA_ATOMIC_LOAD(&ts->seen)) {
|
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);
|
did_append = MT_LIST_TRY_APPEND(&t->pend_updts[tgid - 1], &ts->pend_updts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!ts->upd.node.leaf_p) {
|
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);
|
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;
|
empty_tgid = 0;
|
||||||
if (cur_tgid == global.nbtgroups)
|
if (cur_tgid == global.nbtgroups)
|
||||||
cur_tgid = 0;
|
cur_tgid = 0;
|
||||||
is_local = stksess->updt_is_local;
|
is_local = (stksess->updt_type == STKSESS_UPDT_LOCAL);
|
||||||
stksess->seen = 0;
|
stksess->seen = 0;
|
||||||
if (is_local) {
|
if (is_local) {
|
||||||
stksess->upd.key = ++table->update;
|
stksess->upd.key = ++table->update;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user