]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
DispatchQueue: factor out pre_dispatch and post_dispatch
authorSamuel Just <sam.just@inktank.com>
Thu, 7 Nov 2013 21:44:07 +0000 (13:44 -0800)
committerGreg Farnum <greg@inktank.com>
Mon, 5 May 2014 22:29:15 +0000 (15:29 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/msg/DispatchQueue.cc
src/msg/DispatchQueue.h

index 8a79ce0d7e04313e83dcf188f4efba9762b35dd7..9489a40490dd0b1faedca23bbd2e88c92c447488 100644 (file)
@@ -36,6 +36,30 @@ double DispatchQueue::get_max_age(utime_t now) {
     return (now - marrival.begin()->first);
 }
 
+uint64_t DispatchQueue::pre_dispatch(Message *m)
+{
+  ldout(cct,1) << "<== " << m->get_source_inst()
+              << " " << m->get_seq()
+              << " ==== " << *m
+              << " ==== " << m->get_payload().length()
+              << "+" << m->get_middle().length()
+              << "+" << m->get_data().length()
+              << " (" << m->get_footer().front_crc << " "
+              << m->get_footer().middle_crc
+              << " " << m->get_footer().data_crc << ")"
+              << " " << m << " con " << m->get_connection()
+              << dendl;
+  uint64_t msize = m->get_dispatch_throttle_size();
+  m->set_dispatch_throttle_size(0); // clear it out, in case we requeue this message.
+  return msize;
+}
+
+void DispatchQueue::post_dispatch(Message *m, uint64_t msize)
+{
+  msgr->dispatch_throttle_release(msize);
+  ldout(cct,20) << "done calling dispatch on " << m << dendl;
+}
+
 void DispatchQueue::enqueue(Message *m, int priority, uint64_t id)
 {
   Mutex::Locker l(lock);
@@ -109,23 +133,9 @@ void DispatchQueue::entry()
          ldout(cct,10) << " stop flag set, discarding " << m << " " << *m << dendl;
          m->put();
        } else {
-         uint64_t msize = m->get_dispatch_throttle_size();
-         m->set_dispatch_throttle_size(0);  // clear it out, in case we requeue this message.
-
-         ldout(cct,1) << "<== " << m->get_source_inst()
-                      << " " << m->get_seq()
-                      << " ==== " << *m
-                      << " ==== " << m->get_payload().length() << "+" << m->get_middle().length()
-                      << "+" << m->get_data().length()
-                      << " (" << m->get_footer().front_crc << " " << m->get_footer().middle_crc
-                      << " " << m->get_footer().data_crc << ")"
-                      << " " << m << " con " << m->get_connection()
-                      << dendl;
+         uint64_t msize = pre_dispatch(m);
          msgr->ms_deliver_dispatch(m);
-
-         msgr->dispatch_throttle_release(msize);
-
-         ldout(cct,20) << "done calling dispatch on " << m << dendl;
+         post_dispatch(m, msize);
        }
       }
 
index dffd65cc54ef473ce13d125727c5788ef62684c3..5b0decdd984b832d933b3d9f91f063111f9fbf02 100644 (file)
@@ -106,6 +106,9 @@ class DispatchQueue {
     }
   } dispatch_thread;
 
+  uint64_t pre_dispatch(Message *m);
+  void post_dispatch(Message *m, uint64_t msize);
+
   public:
   bool stop;
   void local_delivery(Message *m, int priority);