@@ -2250,11 +2250,11 @@ static inline bool already_run_today(CephContext* cct, time_t start_date)
22502250 utime_t now = ceph_clock_now ();
22512251 localtime_r (&start_date, &bdt);
22522252
2253- if (cct->_conf ->rgw_lc_debug_interval > 0 ) {
2254- if (now - start_date < cct-> _conf -> rgw_lc_debug_interval )
2255- return true ;
2256- else
2257- return false ;
2253+ if (const auto interval = cct->_conf ->rgw_lc_debug_interval ; interval > 0 ) {
2254+ // compare start_date against the beginning of the current interval
2255+ const auto remainder = now. sec () % interval ;
2256+ const time_t interval_start = now. sec () - remainder;
2257+ return start_date >= interval_start ;
22582258 }
22592259
22602260 bdt.tm_hour = 0 ;
@@ -2609,10 +2609,10 @@ bool RGWLC::going_down()
26092609
26102610bool RGWLC::LCWorker::should_work (utime_t & now)
26112611{
2612- int start_hour;
2613- int start_minute;
2614- int end_hour;
2615- int end_minute;
2612+ int start_hour = 0 ;
2613+ int start_minute = 0 ;
2614+ int end_hour = 23 ;
2615+ int end_minute = 59 ;
26162616 string worktime = cct->_conf ->rgw_lifecycle_work_time ;
26172617 sscanf (worktime.c_str ()," %d:%d-%d:%d" ,&start_hour, &start_minute,
26182618 &end_hour, &end_minute);
@@ -2642,17 +2642,19 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
26422642{
26432643 int secs;
26442644
2645- if (cct->_conf ->rgw_lc_debug_interval > 0 ) {
2646- secs = start + cct->_conf ->rgw_lc_debug_interval - now;
2645+ if (const auto interval = cct->_conf ->rgw_lc_debug_interval ; interval > 0 ) {
2646+ // schedule for the next interval
2647+ const auto remainder = now.sec () % interval;
2648+ secs = interval - remainder;
26472649 if (secs < 0 )
26482650 secs = 0 ;
26492651 return (secs);
26502652 }
26512653
2652- int start_hour;
2653- int start_minute;
2654- int end_hour;
2655- int end_minute;
2654+ int start_hour = 0 ;
2655+ int start_minute = 0 ;
2656+ int end_hour = 23 ;
2657+ int end_minute = 59 ;
26562658 string worktime = cct->_conf ->rgw_lifecycle_work_time ;
26572659 sscanf (worktime.c_str ()," %d:%d-%d:%d" ,&start_hour, &start_minute, &end_hour,
26582660 &end_minute);
0 commit comments