TT#91150 move to a global NG cookie cache

Change-Id: I8aa5275ffb4d53bb959acd6a8329e5a31f099000
pull/1093/head
Richard Fuchs 5 years ago
parent 3f301dd73b
commit 32d43fed4d

@ -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);
}

@ -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);

@ -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;

Loading…
Cancel
Save