]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
LogClient: fill seq & who for syslog and graylog 10196/head
authorXiaoxi Chen <xiaoxchen@ebay.com>
Fri, 8 Jul 2016 07:17:40 +0000 (15:17 +0800)
committerXiaoxi Chen <xiaoxchen@ebay.com>
Mon, 7 Nov 2016 05:41:05 +0000 (13:41 +0800)
Previous code fill "seq" and "who" in LogClient::queue(), but
syslog and graylog doesn't go through this path. Which will result
the message without unidentifier.

Fixes http://tracker.ceph.com/issues/16609

Signed-off-by: Xiaoxi Chen <xiaoxchen@ebay.com>
src/common/LogClient.cc
src/common/LogClient.h

index 237ce4bcf9d28578e5bc99d03bf24be1f06d6f3c..43a88f8331c5322cc55d39739f8301574d938c3e 100644 (file)
@@ -238,11 +238,10 @@ void LogChannel::do_log(clog_type prio, const std::string& s)
   int lvl = (prio == CLOG_ERROR ? -1 : 0);
   ldout(cct,lvl) << "log " << prio << " : " << s << dendl;
   LogEntry e;
-  // who will be set when we queue the entry on LogClient
-  //e.who = messenger->get_myinst();
   e.stamp = ceph_clock_now(cct);
-  // seq will be set when we queue the entry on LogClient
-  // e.seq = ++last_log;
+  // seq and who should be set for syslog/graylog/log_to_mon
+  e.who = parent->get_myinst();
+  e.seq = parent->get_next_seq();
   e.prio = prio;
   e.msg = s;
   e.channel = get_log_channel();
@@ -342,8 +341,6 @@ void LogClient::_send_to_mon()
 version_t LogClient::queue(LogEntry &entry)
 {
   Mutex::Locker l(log_lock);
-  entry.seq = ++last_log;
-  entry.who = messenger->get_myinst();
   log_queue.push_back(entry);
 
   if (is_mon) {
@@ -353,6 +350,16 @@ version_t LogClient::queue(LogEntry &entry)
   return entry.seq;
 }
 
+uint64_t LogClient::get_next_seq()
+{
+  return ++last_log;
+}
+
+const entity_inst_t& LogClient::get_myinst()
+{
+  return messenger->get_myinst();
+}
+
 bool LogClient::handle_log_ack(MLogAck *m)
 {
   Mutex::Locker l(log_lock);
index 3bb4e47301b47eb9410624168713310833ded85c..15f800f3013d5bbdd83e4592475f9b0eed9cff77 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <iosfwd>
 #include <sstream>
+#include <atomic>
 
 class LogClient;
 class MLog;
@@ -233,6 +234,8 @@ public:
     channels.clear();
   }
 
+  uint64_t get_next_seq();
+  const entity_inst_t& get_myinst();
   version_t queue(LogEntry &entry);
 
 private:
@@ -245,7 +248,7 @@ private:
   bool is_mon;
   Mutex log_lock;
   version_t last_log_sent;
-  version_t last_log;
+  std::atomic<uint64_t> last_log;
   std::deque<LogEntry> log_queue;
 
   std::map<std::string, LogChannelRef> channels;