]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: make get_mon_log_message() atomic 14587/head
authorKefu Chai <kchai@redhat.com>
Mon, 10 Apr 2017 06:53:46 +0000 (14:53 +0800)
committerAlexey Sheplyakov <asheplyakov@mirantis.com>
Mon, 17 Apr 2017 10:12:45 +0000 (14:12 +0400)
* LogClient: move reset_session() into get_mon_log_message() and add a
  "flush" param to the latter. so it can get_mon_log_message()
  atomically. otherwise another call changing the log queue could sneak
  in between reset_session() and get_mon_log_message().
* MonClient: add a "flush" param to do_send() so we can reset the
  LogClient session once we are connected to a monitor.

Fixes: http://tracker.ceph.com/issues/19427
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 5215e291da2b527d85e129eda86043490843178e)

Conflicts:
src/mon/MonClient.cc: handle_auth: replaced 'log_client->reset_session();
send_log();' sequence with newly introduced 'send_log(true);' like
the original patch does

src/common/LogClient.cc
src/common/LogClient.h
src/mon/MonClient.cc
src/mon/MonClient.h

index 237ce4bcf9d28578e5bc99d03bf24be1f06d6f3c..e8a4bb922a23baa50884e1dfcb38fed598e18bef 100644 (file)
@@ -265,15 +265,13 @@ void LogChannel::do_log(clog_type prio, const std::string& s)
   }
 }
 
-void LogClient::reset_session()
-{
-  Mutex::Locker l(log_lock);
-  last_log_sent = last_log - log_queue.size();
-}
-
-Message *LogClient::get_mon_log_message()
+Message *LogClient::get_mon_log_message(bool flush)
 {
   Mutex::Locker l(log_lock);
+  if (flush) {
+    // reset session
+    last_log_sent = last_log - log_queue.size();
+  }
   return _get_mon_log_message();
 }
 
index 3bb4e47301b47eb9410624168713310833ded85c..051c67534b6d5e75492b2b12f1a5fdea216b2745 100644 (file)
@@ -205,8 +205,7 @@ public:
   }
 
   bool handle_log_ack(MLogAck *m);
-  void reset_session();
-  Message *get_mon_log_message();
+  Message *get_mon_log_message(bool flush);
   bool are_pending();
 
   LogChannelRef create_channel() {
index 6395918a754a72b05c1091e1abf76e020cb25470..85c818dc8ec05f3f6026e5add276293dd6ef3ba8 100644 (file)
@@ -310,10 +310,10 @@ bool MonClient::ms_dispatch(Message *m)
   return true;
 }
 
-void MonClient::send_log()
+void MonClient::send_log(bool flush)
 {
   if (log_client) {
-    Message *lm = log_client->get_mon_log_message();
+    Message *lm = log_client->get_mon_log_message(flush);
     if (lm)
       _send_mon_message(lm);
     more_log_pending = log_client->are_pending();
@@ -539,13 +539,9 @@ void MonClient::handle_auth(MAuthReply *m)
        _send_mon_message(waiting_for_session.front());
        waiting_for_session.pop_front();
       }
-
       _resend_mon_commands();
 
-      if (log_client) {
-       log_client->reset_session();
-       send_log();
-      }
+      send_log(true);
       if (session_established_context) {
         cb = session_established_context;
         session_established_context = NULL;
index 2efa1ff48facc2d9171da5113032e1693c78f67d..59e3c7b1e14ee1224a35907aa863dc0a1b300260 100644 (file)
@@ -138,7 +138,7 @@ private:
   LogClient *log_client;
   bool more_log_pending;
 
-  void send_log();
+  void send_log(bool flush = false);
 
   AuthMethodList *auth_supported;