From cf3abdb9e3667609626fb43db3d4089dc32ebea2 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 20 Jun 2026 01:48:50 +0300 Subject: [PATCH] Clear autosync_timer when autosync_interval is set to 0 Clear other timers similarly (but their interval can't be 0) --- src/osd/osd.cpp | 51 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/osd/osd.cpp b/src/osd/osd.cpp index 7471edb5..57d970f2 100644 --- a/src/osd/osd.cpp +++ b/src/osd/osd.cpp @@ -352,29 +352,50 @@ void osd_t::parse_config(bool init) { peering_state = peering_state | OSD_RECOVERING; } - if (old_autosync_interval != autosync_interval && autosync_timer_id >= 0) + if (old_autosync_interval != autosync_interval) { - this->tfd->clear_timer(autosync_timer_id); - autosync_timer_id = this->tfd->set_timer(autosync_interval*1000, true, [this](int timer_id) + if (autosync_timer_id >= 0) { - autosync(); - }); + this->tfd->clear_timer(autosync_timer_id); + autosync_timer_id = -1; + } + if (autosync_interval != 0) + { + autosync_timer_id = this->tfd->set_timer(autosync_interval*1000, true, [this](int timer_id) + { + autosync(); + }); + } } - if (old_print_stats_interval != print_stats_interval && print_stats_timer_id >= 0) + if (old_print_stats_interval != print_stats_interval) { - tfd->clear_timer(print_stats_timer_id); - print_stats_timer_id = this->tfd->set_timer(print_stats_interval*1000, true, [this](int timer_id) + if (print_stats_timer_id >= 0) { - print_stats(); - }); + tfd->clear_timer(print_stats_timer_id); + print_stats_timer_id = -1; + } + if (print_stats_interval != 0) + { + print_stats_timer_id = this->tfd->set_timer(print_stats_interval*1000, true, [this](int timer_id) + { + print_stats(); + }); + } } - if (old_slow_log_interval != slow_log_interval && slow_log_timer_id >= 0) + if (old_slow_log_interval != slow_log_interval) { - tfd->clear_timer(slow_log_timer_id); - slow_log_timer_id = this->tfd->set_timer(slow_log_interval*1000, true, [this](int timer_id) + if (slow_log_timer_id >= 0) { - print_slow(); - }); + tfd->clear_timer(slow_log_timer_id); + slow_log_timer_id = -1; + } + if (slow_log_interval != 0) + { + slow_log_timer_id = this->tfd->set_timer(slow_log_interval*1000, true, [this](int timer_id) + { + print_slow(); + }); + } } if (old_recovery_tune_interval != recovery_tune_interval) {