[MINOR] stick_table: add support for variable-sized data
Right now we're only able to store a server ID in a sticky session.
The goal is to be able to store anything whose size is known at startup
time. For this, we store the extra data before the stksess pointer,
using a negative offset. It will then be easy to cumulate multiple
data provided they each have their own offset.
diff --git a/include/types/stick_table.h b/include/types/stick_table.h
index b63b790..bbb9d0d 100644
--- a/include/types/stick_table.h
+++ b/include/types/stick_table.h
@@ -48,7 +48,11 @@
size_t default_size; /* default key size */
};
-/* sticky session */
+/* Sticky session.
+ * Any additional data related to the stuck session is installed *before*
+ * stksess (with negative offsets). This allows us to run variable-sized
+ * keys and variable-sized data without making use of intermediate pointers.
+ */
struct stksess {
int sid; /* id of server to use for this session */
unsigned int expire; /* session expiration date */
@@ -70,6 +74,7 @@
int nopurge; /* if non-zero, don't purge sticky sessions when full */
int exp_next; /* next expiration date (ticks) */
int expire; /* time to live for sticky sessions (milliseconds) */
+ int data_size; /* the size of the data that is prepended *before* stksess */
};
/*** The definitions below should probably be better placed in pattern.h ***/