From 35663dee2f7128df642594d0ebdf16640fe1f29a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 13 Jun 2011 10:04:07 -0700 Subject: [PATCH] monc: protect msg source check with monc_lock Push the locking up into ms_dispatch, so that we protect the source check and don't race with session reopens. Also simplifies things a bit. Fixes: #1151 Signed-off-by: Sage Weil --- src/mon/MonClient.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 4748c55be8556..b73fd10dc3d3e 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -276,6 +276,8 @@ bool MonClient::ms_dispatch(Message *m) return false; } + Mutex::Locker lock(monc_lock); + // ignore any messages outside our current session if (m->get_connection() != cur_con) { dout(0) << "discarding stray montior message " << *m << dendl; @@ -299,7 +301,6 @@ bool MonClient::ms_dispatch(Message *m) void MonClient::handle_monmap(MMonMap *m) { - Mutex::Locker lock(monc_lock); dout(10) << "handle_monmap " << *m << dendl; assert(!cur_mon.empty()); @@ -428,8 +429,6 @@ int MonClient::authenticate(double timeout) void MonClient::handle_auth(MAuthReply *m) { - Mutex::Locker lock(monc_lock); - bufferlist::iterator p = m->result_bl.begin(); if (state == MC_STATE_NEGOTIATING) { if (!auth || (int)m->protocol != auth->get_protocol()) { @@ -650,8 +649,6 @@ void MonClient::_renew_subs() void MonClient::handle_subscribe_ack(MMonSubscribeAck *m) { - Mutex::Locker lock(monc_lock); - _finish_hunting(); if (sub_renew_sent != utime_t()) { -- 2.39.5