]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
AsyncConnection: Don't dispatch event when connection is stopped
authorHaomai Wang <haomaiwang@gmail.com>
Tue, 5 May 2015 05:53:23 +0000 (13:53 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Tue, 5 May 2015 05:53:23 +0000 (13:53 +0800)
When marking down connection, previously we will call stop which will dispatch event
regardless of the staus of the connection. If this connection is already down and
its events all has cleaned, we will hit NULL event.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/msg/async/AsyncConnection.h
src/msg/async/AsyncMessenger.cc

index b5aac3ece308497cbdfa9e4c2cc572ed1744abc5..303aaee72e1d7ebf6ef5a212c3d8be7f90dd2eaf 100644 (file)
@@ -278,7 +278,10 @@ class AsyncConnection : public Connection {
   void wakeup_from(uint64_t id);
   void local_deliver();
   void stop() {
-    center->dispatch_event_external(reset_handler);
+    lock.Lock();
+    if (state != STATE_CLOSED)
+      center->dispatch_event_external(reset_handler);
+    lock.Unlock();
     mark_down();
   }
   void cleanup_handler() {
index 2697ebe8766f855c456bdb8243a8e3d1c6d916a9..10e5a5aff089d3264c7b760cbee35c0c52ab1d4c 100644 (file)
@@ -363,8 +363,8 @@ void WorkerPool::barrier()
   pthread_t cur = pthread_self();
   for (vector<Worker*>::iterator it = workers.begin(); it != workers.end(); ++it) {
     assert(cur != (*it)->center.get_owner());
-    (*it)->center.dispatch_event_external(EventCallbackRef(new C_barrier(this)));
     barrier_count.inc();
+    (*it)->center.dispatch_event_external(EventCallbackRef(new C_barrier(this)));
   }
   ldout(cct, 10) << __func__ << " wait for " << barrier_count.read() << " barrier" << dendl;
   Mutex::Locker l(barrier_lock);