MEDIUM: stick-tables: Add srvkey option to stick-table
This allows using the address of the server rather than the name of the
server for keeping track of servers in a backend for stickiness.
The peers code was also extended to support feeding the dictionary using
this key instead of the name.
Fixes #814
diff --git a/src/peers.c b/src/peers.c
index b5c1d42..3fa1a28 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1633,13 +1633,16 @@
chunk->area[chunk->data] = '\0';
*msg_cur += value_len;
- de = dict_insert(&server_name_dict, chunk->area);
+ de = dict_insert(&server_key_dict, chunk->area);
+ dict_entry_unref(&server_key_dict, dc->rx[id - 1].de);
dc->rx[id - 1].de = de;
}
if (de) {
data_ptr = stktable_data_ptr(st->table, ts, data_type);
- if (data_ptr)
+ if (data_ptr) {
+ HA_ATOMIC_ADD(&de->refcount, 1);
stktable_data_cast(data_ptr, std_t_dict) = de;
+ }
}
break;
}
@@ -3059,6 +3062,8 @@
for (i = 0; i < dc->max_entries; i++) {
ebpt_delete(&dc->tx->entries[i]);
dc->tx->entries[i].key = NULL;
+ dict_entry_unref(&server_key_dict, dc->rx[i].de);
+ dc->rx[i].de = NULL;
}
dc->tx->prev_lookup = NULL;
dc->tx->lru_key = 0;