]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: Make SimpleMessenger shutdown safer 1353/head
authorJohn Spray <john.spray@inktank.com>
Wed, 26 Feb 2014 16:29:20 +0000 (16:29 +0000)
committerJohn Spray <john.spray@inktank.com>
Mon, 3 Mar 2014 19:05:03 +0000 (19:05 +0000)
...in the case where no dispatchers were ever added, previously
we would throw an assertion in wait().

Signed-off-by: John Spray <john.spray@inktank.com>
src/msg/Accepter.cc
src/msg/DispatchQueue.h
src/msg/SimpleMessenger.cc

index 5eebb2eec61f69d25ad5b3313204c00933d9aebf..eb578cd9ed823345ad8e8358a0ae7509cffff3f1 100644 (file)
@@ -247,7 +247,9 @@ void Accepter::stop()
 
   // wait for thread to stop before closing the socket, to avoid
   // racing against fd re-use.
-  join();
+  if (is_started()) {
+    join();
+  }
 
   if (listen_sd >= 0) {
     ::close(listen_sd);
index df73130359233407897338f9470cf2d8b0189f65..dffd65cc54ef473ce13d125727c5788ef62684c3 100644 (file)
@@ -168,6 +168,7 @@ class DispatchQueue {
   void entry();
   void wait();
   void shutdown();
+  bool is_started() {return dispatch_thread.is_started();}
 
   DispatchQueue(CephContext *cct, SimpleMessenger *msgr)
     : cct(cct), msgr(msgr),
index 78e0e69835b670a337fa82f1f6c3aca096c3c24d..e11783dd0ab56f3d87acf94c0bf8771b0b8e4090 100644 (file)
@@ -509,10 +509,12 @@ void SimpleMessenger::wait()
   }
   lock.Unlock();
 
-  ldout(cct,10) << "wait: waiting for dispatch queue" << dendl;
-  dispatch_queue.wait();
-  ldout(cct,10) << "wait: dispatch queue is stopped" << dendl;
-  
+  if(dispatch_queue.is_started()) {
+    ldout(cct,10) << "wait: waiting for dispatch queue" << dendl;
+    dispatch_queue.wait();
+    ldout(cct,10) << "wait: dispatch queue is stopped" << dendl;
+  }
+
   // done!  clean up.
   if (did_bind) {
     ldout(cct,20) << "wait: stopping accepter thread" << dendl;