From 89fa6ac5f9a782d3caecd5fc0ad5d802b483db78 Mon Sep 17 00:00:00 2001 From: enukane Date: Thu, 21 May 2015 17:48:18 +0900 Subject: [PATCH 1/2] fix fd leak in out_fluentd cb_flush_buf handler should close new socket opened by itself Signed-off-by: enukane --- plugins/out_fluentd/out_fluentd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/out_fluentd/out_fluentd.c b/plugins/out_fluentd/out_fluentd.c index 064cd8eee75..862f9aa2169 100644 --- a/plugins/out_fluentd/out_fluentd.c +++ b/plugins/out_fluentd/out_fluentd.c @@ -65,7 +65,7 @@ int cb_fluentd_pre_run(void *out_context, struct flb_config *config) int cb_fluentd_flush(void *data, size_t bytes, void *out_context) { - int fd; + int fd, len; struct flb_out_fluentd_config *ctx = out_context; (void) ctx; @@ -76,7 +76,10 @@ int cb_fluentd_flush(void *data, size_t bytes, void *out_context) } /* FIXME: plain TCP write */ - return write(fd, data, bytes); + len = write(ctx->fd, data, bytes); + close(fd); + + return len; } /* Plugin reference */ From f42b624668b1c675fd2c7c876dad94122078fb67 Mon Sep 17 00:00:00 2001 From: enukane Date: Thu, 21 May 2015 18:10:53 +0900 Subject: [PATCH 2/2] don't use ctx (for now) Signed-off-by: enukane --- plugins/out_fluentd/out_fluentd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/out_fluentd/out_fluentd.c b/plugins/out_fluentd/out_fluentd.c index 862f9aa2169..9d04b7324b8 100644 --- a/plugins/out_fluentd/out_fluentd.c +++ b/plugins/out_fluentd/out_fluentd.c @@ -76,7 +76,7 @@ int cb_fluentd_flush(void *data, size_t bytes, void *out_context) } /* FIXME: plain TCP write */ - len = write(ctx->fd, data, bytes); + len = write(fd, data, bytes); close(fd); return len;