From a16ca787a8cc73a365ee55634ba361b98c733807 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 26 Jul 2017 13:54:58 +0800 Subject: [PATCH] mon/MonClient: do not send_log if conn is not active anymore 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 --- src/mon/MonClient.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index a0cd1e923c8e..850b38d69b60 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -14,6 +14,8 @@ #include +#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() -- 2.47.3