From: Sage Weil Date: Sat, 18 Feb 2012 21:45:37 +0000 (-0800) Subject: msgr: fix shutdown vs accept race X-Git-Tag: v0.43~67 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=787dd1709797876dd9fa6004c6723df859003b59;p=ceph.git msgr: fix shutdown vs accept race This is a kludge. The real fix is to rewrite SimpleMessenger as a state machine. Fixes: #2073 Signed-off-by: Sage Weil --- diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index 32eb818217b9..a6898e37e28c 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -729,6 +729,8 @@ int SimpleMessenger::Pipe::accept() << dendl; msgr->lock.Lock(); + if (msgr->dispatch_queue.stop) + goto shutting_down; // note peer's type, flags set_peer_type(connect.host_type); @@ -766,6 +768,9 @@ int SimpleMessenger::Pipe::accept() goto reply; } msgr->lock.Lock(); + if (msgr->dispatch_queue.stop) + goto shutting_down; + // existing? if (msgr->rank_pipe.count(peer_addr)) { @@ -946,6 +951,8 @@ int SimpleMessenger::Pipe::accept() ldout(msgr->cct,10) << "accept features " << connection_state->get_features() << dendl; // ok! + if (msgr->dispatch_queue.stop) + goto shutting_down; register_pipe(); msgr->lock.Unlock(); @@ -985,16 +992,25 @@ int SimpleMessenger::Pipe::accept() fail_unlocked: pipe_lock.Lock(); - bool queued = is_queued(); - if (queued) - state = STATE_CONNECTING; - else - state = STATE_CLOSED; - fault(); - if (queued) - start_writer(); + { + bool queued = is_queued(); + if (queued && state != STATE_CLOSED) + state = STATE_CONNECTING; + else + state = STATE_CLOSED; + fault(); + if (queued) + start_writer(); + } pipe_lock.Unlock(); return -1; + + shutting_down: + msgr->lock.Unlock(); + state = STATE_CLOSED; + fault(); + msgr->lock.Unlock(); + return -1; } int SimpleMessenger::Pipe::connect()