diff --git a/src/stick_table.c b/src/stick_table.c index 31eeff528..7f788f8f7 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -207,6 +207,25 @@ void stksess_setkey(struct stktable *t, struct stksess *ts, struct stktable_key } } +/* + * Get the key in the sticky session present in table + * It cannot fail as it is assumed that if exists, then the key has + * been set. + * It uses static_table_key to store the key + */ +struct stktable_key *stksess_getkey(struct stktable *t, struct stksess *ts) +{ + if (t->type != SMP_T_STR) { + static_table_key.key = ts->key.key; + static_table_key.key_len = t->key_size; + } + else { + static_table_key.key = ts->key.key; + static_table_key.key_len = strnlen2((char *)ts->key.key, t->key_size); + } + return &static_table_key; +} + /* return a shard number for key of len present in table . This * takes into account the presence or absence of a peers section with shards * and the number of shards, the table's hash_seed, and of course the key. The