From bd7abe64096271038e4e9949ec806eb86220a126 Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Tue, 12 Apr 2016 12:52:14 +0200 Subject: [PATCH] Fix memory leak for notifications feature Add log_info_clear() to cancel out log_info_call() from call_get*(). --- daemon/cli.c | 8 +++++--- daemon/redis.c | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/daemon/cli.c b/daemon/cli.c index 60ae0140a..74e559528 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -11,6 +11,7 @@ #include "poller.h" #include "aux.h" #include "log.h" +#include "log_funcs.h" #include "call.h" #include "cli.h" #include "socket.h" @@ -49,11 +50,11 @@ static void destroy_own_foreign_calls(struct callmaster *m, unsigned int foreign continue; } - // save call reference - g_queue_push_tail(&call_list, obj_get(c)); - // increase ref counter obj_get(c); + + // save call reference + g_queue_push_tail(&call_list, c); } // unlock read @@ -889,6 +890,7 @@ next: cleanup: close(nfd); mutex_unlock(&cli->lock); + log_info_clear(); } static void control_closed(int fd, void *p, uintptr_t u) { diff --git a/daemon/redis.c b/daemon/redis.c index 5f2a075f7..6b40dbbbf 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -13,6 +13,7 @@ #include "aux.h" #include "call.h" #include "log.h" +#include "log_funcs.h" #include "str.h" #include "crypto.h" #include "dtls.h" @@ -20,7 +21,6 @@ #include "hiredis/async.h" #include "hiredis/adapters/libevent.h" #include "event2/thread.h" -#include "log_funcs.h" @@ -343,6 +343,7 @@ err: if (c) { // because of call_get(..) obj_put(c); + log_info_clear(); } mutex_unlock(&r->lock);