]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: do not assert on auth in build_authorizer() 13685/head
authorKefu Chai <kchai@redhat.com>
Tue, 28 Feb 2017 06:38:14 +0000 (06:38 +0000)
committerKefu Chai <kchai@redhat.com>
Wed, 1 Mar 2017 02:11:12 +0000 (10:11 +0800)
* there is chance that some connections is still trying to authorize
  itself after the MonClient is shut down. do not assert in this case,
  but it is a sign of bug, or bad shutdown sequence, so print a message to
  dout().
* do not use active_con->get_auth() as an alternative to `this->auth` if
  it is not available. because we promote the authorized conn in
  pending_cons as the active_con, and std::swap(active_conn->auth, this->auth)
  with the monc_lock. so there is no point to return active_con->get_auth(),
  as it's always null.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/MonClient.cc

index 644a0e48812bf024a5be2699d1ea507fc4f43d81..c685996a8e64c6d7959327599c602d9b1ef2a83d 100644 (file)
@@ -1136,11 +1136,13 @@ void MonClient::handle_get_version_reply(MMonGetVersionReply* m)
 
 AuthAuthorizer* MonClient::build_authorizer(int service_id) const {
   Mutex::Locker l(monc_lock);
-  assert(auth || active_con->get_auth());
-  if (auth)
+  if (auth) {
     return auth->build_authorizer(service_id);
-  else
-    return active_con->get_auth()->build_authorizer(service_id);
+  } else {
+    ldout(cct, 0) << __func__ << " for " << ceph_entity_type_name(service_id)
+                 << ", but no auth is available now" << dendl;
+    return nullptr;
+  }
 }
 
 #define dout_subsys ceph_subsys_monc