From: Haomai Wang Date: Tue, 5 May 2015 05:53:23 +0000 (+0800) Subject: AsyncConnection: Don't dispatch event when connection is stopped X-Git-Tag: v9.0.2~222^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c26b21fa7981b050dbd10b5f82832100a69f9db0;p=ceph.git AsyncConnection: Don't dispatch event when connection is stopped 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 --- diff --git a/src/msg/async/AsyncConnection.h b/src/msg/async/AsyncConnection.h index b5aac3ece308..303aaee72e1d 100644 --- a/src/msg/async/AsyncConnection.h +++ b/src/msg/async/AsyncConnection.h @@ -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() { diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc index 2697ebe8766f..10e5a5aff089 100644 --- a/src/msg/async/AsyncMessenger.cc +++ b/src/msg/async/AsyncMessenger.cc @@ -363,8 +363,8 @@ void WorkerPool::barrier() pthread_t cur = pthread_self(); for (vector::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);