]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Timer: return false if event not added
authorKefu Chai <kchai@redhat.com>
Mon, 10 Jul 2017 07:31:16 +0000 (15:31 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 10 Jul 2017 07:31:16 +0000 (15:31 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/Timer.cc
src/common/Timer.h

index 82e090148f3bc8bc8c0b0da3b5900688501ae4a5..f211a6f8ff8c2171f4921f326ac451e5c82cc283 100644 (file)
@@ -114,22 +114,23 @@ void SafeTimer::timer_thread()
   lock.Unlock();
 }
 
-void SafeTimer::add_event_after(double seconds, Context *callback)
+bool SafeTimer::add_event_after(double seconds, Context *callback)
 {
   assert(lock.is_locked());
 
   utime_t when = ceph_clock_now();
   when += seconds;
-  add_event_at(when, callback);
+  return add_event_at(when, callback);
 }
 
-void SafeTimer::add_event_at(utime_t when, Context *callback)
+bool SafeTimer::add_event_at(utime_t when, Context *callback)
 {
   assert(lock.is_locked());
   ldout(cct,10) << __func__ << " " << when << " -> " << callback << dendl;
   if (stopping) {
     ldout(cct,5) << __func__ << " already shutdown, event not added" << dendl;
     delete callback;
+    return false;
   }
   scheduled_map_t::value_type s_val(when, callback);
   scheduled_map_t::iterator i = schedule.insert(s_val);
@@ -144,7 +145,7 @@ void SafeTimer::add_event_at(utime_t when, Context *callback)
    * adjust our timeout. */
   if (i == schedule.begin())
     cond.Signal();
-
+  return true;
 }
 
 bool SafeTimer::cancel_event(Context *callback)
index 078a172b25b187e4b4747f9625e3f84d55ff06f4..861b239ca32e12637f7fa8b1bfc1aa472ce23416 100644 (file)
@@ -70,8 +70,8 @@ public:
 
   /* Schedule an event in the future
    * Call with the event_lock LOCKED */
-  void add_event_after(double seconds, Context *callback);
-  void add_event_at(utime_t when, Context *callback);
+  bool add_event_after(double seconds, Context *callback);
+  bool add_event_at(utime_t when, Context *callback);
 
   /* Cancel an event.
    * Call with the event_lock LOCKED