@@ -183,37 +183,85 @@ static void flb_proxy_input_cb_resume(void *data, struct flb_config *config)
183183}
184184
185185static void flb_plugin_proxy_destroy (struct flb_plugin_proxy * proxy );
186- static int flb_proxy_output_cb_exit (void * data , struct flb_config * config )
186+
187+ static int flb_proxy_output_cb_exit (void * out_context , struct flb_config * config )
187188{
188- struct flb_output_plugin * instance = data ;
189- struct flb_plugin_proxy * proxy = (instance -> proxy );
189+ struct flb_plugin_proxy_context * ctx = out_context ;
190+ struct flb_plugin_proxy * proxy = (ctx -> proxy );
191+
192+ if (!out_context ) {
193+ return 0 ;
194+ }
190195
191196 if (proxy -> def -> proxy == FLB_PROXY_GOLANG ) {
192- proxy_go_output_destroy (proxy -> data );
197+ #ifdef FLB_HAVE_PROXY_GO
198+ proxy_go_output_destroy (ctx );
199+ #endif
193200 }
194- flb_plugin_proxy_destroy (proxy );
201+
202+ flb_free (ctx );
195203 return 0 ;
196204}
197205
206+ static void flb_proxy_output_cb_destroy (struct flb_output_plugin * plugin )
207+ {
208+ struct flb_plugin_proxy * proxy = (struct flb_plugin_proxy * ) plugin -> proxy ;
209+ /* cleanup */
210+ void (* cb_unregister )(struct flb_plugin_proxy_def * def );
211+
212+ cb_unregister = flb_plugin_proxy_symbol (proxy , "FLBPluginUnregister" );
213+ if (cb_unregister != NULL ) {
214+ cb_unregister (proxy -> def );
215+ }
216+
217+ if (proxy -> def -> proxy == FLB_PROXY_GOLANG ) {
218+ #ifdef FLB_HAVE_PROXY_GO
219+ proxy_go_output_unregister (proxy -> data );
220+ #endif
221+ }
222+
223+ flb_plugin_proxy_destroy (proxy );
224+ }
225+
198226static int flb_proxy_input_cb_exit (void * in_context , struct flb_config * config )
199227{
200228 struct flb_plugin_input_proxy_context * ctx = in_context ;
229+ struct flb_plugin_proxy * proxy = (ctx -> proxy );
201230
202231 if (!in_context ) {
203232 return 0 ;
204233 }
205234
206- if (ctx -> proxy -> def -> proxy == FLB_PROXY_GOLANG ) {
207- proxy_go_input_destroy (ctx -> proxy -> data );
235+ if (proxy -> def -> proxy == FLB_PROXY_GOLANG ) {
236+ #ifdef FLB_HAVE_PROXY_GO
237+ proxy_go_input_destroy (ctx );
238+ #endif
208239 }
209240
210- flb_plugin_proxy_destroy (ctx -> proxy );
211-
212241 flb_free (ctx );
213-
214242 return 0 ;
215243}
216244
245+ static void flb_proxy_input_cb_destroy (struct flb_input_plugin * plugin )
246+ {
247+ struct flb_plugin_proxy * proxy = (struct flb_plugin_proxy * ) plugin -> proxy ;
248+ /* cleanup */
249+ void (* cb_unregister )(struct flb_plugin_proxy_def * def );
250+
251+ cb_unregister = flb_plugin_proxy_symbol (proxy , "FLBPluginUnregister" );
252+ if (cb_unregister != NULL ) {
253+ cb_unregister (proxy -> def );
254+ }
255+
256+ if (proxy -> def -> proxy == FLB_PROXY_GOLANG ) {
257+ #ifdef FLB_HAVE_PROXY_GO
258+ proxy_go_input_unregister (proxy -> data );
259+ #endif
260+ }
261+
262+ flb_plugin_proxy_destroy (proxy );
263+ }
264+
217265static int flb_proxy_register_output (struct flb_plugin_proxy * proxy ,
218266 struct flb_plugin_proxy_def * def ,
219267 struct flb_config * config )
@@ -241,6 +289,7 @@ static int flb_proxy_register_output(struct flb_plugin_proxy *proxy,
241289 */
242290 out -> cb_flush = proxy_cb_flush ;
243291 out -> cb_exit = flb_proxy_output_cb_exit ;
292+ out -> cb_destroy = flb_proxy_output_cb_destroy ;
244293 return 0 ;
245294}
246295
@@ -273,6 +322,7 @@ static int flb_proxy_register_input(struct flb_plugin_proxy *proxy,
273322 in -> cb_collect = flb_proxy_input_cb_collect ;
274323 in -> cb_flush_buf = NULL ;
275324 in -> cb_exit = flb_proxy_input_cb_exit ;
325+ in -> cb_destroy = flb_proxy_input_cb_destroy ;
276326 in -> cb_pause = flb_proxy_input_cb_pause ;
277327 in -> cb_resume = flb_proxy_input_cb_resume ;
278328 return 0 ;
@@ -427,13 +477,6 @@ struct flb_plugin_proxy *flb_plugin_proxy_create(const char *dso_path, int type,
427477
428478static void flb_plugin_proxy_destroy (struct flb_plugin_proxy * proxy )
429479{
430- /* cleanup */
431- void (* cb_unregister )(struct flb_plugin_proxy_def * def );
432-
433- cb_unregister = flb_plugin_proxy_symbol (proxy , "FLBPluginUnregister" );
434- if (cb_unregister != NULL ) {
435- cb_unregister (proxy -> def );
436- }
437480 flb_free (proxy -> def );
438481 flb_api_destroy (proxy -> api );
439482 dlclose (proxy -> dso_handler );
0 commit comments