mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
CLEANUP: stktable: replace nopurge attribute with flag
Thanks to previous commit stktable struct now have a "flags" struct member Let's take this opportunity to remove the isolated "nopurge" attribute in stktable struct and rely on a flag named STK_FL_NOPURGE instead. This helps to better organize stktable struct members.
This commit is contained in:
parent
1f73d3524d
commit
9f44c5f9be
@ -159,6 +159,7 @@ struct stksess {
|
|||||||
#define STK_FL_RECV_ONLY 0x01 /* table is assumed to be remotely updated only
|
#define STK_FL_RECV_ONLY 0x01 /* table is assumed to be remotely updated only
|
||||||
* (never updated locally)
|
* (never updated locally)
|
||||||
*/
|
*/
|
||||||
|
#define STK_FL_NOPURGE 0x02 /* if non-zero, don't purge sticky sessions when full */
|
||||||
|
|
||||||
/* stick table */
|
/* stick table */
|
||||||
struct stktable {
|
struct stktable {
|
||||||
@ -183,12 +184,13 @@ struct stktable {
|
|||||||
size_t key_size; /* size of a key, maximum size in case of string */
|
size_t key_size; /* size of a key, maximum size in case of string */
|
||||||
unsigned int server_key_type; /* What type of key is used to identify servers */
|
unsigned int server_key_type; /* What type of key is used to identify servers */
|
||||||
unsigned int size; /* maximum number of sticky sessions in table */
|
unsigned int size; /* maximum number of sticky sessions in table */
|
||||||
int nopurge; /* if non-zero, don't purge sticky sessions when full */
|
|
||||||
int expire; /* time to live for sticky sessions (milliseconds) */
|
int expire; /* time to live for sticky sessions (milliseconds) */
|
||||||
int data_size; /* the size of the data that is prepended *before* stksess */
|
int data_size; /* the size of the data that is prepended *before* stksess */
|
||||||
int data_ofs[STKTABLE_DATA_TYPES]; /* negative offsets of present data types, or 0 if absent */
|
int data_ofs[STKTABLE_DATA_TYPES]; /* negative offsets of present data types, or 0 if absent */
|
||||||
unsigned int data_nbelem[STKTABLE_DATA_TYPES]; /* to store nb_elem in case of array types */
|
unsigned int data_nbelem[STKTABLE_DATA_TYPES]; /* to store nb_elem in case of array types */
|
||||||
unsigned int brates_factor; /* Factor used for IN/OUT bytes rates */
|
unsigned int brates_factor; /* Factor used for IN/OUT bytes rates */
|
||||||
|
uint16_t flags;
|
||||||
|
/* 2-bytes hole */
|
||||||
union {
|
union {
|
||||||
int i;
|
int i;
|
||||||
unsigned int u;
|
unsigned int u;
|
||||||
@ -201,8 +203,6 @@ struct stktable {
|
|||||||
void *ptr; /* generic ptr to check if set or not */
|
void *ptr; /* generic ptr to check if set or not */
|
||||||
} write_to; /* updates received on the source table will also update write_to */
|
} write_to; /* updates received on the source table will also update write_to */
|
||||||
|
|
||||||
uint16_t flags;
|
|
||||||
|
|
||||||
THREAD_ALIGN(64);
|
THREAD_ALIGN(64);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -823,7 +823,7 @@ int hlua_stktable_info(lua_State *L)
|
|||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
|
|
||||||
lua_pushstring(L, "nopurge");
|
lua_pushstring(L, "nopurge");
|
||||||
lua_pushboolean(L, tbl->nopurge > 0);
|
lua_pushboolean(L, (tbl->flags & STK_FL_NOPURGE));
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
|
|
||||||
lua_pushstring(L, "expire");
|
lua_pushstring(L, "expire");
|
||||||
|
@ -396,7 +396,8 @@ struct stksess *stksess_new(struct stktable *t, struct stktable_key *key)
|
|||||||
|
|
||||||
if (unlikely(current >= t->size)) {
|
if (unlikely(current >= t->size)) {
|
||||||
/* the table was already full, we may have to purge entries */
|
/* the table was already full, we may have to purge entries */
|
||||||
if (t->nopurge || !stktable_trash_oldest(t, (t->size >> 8) + 1)) {
|
if ((t->flags & STK_FL_NOPURGE) ||
|
||||||
|
!stktable_trash_oldest(t, (t->size >> 8) + 1)) {
|
||||||
HA_ATOMIC_DEC(&t->current);
|
HA_ATOMIC_DEC(&t->current);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1248,7 +1249,7 @@ int parse_stick_table(const char *file, int linenum, char **args,
|
|||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[idx], "nopurge") == 0) {
|
else if (strcmp(args[idx], "nopurge") == 0) {
|
||||||
t->nopurge = 1;
|
t->flags |= STK_FL_NOPURGE;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
else if (strcmp(args[idx], "type") == 0) {
|
else if (strcmp(args[idx], "type") == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user