@cryptotaxi247 / netdata-1 / commits / cdf7e7316

Fix crash on agent initialization (#18746)

Check for delayed aclk_synd cfg creation

Stelios Fragkakis committed Oct 10, 2024 at 13:49 UTC cdf7e7316a78f2de4b73ac80645310cc5919d3e7
1 file changed +19 -16
src/database/sqlite/sqlite_aclk.c
+19 -16
@@ -434,27 +434,30 @@ static void aclk_synchronization(void *arg)
434 case ACLK_DATABASE_NODE_STATE:;
435 RRDHOST *host = cmd.param[0];
436 struct aclk_sync_cfg_t *ahc = host->aclk_config;
437 - if (unlikely(!ahc))
437 + if (unlikely(!ahc)) {
438 create_aclk_config(host, &host->host_id.uuid, &host->node_id.uuid);
439 + ahc = host->aclk_config;
440 + }
441
440 - uint64_t schedule_time = (uint64_t)(uintptr_t)cmd.param[1];
441 -
442 - if (!ahc->timer_initialized) {
443 - int rc = uv_timer_init(loop, &ahc->timer);
444 - if (!rc) {
445 - ahc->timer_initialized = true;
446 - ahc->timer.data = ahc;
442 + if (ahc) {
443 + uint64_t schedule_time = (uint64_t)(uintptr_t)cmd.param[1];
444 + if (!ahc->timer_initialized) {
445 + int rc = uv_timer_init(loop, &ahc->timer);
446 + if (!rc) {
447 + ahc->timer_initialized = true;
448 + ahc->timer.data = ahc;
449 + }
450 }
448 - }
451
450 - if (ahc->timer_initialized) {
451 - if (uv_is_active((uv_handle_t *)&ahc->timer))
452 - uv_timer_stop(&ahc->timer);
452 + if (ahc->timer_initialized) {
453 + if (uv_is_active((uv_handle_t *)&ahc->timer))
454 + uv_timer_stop(&ahc->timer);
455
454 - ahc->timer.data = ahc;
455 - int rc = uv_timer_start(&ahc->timer, node_update_timer_cb, schedule_time, 0);
456 - if (!rc)
457 - break; // Timer started, exit
456 + ahc->timer.data = ahc;
457 + int rc = uv_timer_start(&ahc->timer, node_update_timer_cb, schedule_time, 0);
458 + if (!rc)
459 + break; // Timer started, exit
460 + }
461 }
462
463 // This is fallback if timer fails