From: Kefu Chai Date: Fri, 15 Mar 2019 03:27:53 +0000 (+0800) Subject: mon: avoid using naked pointer X-Git-Tag: v14.2.0~14^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0500fff76b088f34c3ae81ab4305eed507051027;p=ceph-ci.git mon: avoid using naked pointer to save our trouble to delete auth_handler in the error handling paths Signed-off-by: Kefu Chai --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index cd4cec304e0..7eeef1dad07 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6184,8 +6184,8 @@ int Monitor::handle_auth_request( } // handler? - AuthServiceHandler *auth_handler = get_auth_service_handler( - auth_method, g_ceph_context, &key_server); + unique_ptr auth_handler{get_auth_service_handler( + auth_method, g_ceph_context, &key_server)}; if (!auth_handler) { dout(1) << __func__ << " auth_method " << auth_method << " not supported" << dendl; @@ -6200,7 +6200,6 @@ int Monitor::handle_auth_request( if (mode < AUTH_MODE_MON || mode > AUTH_MODE_MON_MAX) { dout(1) << __func__ << " invalid mode " << (int)mode << dendl; - delete auth_handler; return -EACCES; } assert(mode >= AUTH_MODE_MON && mode <= AUTH_MODE_MON_MAX); @@ -6208,7 +6207,6 @@ int Monitor::handle_auth_request( decode(con->peer_global_id, p); } catch (buffer::error& e) { dout(1) << __func__ << " failed to decode, " << e.what() << dendl; - delete auth_handler; return -EACCES; } @@ -6221,7 +6219,6 @@ int Monitor::handle_auth_request( dout(10) << __func__ << " entity " << entity_name << " method " << auth_method << " not among supported " << auth_cluster_required.get_supported_set() << dendl; - delete auth_handler; return -EOPNOTSUPP; } } else { @@ -6229,7 +6226,6 @@ int Monitor::handle_auth_request( dout(10) << __func__ << " entity " << entity_name << " method " << auth_method << " not among supported " << auth_cluster_required.get_supported_set() << dendl; - delete auth_handler; return -EOPNOTSUPP; } } @@ -6242,7 +6238,6 @@ int Monitor::handle_auth_request( con->peer_global_id = authmon()->_assign_global_id(); if (!con->peer_global_id) { dout(1) << __func__ << " failed to assign global_id" << dendl; - delete auth_handler; return -EBUSY; } dout(10) << __func__ << " assigned global_id " << con->peer_global_id @@ -6251,7 +6246,7 @@ int Monitor::handle_auth_request( // set up partial session s = new MonSession(con); - s->auth_handler = auth_handler; + s->auth_handler = auth_handler.release(); con->set_priv(RefCountedPtr{s, false}); r = s->auth_handler->start_session(