From: Haomai Wang Date: Sat, 30 Jan 2016 18:04:04 +0000 (+0800) Subject: AsyncConnection: avoid dispatch event to a closed connection X-Git-Tag: v10.0.4~54^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc289fe4febb61e2237442c8c45a0b7bd37854ed;p=ceph.git AsyncConnection: avoid dispatch event to a closed connection 1. thread 1 call AsyncConnection::accept and create file event 2. the owner thread of connection is waked from file event 3. then this connection is closed soon 4. thread 1 dispatch reader event 5. the owner thread will crash because of a closed connection Fix #14566 Signed-off-by: Haomai Wang --- diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 38be59d3cf0..cce78d8ec61 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -2007,6 +2007,7 @@ void AsyncConnection::accept(int incoming) ldout(async_msgr->cct, 10) << __func__ << " sd=" << incoming << dendl; assert(sd < 0); + Mutex::Locker l(lock); sd = incoming; state = STATE_ACCEPTING; center->create_file_event(sd, EVENT_READABLE, read_handler);