From 9cacdf1bca51d194e571bda60648d70c2d3b1e30 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Sat, 16 Jan 2016 12:44:50 +0800 Subject: [PATCH] AsyncConnection: Dont send message when local connection is closed Fix: #14386 Signed-off-by: Haomai Wang --- src/msg/async/AsyncConnection.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 52240965c4b..cfd34713e8a 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -2027,11 +2027,17 @@ int AsyncConnection::send_message(Message *m) m->set_connection(this); if (async_msgr->get_myaddr() == get_peer_addr()) { //loopback connection - ldout(async_msgr->cct, 20) << __func__ << " " << *m << " local" << dendl; - Mutex::Locker l(write_lock); - local_messages.push_back(m); - center->dispatch_event_external(local_deliver_handler); - return 0; + ldout(async_msgr->cct, 20) << __func__ << " " << *m << " local" << dendl; + Mutex::Locker l(write_lock); + if (can_write != CLOSED) { + local_messages.push_back(m); + center->dispatch_event_external(local_deliver_handler); + } else { + ldout(async_msgr->cct, 10) << __func__ << " loopback connection closed." + << " Drop message " << m << dendl; + m->put(); + } + return 0; } // we don't want to consider local message here, it's too lightweight which -- 2.47.3