]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: use scoped_guard instead of goto 24304/head
authorKefu Chai <kchai@redhat.com>
Thu, 27 Sep 2018 13:28:57 +0000 (21:28 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 27 Sep 2018 14:02:14 +0000 (22:02 +0800)
also silences the unused label warning. as "out_shutdown" is not used
anymore after f35e10f4849440f0583d021e23a83563dd3b1607 .

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

index 356e0cff9237d08a45db6202a5a6790e105d5f1c..a7cc57f62d70d2931c12d9d49ab25eca51097f3c 100644 (file)
@@ -103,11 +103,14 @@ int MonClient::get_monmap_and_config()
   interval.set_from_double(cct->_conf->mon_client_hunt_interval);
 
   cct->init_crypto();
+  auto shutdown_crypto = make_scope_guard([this] {
+    cct->shutdown_crypto();
+  });
 
   int r = build_initial_monmap();
   if (r < 0) {
     lderr(cct) << __func__ << " cannot identify monitors to contact" << dendl;
-    goto out;
+    return r;
   }
 
   messenger = Messenger::create_client_messenger(
@@ -115,11 +118,20 @@ int MonClient::get_monmap_and_config()
   ceph_assert(messenger);
   messenger->add_dispatcher_head(this);
   messenger->start();
+  auto shutdown_msgr = make_scope_guard([this] {
+    messenger->shutdown();
+    messenger->wait();
+    delete messenger;
+    messenger = nullptr;
+    if (!monmap.fsid.is_zero()) {
+      cct->_conf.set_val("fsid", stringify(monmap.fsid));
+    }
+  });
 
   while (tries-- > 0) {
     r = init();
     if (r < 0) {
-      goto out_msgr;
+      return r;
     }
     r = authenticate(cct->_conf->client_mount_timeout);
     if (r == -ETIMEDOUT) {
@@ -154,21 +166,7 @@ int MonClient::get_monmap_and_config()
     continue;
   }
 
-out_shutdown:
   shutdown();
-
-out_msgr:
-  messenger->shutdown();
-  messenger->wait();
-  delete messenger;
-  messenger = nullptr;
-
-  if (!monmap.fsid.is_zero()) {
-    cct->_conf.set_val("fsid", stringify(monmap.fsid));
-  }
-
-out:
-  cct->shutdown_crypto();
   return r;
 }