From 0d2d42c8ac678e505dfd4874b3f463b085457aeb Mon Sep 17 00:00:00 2001 From: Takeshi HASEGAWA Date: Tue, 9 Jun 2015 05:05:24 +0000 Subject: [PATCH] plugins/in_mem: no longer flushes empty buffer plugins/in_kmsg: no longer flushes empty buffer plugins/in_cpu: no longer flushes empty buffer This changes avoid allocating and flushing unnecessary empty buffers (size == 0). These also surpress error messages when no updates in flush interval(typically every 5 seconds). Signed-off-by: Takeshi HASEGAWA --- plugins/in_cpu/in_cpu.c | 3 +++ plugins/in_kmsg/in_kmsg.c | 3 +++ plugins/in_mem/in_mem.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/plugins/in_cpu/in_cpu.c b/plugins/in_cpu/in_cpu.c index 4f446341c77..4b783f27052 100644 --- a/plugins/in_cpu/in_cpu.c +++ b/plugins/in_cpu/in_cpu.c @@ -158,6 +158,9 @@ void *in_cpu_flush(void *in_context, int *size) msgpack_sbuffer *sbuf; struct flb_in_cpu_config *ctx = in_context; + if (ctx->data_idx == 0) + return NULL; + sbuf = &ctx->mp_sbuf; *size = sbuf->size; buf = malloc(sbuf->size); diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c index 152c320f19a..a366067d9ca 100644 --- a/plugins/in_kmsg/in_kmsg.c +++ b/plugins/in_kmsg/in_kmsg.c @@ -107,6 +107,9 @@ void *in_kmsg_flush(void *in_context, int *size) msgpack_sbuffer *sbuf; struct flb_in_kmsg_config *ctx = in_context; + if (ctx->buffer_id == 0) + return NULL; + sbuf = &ctx->mp_sbuf; *size = sbuf->size; buf = malloc(sbuf->size); diff --git a/plugins/in_mem/in_mem.c b/plugins/in_mem/in_mem.c index cc2db0d4f27..72d24eee7c7 100644 --- a/plugins/in_mem/in_mem.c +++ b/plugins/in_mem/in_mem.c @@ -99,6 +99,9 @@ void *in_mem_flush(void *in_context, int *size) char *buf; struct flb_in_mem_config *ctx = in_context; + if (ctx->idx == 0) + return NULL; + buf = malloc(ctx->sbuf.size); if (!buf) { return NULL;