@@ -256,10 +256,7 @@ int flb_engine_start(struct flb_config *config)
256
256
if (event -> type == FLB_ENGINE_EV_CORE ) {
257
257
ret = flb_engine_handle_event (event -> fd , event -> mask , config );
258
258
if (ret == -1 ) {
259
- /* Inputs exit */
260
- flb_input_exit_all (config );
261
- /* Outputs exit */
262
- flb_output_exit (config );
259
+ flb_engine_shutdown (config );
263
260
return 0 ;
264
261
}
265
262
}
@@ -281,3 +278,44 @@ int flb_engine_start(struct flb_config *config)
281
278
}
282
279
}
283
280
}
281
+
282
+ /* Release all resources associated to the engine */
283
+ int flb_engine_shutdown (struct flb_config * config )
284
+ {
285
+ /* cleanup plugins */
286
+ flb_input_exit_all (config );
287
+ flb_output_exit (config );
288
+
289
+ /* release resources */
290
+ if (config -> ch_event .fd ) {
291
+ close (config -> ch_event .fd );
292
+ }
293
+
294
+ /* Pipe */
295
+ if (config -> ch_data [0 ]) {
296
+ close (config -> ch_data [0 ]);
297
+ close (config -> ch_data [1 ]);
298
+ }
299
+
300
+ /* Channel manager */
301
+ if (config -> ch_manager [0 ] > 0 ) {
302
+ close (config -> ch_manager [0 ]);
303
+ if (config -> ch_manager [0 ] != config -> ch_manager [1 ]) {
304
+ close (config -> ch_manager [1 ]);
305
+ }
306
+ }
307
+
308
+ /* Channel notifications */
309
+ if (config -> ch_notif [0 ] > 0 ) {
310
+ close (config -> ch_notif [0 ]);
311
+ if (config -> ch_notif [0 ] != config -> ch_notif [1 ]) {
312
+ close (config -> ch_notif [1 ]);
313
+ }
314
+ }
315
+
316
+ close (config -> flush_fd );
317
+ mk_event_loop_destroy (config -> evl );
318
+ free (config );
319
+
320
+ return 0 ;
321
+ }
0 commit comments