summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-05-03 12:57:00 -0700
committerSage Weil <sage@inktank.com>2013-05-21 13:07:20 -0700
commitf21a7f7bf3db61bd533e777297bff1346112a0db (patch)
tree044e08f246cee254f3c5562ef127c4849da657f9
parent49c04c623466df45003ed2a18445c354c424a078 (diff)
downloadceph-f21a7f7bf3db61bd533e777297bff1346112a0db.tar.gz
rgw: protect ops log socket formatter
Fixes: #4905 Ops log (through the unix domain socket) uses a formatter, which wasn't protected. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com> (cherry picked from commit d48f1edb07a4d8727ac956f70e663c1b4e33e1dd)
-rw-r--r--src/rgw/rgw_log.cc4
-rw-r--r--src/rgw/rgw_log.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc
index e999f623a01..62dd8c0c46c 100644
--- a/src/rgw/rgw_log.cc
+++ b/src/rgw/rgw_log.cc
@@ -233,7 +233,7 @@ void OpsLogSocket::init_connection(bufferlist& bl)
bl.append("[");
}
-OpsLogSocket::OpsLogSocket(CephContext *cct, uint64_t _backlog) : OutputDataSocket(cct, _backlog)
+OpsLogSocket::OpsLogSocket(CephContext *cct, uint64_t _backlog) : OutputDataSocket(cct, _backlog), lock("OpsLogSocket")
{
formatter = new JSONFormatter;
delim.append(",\n");
@@ -248,8 +248,10 @@ void OpsLogSocket::log(struct rgw_log_entry& entry)
{
bufferlist bl;
+ lock.Lock();
rgw_format_ops_log_entry(entry, formatter);
formatter_to_bl(bl);
+ lock.Unlock();
append_output(bl);
}
diff --git a/src/rgw/rgw_log.h b/src/rgw/rgw_log.h
index 823f0b1767f..37e387d4ce6 100644
--- a/src/rgw/rgw_log.h
+++ b/src/rgw/rgw_log.h
@@ -119,6 +119,7 @@ WRITE_CLASS_ENCODER(rgw_intent_log_entry)
class OpsLogSocket : public OutputDataSocket {
Formatter *formatter;
+ Mutex lock;
void formatter_to_bl(bufferlist& bl);