@cryptotaxi247 / netdata-1 / commits / 239c340c6

Check for host timer validity in ACLK synchronization (#20031)

Add null checks and timer cleanup in aclk configuration

Stelios Fragkakis committed Apr 2, 2025 at 17:35 UTC 239c340c6da6646e390205e471c8e2c594430441
1 file changed +11 -1
src/database/sqlite/sqlite_aclk.c
+11 -1
@@ -519,6 +519,9 @@ static void do_unregister_node(uv_work_t *req)
519 static void node_update_timer_cb(uv_timer_t *handle)
520 {
521 struct aclk_sync_cfg_t *ahc = handle->data;
522 + if (unlikely(!ahc))
523 + return;
524 +
525 RRDHOST *host = ahc->host;
526
527 if(!host || aclk_host_state_update_auto(host))
@@ -950,9 +953,16 @@ void create_aclk_config(RRDHOST *host __maybe_unused, nd_uuid_t *host_uuid __may
953
954 void destroy_aclk_config(RRDHOST *host)
955 {
953 - if (!host || !host->aclk_config)
956 + struct aclk_sync_cfg_t *ahc;
957 + if (!host || !(ahc = host->aclk_config))
958 return;
959
960 + if (ahc->timer_initialized) {
961 + if (uv_is_active((uv_handle_t *)&ahc->timer))
962 + uv_timer_stop(&ahc->timer);
963 + uv_close((uv_handle_t *)&ahc->timer, NULL);
964 + }
965 +
966 freez(host->aclk_config);
967 host->aclk_config = NULL;
968 }