[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/TraceFile.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Aug 8 03:51:32 UTC 2016
loolwsd/LOOLWSD.cpp | 2 +
loolwsd/TraceFile.hpp | 70 ++++++++++++++++++++++++++------------------------
2 files changed, 39 insertions(+), 33 deletions(-)
New commits:
commit ca9135e7a5682df3b0368cc84d73efcf2058f0f9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Tue Aug 2 10:00:37 2016 -0400
loolstress: add pid to trace file and parse it
Change-Id: I74569d5692291b4f3310b996d1cf49d5c951d0fc
Reviewed-on: https://gerrit.libreoffice.org/27964
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index c2df0b3..74f22af 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -862,6 +862,8 @@ public:
const auto id = LOOLWSD::GenSessionId();
Poco::URI requestUri(request.getURI());
+ Log::debug("Handling GET: " + request.getURI());
+
std::vector<std::string> reqPathSegs;
requestUri.getPathSegments(reqPathSegs);
diff --git a/loolwsd/TraceFile.hpp b/loolwsd/TraceFile.hpp
index bb39c44..a5dc558 100644
--- a/loolwsd/TraceFile.hpp
+++ b/loolwsd/TraceFile.hpp
@@ -14,6 +14,27 @@
#include <vector>
/// Dumps commands and notification trace.
+class TraceFileRecord
+{
+public:
+ enum class Direction : char
+ {
+ Invalid = 0,
+ Incoming = '>',
+ Outgoing = '<'
+ };
+
+ TraceFileRecord() :
+ Dir(Direction::Invalid)
+ {
+ }
+
+ Direction Dir;
+ unsigned Pid;
+ unsigned TimestampNs;
+ std::string Payload;
+};
+
class TraceFileWriter
{
public:
@@ -30,22 +51,24 @@ public:
void writeIncoming(const std::string& data)
{
- std::unique_lock<std::mutex> lock(_mutex);
- const Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - _epochStart;
- _stream.write(">", 1);
- _stream << usec;
- _stream.write(">", 1);
- _stream.write(data.c_str(), data.size());
- _stream.write("\n", 1);
+ write(data, static_cast<char>(TraceFileRecord::Direction::Incoming));
}
void writeOutgoing(const std::string& data)
{
+ write(data, static_cast<char>(TraceFileRecord::Direction::Outgoing));
+ }
+
+private:
+ void write(const std::string& data, const char delim)
+ {
std::unique_lock<std::mutex> lock(_mutex);
const Poco::Int64 usec = Poco::Timestamp().epochMicroseconds() - _epochStart;
- _stream.write("<", 1);
+ _stream.write(&delim, 1);
+ _stream << getpid();
+ _stream.write(&delim, 1);
_stream << usec;
- _stream.write("<", 1);
+ _stream.write(&delim, 1);
_stream.write(data.c_str(), data.size());
_stream.write("\n", 1);
}
@@ -56,26 +79,6 @@ private:
std::mutex _mutex;
};
-class TraceFileRecord
-{
-public:
- enum class Direction
- {
- Invalid,
- Incoming,
- Outgoing
- };
-
- TraceFileRecord() :
- Dir(Direction::Invalid)
- {
- }
-
- Direction Dir;
- unsigned TimestampNs;
- std::string Payload;
-};
-
class TraceFileReader
{
public:
@@ -124,12 +127,13 @@ private:
while (std::getline(_stream, line) && !line.empty())
{
const auto v = split(line, line[0]);
- if (v.size() == 2)
+ if (v.size() == 3)
{
TraceFileRecord rec;
- rec.Dir = (line[0] == '>' ? TraceFileRecord::Direction::Incoming : TraceFileRecord::Direction::Outgoing);
- rec.TimestampNs = std::atoi(v[0].c_str());
- rec.Payload = v[1];
+ rec.Dir = static_cast<TraceFileRecord::Direction>(line[0]);
+ rec.Pid = std::atoi(v[0].c_str());
+ rec.TimestampNs = std::atoi(v[1].c_str());
+ rec.Payload = v[2];
_records.push_back(rec);
}
}
More information about the Libreoffice-commits
mailing list