[PATCH] afsocket: Properly release our queue at deinit

Gergely Nagy algernon at balabit.hu
Fri Mar 30 16:00:17 CEST 2012


At deinit time, release the destination driver's queue
explicitly. This allows us to re-add the implicit queue unref to
log_dest_driver_release_queue().

This fixes the memory leak seen with, for example, file destinations.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/driver.h                |    1 +
 modules/afsocket/afsocket.c |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/driver.h b/lib/driver.h
index 7f7acbd..c805da5 100644
--- a/lib/driver.h
+++ b/lib/driver.h
@@ -188,6 +188,7 @@ log_dest_driver_release_queue(LogDestDriver *self, LogQueue *q)
   if (q)
     {
       self->queues = g_list_remove(self->queues, q);
+      log_queue_unref(q);
 
       self->release_queue(self, q, self->release_queue_data);
     }
diff --git a/modules/afsocket/afsocket.c b/modules/afsocket/afsocket.c
index ae9c5c2..4e9002f 100644
--- a/modules/afsocket/afsocket.c
+++ b/modules/afsocket/afsocket.c
@@ -1217,6 +1217,9 @@ afsocket_dd_deinit(LogPipe *s)
   if (self->writer)
     log_pipe_deinit(self->writer);
 
+  log_dest_driver_release_queue(&self->super, log_writer_get_queue(self->writer));
+  log_writer_set_queue(self->writer, NULL);
+
   if (self->flags & AFSOCKET_KEEP_ALIVE)
     {
       cfg_persist_config_add(cfg, afsocket_dd_format_persist_name(self, FALSE), self->writer, (GDestroyNotify) log_pipe_unref, FALSE);
-- 
1.7.9


--=-=-=--



More information about the syslog-ng mailing list