]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Timer: add verbose debugging when debug timer = 20
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 3 Nov 2010 22:36:09 +0000 (15:36 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 4 Nov 2010 04:40:24 +0000 (21:40 -0700)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/common/Timer.cc
src/common/Timer.h

index 07f68bc63b43018eca2abb024823d241f92ab5e7..7b7530c3d83a0225dd39669e767d55d06b021363 100644 (file)
@@ -26,6 +26,7 @@
 
 #define DBL 10
 
+#include <sstream>
 #include <signal.h>
 #include <sys/time.h>
 #include <math.h>
@@ -189,6 +190,7 @@ void Timer::add_event_at(utime_t when, Context *callback)
   if (i == scheduled.begin())
     cond.Signal();
 
+  dout(19) << show_all_events(__func__) << dendl;
   lock.Unlock();
 }
 
@@ -206,6 +208,8 @@ void Timer::cancel_all_events(void)
 {
   dout(DBL) << __PRETTY_FUNCTION__ << dendl;
 
+  dout(19) << show_all_events(__func__) << dendl;
+
   lock.Lock();
   cancel_all_events_impl(false);
   lock.Unlock();
@@ -227,6 +231,8 @@ int Timer::init()
 
 bool Timer::cancel_event_impl(Context *callback, bool cancel_running)
 {
+  dout(19) << show_all_events(__func__) << dendl;
+
   event_lookup_map_t::iterator e = events.find(callback);
   if (e != events.end()) {
     // Erase the item out of the scheduled map.
@@ -286,6 +292,33 @@ void Timer::pop_running(list <Context*> &running_, const utime_t &now)
   }
 }
 
+std::string Timer::show_all_events(const char *caller) const
+{
+  ostringstream oss;
+  string sep;
+  oss << "show_all_events: from " << caller << ": scheduled [";
+  for (scheduled_map_t::const_iterator s = scheduled.begin();
+       s != scheduled.end();
+       ++s)
+  {
+    oss << sep << s->first << "->" << s->second;
+    sep = ",";
+  }
+  oss << "] ";
+
+  oss << "events [";
+  string sep2;
+  for (event_lookup_map_t::const_iterator e = events.begin();
+       e != events.end();
+       ++e)
+  {
+    oss << sep2 << e->first << "->" << e->second->first;
+    sep2 = ",";
+  }
+  oss << "]";
+  return oss.str();
+}
+
 /******************************************************************/
 SafeTimer::SafeTimer(Mutex &event_lock)
   : t(&event_lock)
index 2efd3e04897628acfb555a57df473f912682bc5e..f19f3c74c52e13fdfb8e9f65f0b78f5bd114e75f 100644 (file)
@@ -80,6 +80,8 @@ private:
 
   void pop_running(std::list <Context*> &running_, const utime_t &now);
 
+  std::string show_all_events(const char *caller) const;
+
   // This class isn't supposed to be copied
   Timer(const Timer &rhs);
   Timer& operator=(const Timer &rhs);