[MEDIUM] stick_table: move the server ID to a generic data type
The server ID is now stored just as any other data type. It is only
allocated if needed and is manipulated just like the other ones.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 26c8ba7..d472f99 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -4899,6 +4899,7 @@
else {
free((void *)mrule->table.name);
mrule->table.t = &(target->table);
+ stktable_alloc_data_type(&target->table, STKTABLE_DT_SERVER_ID);
}
}
@@ -4931,6 +4932,7 @@
else {
free((void *)mrule->table.name);
mrule->table.t = &(target->table);
+ stktable_alloc_data_type(&target->table, STKTABLE_DT_SERVER_ID);
}
}
diff --git a/src/session.c b/src/session.c
index 873201c..2ae6f90 100644
--- a/src/session.c
+++ b/src/session.c
@@ -945,9 +945,11 @@
if ((ts = stktable_lookup_key(rule->table.t, key)) != NULL) {
if (!(s->flags & SN_ASSIGNED)) {
struct eb32_node *node;
+ void *ptr;
/* srv found in table */
- node = eb32_lookup(&px->conf.used_server_id, ts->sid);
+ ptr = stktable_data_ptr(rule->table.t, ts, STKTABLE_DT_SERVER_ID);
+ node = eb32_lookup(&px->conf.used_server_id, stktable_data_cast(ptr, server_id));
if (node) {
struct server *srv;
@@ -1050,6 +1052,7 @@
/* process store request and store response */
for (i = 0; i < s->store_count; i++) {
struct stksess *ts;
+ void *ptr;
ts = stktable_lookup(s->store[i].table, s->store[i].ts);
if (ts) {
@@ -1060,7 +1063,8 @@
ts = stktable_store(s->store[i].table, s->store[i].ts);
s->store[i].ts = NULL;
- ts->sid = s->srv->puid;
+ ptr = stktable_data_ptr(s->store[i].table, ts, STKTABLE_DT_SERVER_ID);
+ stktable_data_cast(ptr, server_id) = s->srv->puid;
}
rep->analysers &= ~an_bit;
diff --git a/src/stick_table.c b/src/stick_table.c
index 994fbeb..017362f 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -64,7 +64,6 @@
static struct stksess *stksess_init(struct stktable *t, struct stksess * ts)
{
memset((void *)ts - t->data_size, 0, t->data_size);
- ts->sid = 0;
ts->key.node.leaf_p = NULL;
ts->exp.node.leaf_p = NULL;
return ts;
@@ -476,6 +475,7 @@
/* Extra data types processing */
struct stktable_data_type stktable_data_types[STKTABLE_DATA_TYPES] = {
[STKTABLE_DT_CONN_CUM] = { .name = "conn_cum", .data_length = stktable_data_size(conn_cum) },
+ [STKTABLE_DT_SERVER_ID] = { .name = "server_id", .data_length = stktable_data_size(server_id) },
};
/*