diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 99fba2cce..78433ee2e 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -21,6 +21,7 @@ mutex_t rtpe_cngs_lock; GHashTable *rtpe_cngs_hash; struct control_ng *rtpe_control_ng; +static struct cookie_cache ng_cookie_cache; const char magic_load_limit_strings[__LOAD_LIMIT_MAX][64] = { [LOAD_LIMIT_MAX_SESSIONS] = "Parallel session limit reached", @@ -151,7 +152,7 @@ static void control_ng_incoming(struct obj *obj, str *buf, const endpoint_t *sin if (data.len <= 0) goto err_send; - to_send = cookie_cache_lookup(&c->cookie_cache, &cookie); + to_send = cookie_cache_lookup(&ng_cookie_cache, &cookie); if (to_send) { ilog(LOG_INFO, "Detected command from %s as a duplicate", addr); resp = NULL; @@ -347,7 +348,7 @@ send_only: socket_sendiov(ul, iov, iovlen, sin); if (resp) - cookie_cache_insert(&c->cookie_cache, &cookie, &reply); + cookie_cache_insert(&ng_cookie_cache, &cookie, &reply); else free(to_send); @@ -376,7 +377,6 @@ void control_ng_free(void *p) { poller_del_item(c->poller, c->udp_listeners[1].fd); close_socket(&c->udp_listeners[0]); close_socket(&c->udp_listeners[1]); - cookie_cache_cleanup(&c->cookie_cache); } @@ -388,7 +388,6 @@ struct control_ng *control_ng_new(struct poller *p, endpoint_t *ep, unsigned cha c = obj_alloc0("control_ng", sizeof(*c), control_ng_free); - cookie_cache_init(&c->cookie_cache); c->udp_listeners[0].fd = -1; c->udp_listeners[1].fd = -1; c->poller = p; @@ -415,4 +414,8 @@ fail2: void control_ng_init() { mutex_init(&rtpe_cngs_lock); rtpe_cngs_hash = g_hash_table_new(g_sockaddr_hash, g_sockaddr_eq); + cookie_cache_init(&ng_cookie_cache); +} +void control_ng_cleanup() { + cookie_cache_cleanup(&ng_cookie_cache); } diff --git a/daemon/main.c b/daemon/main.c index c20910ce6..f8db044e8 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1049,6 +1049,7 @@ int main(int argc, char **argv) { interfaces_free(); ice_free(); dtls_cert_free(); + control_ng_cleanup(); redis_close(rtpe_redis); redis_close(rtpe_redis_write); diff --git a/include/control_ng.h b/include/control_ng.h index 73336bc91..ed53b5d8d 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -2,7 +2,6 @@ #define _CONTROL_NG_H_ #include "obj.h" -#include "cookie_cache.h" #include "udp_listener.h" #include "socket.h" @@ -34,13 +33,13 @@ struct control_ng_stats { struct control_ng { struct obj obj; - struct cookie_cache cookie_cache; socket_t udp_listeners[2]; struct poller *poller; }; struct control_ng *control_ng_new(struct poller *, endpoint_t *, unsigned char); void control_ng_init(void); +void control_ng_cleanup(void); extern mutex_t rtpe_cngs_lock; extern GHashTable *rtpe_cngs_hash;