]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: do not send_log if conn is not active anymore 16576/head
authorKefu Chai <kchai@redhat.com>
Wed, 26 Jul 2017 05:54:58 +0000 (13:54 +0800)
committerSage Weil <sage@redhat.com>
Wed, 26 Jul 2017 11:53:40 +0000 (07:53 -0400)
the log message to be sent will be appended to waiting_for_session
instead. but we will send the logs anyway when the MonClient is
authorized with the new connection. so, avoid doing this as it's not
necessary.

also refactor the schedule_tick() call into a scope_guard, so it is
always called upon the return of the tick() method.

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

index a0cd1e923c8ee2bbc023a7b08e5ee8ccd15149f9..850b38d69b605b47ba84b5989a00494134502a57 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <random>
 
+#include "include/scope_guard.h"
+
 #include "messages/MMonGetMap.h"
 #include "messages/MMonGetVersion.h"
 #include "messages/MMonGetVersionReply.h"
@@ -737,11 +739,15 @@ void MonClient::tick()
 {
   ldout(cct, 10) << __func__ << dendl;
 
+  auto reschedule_tick = make_scope_guard([this] {
+      schedule_tick();
+    });
+
   _check_auth_tickets();
   
   if (_hunting()) {
     ldout(cct, 1) << "continuing hunt" << dendl;
-    _reopen_session();
+    return _reopen_session();
   } else if (active_con) {
     // just renew as needed
     utime_t now = ceph_clock_now();
@@ -764,16 +770,13 @@ void MonClient::tick()
       if (interval > cct->_conf->mon_client_ping_timeout) {
        ldout(cct, 1) << "no keepalive since " << lk << " (" << interval
                      << " seconds), reconnecting" << dendl;
-       _reopen_session();
+       return _reopen_session();
       }
-
       send_log();
     }
 
     _un_backoff();
   }
-
-  schedule_tick();
 }
 
 void MonClient::_un_backoff()