From: Armin Kuster <akuster808@gmail.com>
To: openembedded-devel@lists.openembedded.org
Cc: otavio@ossystems.com.br
Subject: [PATCH 13/15] syslog-ng: Fix memory leak when udp connection is used [ LIN7-1379 ]
Date: Sun, 30 Nov 2014 17:04:15 -0800 [thread overview]
Message-ID: <94de8bcf6f8558bbd43374e69bb324237f8d8b0d.1417194166.git.akuster808@gmail.com> (raw)
In-Reply-To: <cover.1417194166.git.akuster808@gmail.com>
In-Reply-To: <cover.1417194166.git.akuster808@gmail.com>
From: Xufeng Zhang <xufeng.zhang@windriver.com>
When udp connection is used, there are several memory leaks happen
after run a long time.
Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
Signed-off-by: Roy Li <rongqing.li@windriver.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
.../logwriter-dont-allocate-a-new-buffer.patch | 26 +++++++
.../logwriter-still-free-the-unconsumed-item.patch | 47 -----------
.../rewrite-expr-grammar.ym-Free-up-token.patch | 17 ++++
.../files/still-free-the-unconsumed-item.patch | 90 ++++++++++++++++++++++
.../recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb | 4 +-
5 files changed, 136 insertions(+), 48 deletions(-)
create mode 100644 meta-oe/recipes-support/syslog-ng/files/logwriter-dont-allocate-a-new-buffer.patch
delete mode 100644 meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch
create mode 100644 meta-oe/recipes-support/syslog-ng/files/rewrite-expr-grammar.ym-Free-up-token.patch
create mode 100644 meta-oe/recipes-support/syslog-ng/files/still-free-the-unconsumed-item.patch
diff --git a/meta-oe/recipes-support/syslog-ng/files/logwriter-dont-allocate-a-new-buffer.patch b/meta-oe/recipes-support/syslog-ng/files/logwriter-dont-allocate-a-new-buffer.patch
new file mode 100644
index 0000000..9e3d64b
--- /dev/null
+++ b/meta-oe/recipes-support/syslog-ng/files/logwriter-dont-allocate-a-new-buffer.patch
@@ -0,0 +1,26 @@
+logwriter: Don't allocate a new buffer if fails to consume current item
+
+Upstream-Status: Pending
+
+Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
+---
+--- a/lib/logwriter.c
++++ b/lib/logwriter.c
+@@ -1010,7 +1010,7 @@
+ {
+ status = log_proto_client_post(proto, (guchar *) self->line_buffer->str, self->line_buffer->len, &consumed);
+
+- if (consumed)
++ if (consumed && status != LPS_ERROR)
+ log_writer_realloc_line_buffer(self);
+
+ if (status == LPS_ERROR)
+@@ -1028,7 +1028,7 @@
+ NULL);
+ consumed = TRUE;
+ }
+- if (consumed)
++ if (consumed && status != LPS_ERROR)
+ {
+ if (lm->flags & LF_LOCAL)
+ step_sequence_number(&self->seq_num);
diff --git a/meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch b/meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch
deleted file mode 100644
index 3111093..0000000
--- a/meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-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();
diff --git a/meta-oe/recipes-support/syslog-ng/files/rewrite-expr-grammar.ym-Free-up-token.patch b/meta-oe/recipes-support/syslog-ng/files/rewrite-expr-grammar.ym-Free-up-token.patch
new file mode 100644
index 0000000..1951af9
--- /dev/null
+++ b/meta-oe/recipes-support/syslog-ng/files/rewrite-expr-grammar.ym-Free-up-token.patch
@@ -0,0 +1,17 @@
+rewrite-expr-grammar.ym: Free up token.
+
+Upsteam-Status: Backport
+
+Reported-by: Xufeng Zhang <xufeng.zhang@windriver.com>
+Signed-off-by: Viktor Tusa <tusavik@gmail.com>
+---
+--- a/lib/rewrite/rewrite-expr-grammar.ym
++++ b/lib/rewrite/rewrite-expr-grammar.ym
+@@ -78,6 +78,7 @@
+
+ $$ = log_template_new(configuration, $1);
+ CHECK_ERROR(log_template_compile($$, $1, &error), @1, "Error compiling template (%s)", error->message);
++ free($1);
+ }
+ ;
+
diff --git a/meta-oe/recipes-support/syslog-ng/files/still-free-the-unconsumed-item.patch b/meta-oe/recipes-support/syslog-ng/files/still-free-the-unconsumed-item.patch
new file mode 100644
index 0000000..ea18682
--- /dev/null
+++ b/meta-oe/recipes-support/syslog-ng/files/still-free-the-unconsumed-item.patch
@@ -0,0 +1,90 @@
+From 365020c5c0823c91a8011e34597f970a7cfb4fb3 Mon Sep 17 00:00:00 2001
+From: Tusa Viktor <tusavik@gmail.com>
+Date: Wed, 23 Apr 2014 17:10:58 +0000
+Subject: [PATCH] logwriter: still free the unconsumed item during reloading
+ configuration
+
+Upstream-Status: Backport
+
+Otherwise we have no chance to free this stuff.
+
+Reported-by: Xufeng Zhang <xufeng.zhang@windriver.com>
+Signed-off-by: Tusa Viktor <tusavik@gmail.com>
+Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
+---
+ lib/logproto/logproto-client.h | 2 +-
+ lib/logproto/logproto-text-client.c | 11 +++++++++++
+ lib/logwriter.c | 9 +++++++--
+ 3 files changed, 19 insertions(+), 3 deletions(-)
+
+diff --git a/lib/logproto/logproto-client.h b/lib/logproto/logproto-client.h
+index 254ecf9..5adc917 100644
+--- a/lib/logproto/logproto-client.h
++++ b/lib/logproto/logproto-client.h
+@@ -47,7 +47,6 @@ void log_proto_client_options_defaults(LogProtoClientOptions *options);
+ void log_proto_client_options_init(LogProtoClientOptions *options, GlobalConfig *cfg);
+ void log_proto_client_options_destroy(LogProtoClientOptions *options);
+
+-
+ struct _LogProtoClient
+ {
+ LogProtoStatus status;
+@@ -107,6 +106,7 @@ log_proto_client_reset_error(LogProtoClient *s)
+ gboolean log_proto_client_validate_options(LogProtoClient *self);
+ void log_proto_client_init(LogProtoClient *s, LogTransport *transport, const LogProtoClientOptions *options);
+ void log_proto_client_free(LogProtoClient *s);
++void log_proto_client_free_method(LogProtoClient *s);
+
+ #define DEFINE_LOG_PROTO_CLIENT(prefix) \
+ static gpointer \
+diff --git a/lib/logproto/logproto-text-client.c b/lib/logproto/logproto-text-client.c
+index 3248759..a5100f3 100644
+--- a/lib/logproto/logproto-text-client.c
++++ b/lib/logproto/logproto-text-client.c
+@@ -146,12 +146,23 @@ log_proto_text_client_post(LogProtoClient *s, guchar *msg, gsize msg_len, gboole
+ }
+
+ void
++log_proto_text_client_free(LogProtoClient *s)
++{
++ LogProtoTextClient *self = (LogProtoTextClient *)s;
++ if (self->partial_free)
++ self->partial_free(self->partial);
++ self->partial = NULL;
++ log_proto_client_free_method(s);
++};
++
++void
+ log_proto_text_client_init(LogProtoTextClient *self, LogTransport *transport, const LogProtoClientOptions *options)
+ {
+ log_proto_client_init(&self->super, transport, options);
+ self->super.prepare = log_proto_text_client_prepare;
+ self->super.flush = log_proto_text_client_flush;
+ self->super.post = log_proto_text_client_post;
++ self->super.free_fn = log_proto_text_client_free;
+ self->super.transport = transport;
+ self->next_state = -1;
+ }
+diff --git a/lib/logwriter.c b/lib/logwriter.c
+index 3292e31..470bcdb 100644
+--- a/lib/logwriter.c
++++ b/lib/logwriter.c
+@@ -1063,8 +1063,13 @@ log_writer_flush(LogWriter *self, LogWriterFlushMode flush_mode)
+ }
+ else
+ {
+- /* push back to the queue */
+- log_queue_push_head(self->queue, lm, &path_options);
++ if (flush_mode == LW_FLUSH_QUEUE)
++ 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.10.4
+
diff --git a/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb b/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb
index d5939e4..b548420 100644
--- a/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb
+++ b/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb
@@ -9,10 +9,12 @@ SRC_URI += " \
file://Fix-the-memory-leak-problem-for-mutex.patch \
file://Fix-the-memory-leak-problem-when-HAVE_ENVIRON-defined.patch \
file://free-global-LogTemplateOptions.patch \
- file://logwriter-still-free-the-unconsumed-item.patch \
+ file://still-free-the-unconsumed-item.patch \
file://syslog-ng-verify-the-list-before-del.patch \
file://configure.patch \
file://dbifix.patch \
+ file://rewrite-expr-grammar.ym-Free-up-token.patch \
+ file://logwriter-dont-allocate-a-new-buffer.patch \
"
SRC_URI[md5sum] = "ff3bf223ebafbaa92b69a2d5b729f368"
--
1.9.1
next prev parent reply other threads:[~2014-12-01 1:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-01 1:04 [PATCH 00/15] for Dizzy Armin Kuster
2014-12-01 1:04 ` [PATCH 01/15] phpmyadmin: fix for Security Advisory CVE-2014-5274 Armin Kuster
2014-12-01 10:40 ` Otavio Salvador
2014-12-01 1:04 ` [PATCH 02/15] net-snmp: fix for Security Advisory - CVE-2014-3565 Armin Kuster
2014-12-01 1:04 ` [PATCH 03/15] postgresql: add fix for CVE-2014-0064 Security Advisory Armin Kuster
2014-12-01 1:04 ` [PATCH 04/15] postgresql: add fix for CVE-2014-0060 " Armin Kuster
2014-12-01 1:04 ` [PATCH 05/15] postgresql: add fix for CVE-2014-0061 " Armin Kuster
2014-12-01 1:04 ` [PATCH 06/15] postgresql: add fix for CVE-2014-0062 " Armin Kuster
2014-12-01 1:04 ` [PATCH 07/15] postgresql: add fix for CVE-2014-0063 " Armin Kuster
2014-12-01 1:04 ` [PATCH 08/15] postgresql: add fix for CVE-2014-0067 " Armin Kuster
2014-12-01 1:04 ` [PATCH 09/15] postgresql: add fix for CVE-2014-0065 and CVE-2014-0066 " Armin Kuster
2014-12-01 1:04 ` [PATCH 10/15] libyaml: add fix for CVE-2014-2525 " Armin Kuster
2014-12-01 1:04 ` [PATCH 11/15] xfce4-weather-plugin: make work properly after met.no API change Armin Kuster
2014-12-01 1:04 ` [PATCH 12/15] gvfs: replace deprecated g_memmove by memmove Armin Kuster
2014-12-01 1:04 ` Armin Kuster [this message]
2014-12-01 1:04 ` [PATCH 14/15] wireshark: update to 1.12.2 Armin Kuster
2014-12-01 1:04 ` [PATCH 15/15] krb5: fix CVE-2014-5351 Armin Kuster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=94de8bcf6f8558bbd43374e69bb324237f8d8b0d.1417194166.git.akuster808@gmail.com \
--to=akuster808@gmail.com \
--cc=openembedded-devel@lists.openembedded.org \
--cc=otavio@ossystems.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.