logwritter: still free the unconsumed item during reloading configuration

Otherwise we have no chance to free this stuff.

Upstream-Status: Pending

Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
---
--- a/lib/logwriter.c
+++ b/lib/logwriter.c
@@ -39,6 +39,7 @@
 #include <iv.h>
 #include <iv_event.h>
 #include <iv_work.h>
+#include "logproto/logproto-text-client.h"
 
 typedef enum
 {
@@ -978,6 +979,7 @@
   gint count = 0;
   gboolean ignore_throttle = (flush_mode >= LW_FLUSH_QUEUE);
   LogProtoStatus status = LPS_SUCCESS;
+  LogProtoTextClient *self_text;
   
   if (!proto)
     return FALSE;
@@ -1035,7 +1037,18 @@
         }
       else
         {
-          /* push back to the queue */
-          log_queue_push_head(self->queue, lm, &path_options);
+          self_text = (LogProtoTextClient *) proto;
+          /* free the unconsumed message during reloading configuration */ 
+          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();
