]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: optimize next start time for lifecycle 19596/head
authorBingyin Zhang <zhangbingyin@cloudin.cn>
Tue, 19 Dec 2017 10:40:22 +0000 (18:40 +0800)
committerBingyin Zhang <zhangbingyin@cloudin.cn>
Tue, 19 Dec 2017 10:40:22 +0000 (18:40 +0800)
* 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 <zhangbingyin@cloudin.cn>
src/rgw/rgw_lc.cc

index 6e03c42a57c7c84a76260926d68ca62a55455aba..9297e8afdd47633d1f2f294c90c1753aa47f68f3 100644 (file)
@@ -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<RGWLifecycleConfiguration*>& o)