]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
AsyncConnection: avoid dispatch event to a closed connection
authorHaomai Wang <haomai@xsky.com>
Sat, 30 Jan 2016 18:04:04 +0000 (02:04 +0800)
committerHaomai Wang <haomai@xsky.com>
Sat, 30 Jan 2016 18:04:04 +0000 (02:04 +0800)
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 <haomai@xsky.com>
src/msg/async/AsyncConnection.cc

index 38be59d3cf0373341bbb419ab8a7a388d8311b3e..cce78d8ec61a55f651736f4da14dc47e2b101b04 100644 (file)
@@ -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);