Skip to content

Commit

Permalink
plugin_proxy: move go specific destructor to proxy/go/go.c
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 committed Jul 29, 2021
1 parent 1a359fd commit 2ca0de5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
15 changes: 2 additions & 13 deletions src/flb_plugin_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 19 additions & 0 deletions src/proxy/go/go.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/proxy/go/go.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2ca0de5

Please sign in to comment.