From 8ed5fc35ba897e97a8dc5b8f34b292fe4e9869cf Mon Sep 17 00:00:00 2001 From: Bingyin Zhang Date: Tue, 19 Dec 2017 18:40:22 +0800 Subject: [PATCH] rgw: optimize next start time for lifecycle * If the scheduling time of lifecycle is after the current time, the * processing of lifecycle should not be postponed for a day Signed-off-by: Bingyin Zhang --- src/rgw/rgw_lc.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 6e03c42a57c7c..9297e8afdd476 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -783,8 +783,10 @@ bool RGWLC::LCWorker::should_work(utime_t& now) int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now) { + int secs; + if (cct->_conf->rgw_lc_debug_interval > 0) { - int secs = start + cct->_conf->rgw_lc_debug_interval - now; + secs = start + cct->_conf->rgw_lc_debug_interval - now; if (secs < 0) secs = 0; return (secs); @@ -804,8 +806,9 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now) bdt.tm_min = start_minute; bdt.tm_sec = 0; nt = mktime(&bdt); + secs = nt - tt; - return (nt+24*60*60 - tt); + return secs>0 ? secs : secs+24*60*60; } void RGWLifecycleConfiguration::generate_test_instances(list& o) -- 2.39.5