diff --git a/include/fluent-bit/flb_log.h b/include/fluent-bit/flb_log.h index 45f60d1e098..48e8ff74966 100644 --- a/include/fluent-bit/flb_log.h +++ b/include/fluent-bit/flb_log.h @@ -225,6 +225,7 @@ static inline int flb_log_suppress_check(int log_suppress_interval, const char * #endif int flb_log_worker_init(struct flb_worker *worker); +int flb_log_worker_destroy(struct flb_worker *worker); int flb_errno_print(int errnum, const char *file, int line); #ifdef __FLB_FILENAME__ diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index f56f4d6b15c..9aaf9a221bc 100644 --- a/plugins/in_calyptia_fleet/in_calyptia_fleet.c +++ b/plugins/in_calyptia_fleet/in_calyptia_fleet.c @@ -496,6 +496,9 @@ static void *do_reload(void *data) /* avoid reloading the current configuration... just use our new one! */ flb_context_set(reload->flb); reload->flb->config->enable_hot_reload = FLB_TRUE; + if (reload->flb->config->conf_path_file) { + flb_sds_destroy(reload->flb->config->conf_path_file); + } reload->flb->config->conf_path_file = reload->cfg_path; flb_free(reload); diff --git a/src/flb_config.c b/src/flb_config.c index 94612cd42bb..54249fa8d33 100644 --- a/src/flb_config.c +++ b/src/flb_config.c @@ -417,8 +417,7 @@ void flb_config_exit(struct flb_config *config) /* Pipe */ if (config->ch_data[0]) { - mk_event_closesocket(config->ch_data[0]); - mk_event_closesocket(config->ch_data[1]); + flb_pipe_destroy(config->ch_data); } /* Channel manager */ diff --git a/src/flb_engine.c b/src/flb_engine.c index 48338367f78..5ec76d788e0 100644 --- a/src/flb_engine.c +++ b/src/flb_engine.c @@ -726,9 +726,9 @@ int flb_engine_start(struct flb_config *config) * to the local event loop 'evl'. */ ret = mk_event_channel_create(config->evl, - &config->ch_self_events[0], - &config->ch_self_events[1], - &config->event_thread_init); + &config->ch_self_events[0], + &config->ch_self_events[1], + &config->event_thread_init); if (ret == -1) { flb_error("[engine] could not create engine thread channel"); return -1; @@ -1135,6 +1135,12 @@ int flb_engine_shutdown(struct flb_config *config) flb_hs_destroy(config->http_ctx); } #endif + if (config->evl) { + mk_event_channel_destroy(config->evl, + config->ch_self_events[0], + config->ch_self_events[1], + &config->event_thread_init); + } return 0; } diff --git a/src/flb_log.c b/src/flb_log.c index 9ef027aca0f..f9c7bfbc15d 100644 --- a/src/flb_log.c +++ b/src/flb_log.c @@ -303,6 +303,12 @@ int flb_log_cache_check_suppress(struct flb_log_cache *cache, char *msg_buf, siz return FLB_TRUE; } +int flb_log_worker_destroy(struct flb_worker *worker) +{ + flb_pipe_destroy(worker->log); + return 0; +} + int flb_log_worker_init(struct flb_worker *worker) { int ret; @@ -321,16 +327,14 @@ int flb_log_worker_init(struct flb_worker *worker) ret = mk_event_add(log->evl, worker->log[0], FLB_LOG_EVENT, MK_EVENT_READ, &worker->event); if (ret == -1) { - close(worker->log[0]); - close(worker->log[1]); + flb_pipe_destroy(worker->log); return -1; } /* Log cache to reduce noise */ cache = flb_log_cache_create(10, FLB_LOG_CACHE_ENTRIES); if (!cache) { - close(worker->log[0]); - close(worker->log[1]); + flb_pipe_destroy(worker->log); return -1; } worker->log_cache = cache; @@ -688,7 +692,9 @@ int flb_log_destroy(struct flb_log *log, struct flb_config *config) flb_pipe_destroy(log->ch_mng); if (log->worker->log_cache) { flb_log_cache_destroy(log->worker->log_cache); + log->worker->log_cache = NULL; } + flb_log_worker_destroy(log->worker); flb_free(log->worker); flb_free(log); diff --git a/src/flb_output_thread.c b/src/flb_output_thread.c index 62cc5a04716..5fca6be4bf3 100644 --- a/src/flb_output_thread.c +++ b/src/flb_output_thread.c @@ -344,6 +344,10 @@ static void output_thread(void *data) } } + mk_event_channel_destroy(th_ins->evl, + th_ins->ch_thread_events[0], + th_ins->ch_thread_events[1], + &event_local); /* * Final cleanup, destroy all resources associated with: * @@ -363,6 +367,12 @@ static void output_thread(void *data) if (params) { flb_free(params); } + + mk_event_channel_destroy(th_ins->evl, + th_ins->ch_parent_events[0], + th_ins->ch_parent_events[1], + th_ins); + mk_event_loop_destroy(th_ins->evl); flb_bucket_queue_destroy(th_ins->evl_bktq); diff --git a/src/flb_scheduler.c b/src/flb_scheduler.c index 7e42550e5c3..01725eb03e8 100644 --- a/src/flb_scheduler.c +++ b/src/flb_scheduler.c @@ -603,6 +603,7 @@ int flb_sched_destroy(struct flb_sched *sched) /* Delete timers */ mk_list_foreach_safe(head, tmp, &sched->timers) { timer = mk_list_entry(head, struct flb_sched_timer, _head); + mk_event_timeout_destroy(sched->evl, &timer->event); flb_sched_timer_destroy(timer); c++; } diff --git a/src/flb_worker.c b/src/flb_worker.c index 067689596a1..87bc006433d 100644 --- a/src/flb_worker.c +++ b/src/flb_worker.c @@ -144,7 +144,9 @@ void flb_worker_destroy(struct flb_worker *worker) if (worker->log_cache) { flb_log_cache_destroy(worker->log_cache); + worker->log_cache = NULL; } + flb_log_worker_destroy(worker); mk_list_del(&worker->_head); flb_free(worker);