]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
monc: protect msg source check with monc_lock
authorSage Weil <sage@newdream.net>
Mon, 13 Jun 2011 17:04:07 +0000 (10:04 -0700)
committerSage Weil <sage@newdream.net>
Mon, 13 Jun 2011 17:04:07 +0000 (10:04 -0700)
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 <sage@newdream.net>
src/mon/MonClient.cc

index 4748c55be85569ef66b4bd2ed918a4143764b4eb..b73fd10dc3d3eadbb064da8dd75f5552822fe4d5 100644 (file)
@@ -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()) {