Otherwise we have no chance to free this stuff. Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com> --- lib/logwriter.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/logwriter.c b/lib/logwriter.c index 3292e31..c4d0fdf 100644 --- a/lib/logwriter.c +++ b/lib/logwriter.c @@ -33,6 +33,7 @@ #include "mainloop-call.h" #include "ml-batched-timer.h" #include "str-format.h" +#include "logproto-text-client.h" #include <unistd.h> #include <assert.h> @@ -1006,6 +1007,7 @@ log_writer_flush(LogWriter *self, LogWriterFlushMode flush_mode) gint count = 0; gboolean ignore_throttle = (flush_mode >= LW_FLUSH_QUEUE); LogProtoStatus status = LPS_SUCCESS; + LogProtoTextClient *self_text; if (!proto) return FALSE; @@ -1063,8 +1065,19 @@ log_writer_flush(LogWriter *self, LogWriterFlushMode flush_mode) } else { - /* push back to the queue */ - log_queue_push_head(self->queue, lm, &path_options); + self_text = (LogProtoTextClient *) proto; + /* free the unconsumed message during configuration reloading */ + if ((LW_FLUSH_QUEUE == flush_mode) && self_text->partial_free && self_text->partial) + { + self_text->partial_free(self_text->partial); + self_text->partial = NULL; + log_msg_unref(lm); + } + else + { + /* push back to the queue */ + log_queue_push_head(self->queue, lm, &path_options); + } msg_set_context(NULL); log_msg_refcache_stop(); break; -- 1.7.0.2