From 2ca0de548ba53efc373e4600c9bb9b8b6ca45e40 Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Thu, 29 Jul 2021 22:08:02 +0900 Subject: [PATCH] plugin_proxy: move go specific destructor to proxy/go/go.c Signed-off-by: Takahiro Yamashita --- src/flb_plugin_proxy.c | 15 ++------------- src/proxy/go/go.c | 19 +++++++++++++++++++ src/proxy/go/go.h | 2 +- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/flb_plugin_proxy.c b/src/flb_plugin_proxy.c index dc5674b30ad..29c07a248b7 100644 --- a/src/flb_plugin_proxy.c +++ b/src/flb_plugin_proxy.c @@ -70,21 +70,10 @@ static int flb_proxy_cb_exit(void *data, struct flb_config *config) { struct flb_output_plugin *instance = data; struct flb_plugin_proxy *proxy = (instance->proxy); - struct flbgo_output_plugin *plugin; - void *inst; - inst = proxy->data; - - plugin = (struct flbgo_output_plugin *) inst; - flb_debug("[GO] running exit callback"); - - if (plugin->cb_exit_ctx) { - return plugin->cb_exit_ctx(plugin->context->remote_context); - } - else if (plugin->cb_exit) { - return plugin->cb_exit(); + if (proxy->def->proxy == FLB_PROXY_GOLANG) { + proxy_go_destroy(proxy->data); } - return 0; } diff --git a/src/proxy/go/go.c b/src/proxy/go/go.c index c919c26af08..cca008f0572 100644 --- a/src/proxy/go/go.c +++ b/src/proxy/go/go.c @@ -145,3 +145,22 @@ int proxy_go_flush(struct flb_plugin_proxy_context *ctx, flb_free(buf); return ret; } + +int proxy_go_destroy(void *data) +{ + int ret = 0; + struct flbgo_output_plugin *plugin; + + plugin = (struct flbgo_output_plugin *) data; + flb_debug("[GO] running exit callback"); + + if (plugin->cb_exit_ctx) { + ret = plugin->cb_exit_ctx(plugin->context->remote_context); + } + else if (plugin->cb_exit) { + ret = plugin->cb_exit(); + } + flb_free(plugin->name); + flb_free(plugin); + return ret; +} diff --git a/src/proxy/go/go.h b/src/proxy/go/go.h index 71dc413b7ae..864d4402f29 100644 --- a/src/proxy/go/go.h +++ b/src/proxy/go/go.h @@ -45,5 +45,5 @@ int proxy_go_init(struct flb_plugin_proxy *proxy); int proxy_go_flush(struct flb_plugin_proxy_context *ctx, const void *data, size_t size, const char *tag, int tag_len); - +int proxy_go_destroy(void *data); #endif