summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-06-22 12:16:51 +0300
committerTor Lillqvist <tml@iki.fi>2021-06-22 13:09:59 +0300
commit0ae8eaaad01b6c7e56ec18b1bdeef08d3eaae573 (patch)
tree1eac25bf1a17c8e353ae6489db9c52345f131684
parentUse the WSD's pid for the Trace Events coming in from loleaflet (diff)
downloadonline-0ae8eaaad01b6c7e56ec18b1bdeef08d3eaae573.tar.gz
online-0ae8eaaad01b6c7e56ec18b1bdeef08d3eaae573.zip
Use a synthetic pid and tid for Trace Events from loleaflet
Signed-off-by: Tor Lillqvist <tml@collabora.com> Change-Id: Icd84ff030c4fdd9d9a034c00d57a3c34540fb1c4
-rw-r--r--wsd/ClientSession.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 803f096ea1..8b54ee1a5b 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -34,6 +34,8 @@
#endif
using namespace LOOLProtocol;
+static constexpr int SYNTHETIC_LOLEAFLET_PID_OFFSET = 10000000;
+
using Poco::Path;
// rotates regularly
@@ -92,6 +94,17 @@ ClientSession::ClientSession(
// get timestamp set
setState(SessionState::DETACHED);
+
+ // Emit metadata Trace Events for the synthetic pid used for the Trace Events coming in from the
+ // client's loleaflet, and for its dummy thread.
+ TraceEvent::emitOneRecordingIfEnabled("{\"name\":\"process_name\",\"ph\":\"M\",\"args\":{\"name\":\""
+ "loleaflet-" + id
+ + "\"},\"pid\":"
+ + std::to_string(getpid() + SYNTHETIC_LOLEAFLET_PID_OFFSET)
+ + ",\"tid\":1},\n");
+ TraceEvent::emitOneRecordingIfEnabled("{\"name\":\"thread_name\",\"ph\":\"M\",\"args\":{\"name\":\"JS\"},\"pid\":"
+ + std::to_string(getpid() + SYNTHETIC_LOLEAFLET_PID_OFFSET)
+ + ",\"tid\":1},\n");
}
// Can't take a reference in the constructor.
@@ -370,10 +383,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
+ ",\"ts\":"
+ std::to_string(ts + _performanceCounterEpoch)
+ ",\"pid\":"
- + std::to_string(getpid())
- + ",\"tid\":"
- + std::to_string(Util::getThreadId())
- + "},\n");
+ + std::to_string(getpid() + SYNTHETIC_LOLEAFLET_PID_OFFSET)
+ + ",\"tid\":1},\n");
}
else if ((ph == "b" || ph == "e") &&
getTokenUInt64(tokens[4], "id", id))
@@ -387,10 +398,9 @@ bool ClientSession::_handleInput(const char *buffer, int length)
+ ",\"ts\":"
+ std::to_string(ts + _performanceCounterEpoch)
+ ",\"pid\":"
- + std::to_string(getpid())
- + ",\"tid\":"
- + std::to_string(Util::getThreadId())
- + ",\"id\":"
+ + std::to_string(getpid() + SYNTHETIC_LOLEAFLET_PID_OFFSET)
+ + ",\"tid\":1"
+ ",\"id\":"
+ std::to_string(id)
+ "},\n");
}
@@ -404,10 +414,9 @@ bool ClientSession::_handleInput(const char *buffer, int length)
+ ",\"ts\":"
+ std::to_string(ts + _performanceCounterEpoch)
+ ",\"pid\":"
- + std::to_string(getpid())
- + ",\"tid\":"
- + std::to_string(Util::getThreadId())
- + ",\"dur\":"
+ + std::to_string(getpid() + SYNTHETIC_LOLEAFLET_PID_OFFSET)
+ + ",\"tid\":1"
+ ",\"dur\":"
+ std::to_string(dur)
+ "},\n");
}