]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: make get_mon_log_message() atomic 14588/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 11:14:43 +0000 (15:14 +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 f52912f7fccc4ac765375bd3f8f670d405763231..e5c069fd7031be94159b6a1debfa550af46874a2 100644 (file)
@@ -264,15 +264,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 bf70e39a805222ef4071bf4bc4abea1c4d54b769..0e8a2578bf1d1ede2de18fcb453e5429dc35868a 100644 (file)
@@ -206,8 +206,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 3db182f6da2838cc2f1073b74b6b41a757705469..6eaa395f40eba80ea05745f4114b45dfb588129d 100644 (file)
@@ -302,10 +302,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();
@@ -544,13 +544,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 d2a29953ff4c5b1382dea4643d75fd3ab63840a4..0164cb3d3b97cd8bf3c772eb24cba940393b54e6 100644 (file)
@@ -129,7 +129,7 @@ private:
   LogClient *log_client;
   bool more_log_pending;
 
-  void send_log();
+  void send_log(bool flush = false);
 
   AuthMethodList *auth_supported;