Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 365020c5c0823c91a8011e34597f970a7cfb4fb3 Mon Sep 17 00:00:00 2001 |
| 2 | From: Tusa Viktor <tusavik@gmail.com> |
| 3 | Date: Wed, 23 Apr 2014 17:10:58 +0000 |
| 4 | Subject: [PATCH] logwriter: still free the unconsumed item during reloading |
| 5 | configuration |
| 6 | |
| 7 | Upstream-Status: Backport |
| 8 | |
| 9 | Otherwise we have no chance to free this stuff. |
| 10 | |
| 11 | Reported-by: Xufeng Zhang <xufeng.zhang@windriver.com> |
| 12 | Signed-off-by: Tusa Viktor <tusavik@gmail.com> |
| 13 | Signed-off-by: Gergely Nagy <algernon@madhouse-project.org> |
| 14 | --- |
| 15 | lib/logproto/logproto-client.h | 2 +- |
| 16 | lib/logproto/logproto-text-client.c | 11 +++++++++++ |
| 17 | lib/logwriter.c | 9 +++++++-- |
| 18 | 3 files changed, 19 insertions(+), 3 deletions(-) |
| 19 | |
| 20 | diff --git a/lib/logproto/logproto-client.h b/lib/logproto/logproto-client.h |
| 21 | index 254ecf9..5adc917 100644 |
| 22 | --- a/lib/logproto/logproto-client.h |
| 23 | +++ b/lib/logproto/logproto-client.h |
| 24 | @@ -47,7 +47,6 @@ void log_proto_client_options_defaults(LogProtoClientOptions *options); |
| 25 | void log_proto_client_options_init(LogProtoClientOptions *options, GlobalConfig *cfg); |
| 26 | void log_proto_client_options_destroy(LogProtoClientOptions *options); |
| 27 | |
| 28 | - |
| 29 | struct _LogProtoClient |
| 30 | { |
| 31 | LogProtoStatus status; |
| 32 | @@ -107,6 +106,7 @@ log_proto_client_reset_error(LogProtoClient *s) |
| 33 | gboolean log_proto_client_validate_options(LogProtoClient *self); |
| 34 | void log_proto_client_init(LogProtoClient *s, LogTransport *transport, const LogProtoClientOptions *options); |
| 35 | void log_proto_client_free(LogProtoClient *s); |
| 36 | +void log_proto_client_free_method(LogProtoClient *s); |
| 37 | |
| 38 | #define DEFINE_LOG_PROTO_CLIENT(prefix) \ |
| 39 | static gpointer \ |
| 40 | diff --git a/lib/logproto/logproto-text-client.c b/lib/logproto/logproto-text-client.c |
| 41 | index 3248759..a5100f3 100644 |
| 42 | --- a/lib/logproto/logproto-text-client.c |
| 43 | +++ b/lib/logproto/logproto-text-client.c |
| 44 | @@ -146,12 +146,23 @@ log_proto_text_client_post(LogProtoClient *s, guchar *msg, gsize msg_len, gboole |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | +log_proto_text_client_free(LogProtoClient *s) |
| 49 | +{ |
| 50 | + LogProtoTextClient *self = (LogProtoTextClient *)s; |
| 51 | + if (self->partial_free) |
| 52 | + self->partial_free(self->partial); |
| 53 | + self->partial = NULL; |
| 54 | + log_proto_client_free_method(s); |
| 55 | +}; |
| 56 | + |
| 57 | +void |
| 58 | log_proto_text_client_init(LogProtoTextClient *self, LogTransport *transport, const LogProtoClientOptions *options) |
| 59 | { |
| 60 | log_proto_client_init(&self->super, transport, options); |
| 61 | self->super.prepare = log_proto_text_client_prepare; |
| 62 | self->super.flush = log_proto_text_client_flush; |
| 63 | self->super.post = log_proto_text_client_post; |
| 64 | + self->super.free_fn = log_proto_text_client_free; |
| 65 | self->super.transport = transport; |
| 66 | self->next_state = -1; |
| 67 | } |
| 68 | diff --git a/lib/logwriter.c b/lib/logwriter.c |
| 69 | index 3292e31..470bcdb 100644 |
| 70 | --- a/lib/logwriter.c |
| 71 | +++ b/lib/logwriter.c |
| 72 | @@ -1063,8 +1063,13 @@ log_writer_flush(LogWriter *self, LogWriterFlushMode flush_mode) |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | - /* push back to the queue */ |
| 77 | - log_queue_push_head(self->queue, lm, &path_options); |
| 78 | + if (flush_mode == LW_FLUSH_QUEUE) |
| 79 | + log_msg_unref(lm); |
| 80 | + else |
| 81 | + { |
| 82 | + /* push back to the queue */ |
| 83 | + log_queue_push_head(self->queue, lm, &path_options); |
| 84 | + } |
| 85 | msg_set_context(NULL); |
| 86 | log_msg_refcache_stop(); |
| 87 | break; |
| 88 | -- |
| 89 | 1.7.10.4 |
| 90 | |