Skip to content

Commit 2e9c39f

Browse files
committed
plugin_proxy: Clean up proxy-ed resources for custom plugins
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 17114c1 commit 2e9c39f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/flb_plugin_proxy.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ static int flb_proxy_register_input(struct flb_plugin_proxy *proxy,
426426
int flb_proxy_custom_cb_init(struct flb_custom_instance *c_ins,
427427
struct flb_config *config, void *data);
428428

429-
static int flb_proxy_custom_cb_exit(void *custom_context,
429+
static int flb_proxy_custom_cb_exit(void *custom_context,
430430
struct flb_config *config);
431+
static void flb_proxy_custom_cb_destroy(struct flb_custom_plugin *plugin);
431432

432433
static int flb_proxy_register_custom(struct flb_plugin_proxy *proxy,
433434
struct flb_plugin_proxy_def *def,
@@ -456,6 +457,7 @@ static int flb_proxy_register_custom(struct flb_plugin_proxy *proxy,
456457
*/
457458
custom->cb_init = flb_proxy_custom_cb_init;
458459
custom->cb_exit = flb_proxy_custom_cb_exit;
460+
custom->cb_destroy = flb_proxy_custom_cb_destroy;
459461
return 0;
460462
}
461463

@@ -707,3 +709,22 @@ int flb_proxy_custom_cb_exit(void *custom_context,
707709
flb_free(ctx);
708710
return ret;
709711
}
712+
713+
static void flb_proxy_custom_cb_destroy(struct flb_custom_plugin *plugin)
714+
{
715+
struct flb_plugin_proxy *proxy = (struct flb_plugin_proxy *) plugin->proxy;
716+
717+
if (plugin->name != NULL) {
718+
flb_free(plugin->name);
719+
720+
plugin->name = NULL;
721+
}
722+
723+
if (proxy->def->proxy == FLB_PROXY_GOLANG) {
724+
#ifdef FLB_HAVE_PROXY_GO
725+
proxy_go_custom_unregister(proxy->data);
726+
#endif
727+
}
728+
729+
flb_plugin_proxy_destroy(proxy);
730+
}

0 commit comments

Comments
 (0)