aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/sessionsclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/sessionsclient.cpp')
-rw-r--r--src/zenutil/sessionsclient.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/zenutil/sessionsclient.cpp b/src/zenutil/sessionsclient.cpp
index 6ba997a62..f8dab4fb9 100644
--- a/src/zenutil/sessionsclient.cpp
+++ b/src/zenutil/sessionsclient.cpp
@@ -6,6 +6,8 @@
#include <zencore/fmtutils.h>
#include <zencore/iobuffer.h>
#include <zencore/logging/logmsg.h>
+#include <zencore/process.h>
+#include <zencore/system.h>
#include <zencore/thread.h>
#include <vector>
@@ -70,6 +72,27 @@ SessionsServiceClient::SessionsServiceClient(Options Opts)
m_Options.TargetUrl.pop_back();
}
+ // Auto-detect the platform if the caller didn't set one explicitly.
+ if (m_Options.Platform.empty())
+ {
+ m_Options.Platform = std::string(GetRuntimePlatformName());
+ }
+
+ // Auto-fill ClientPid when we can reasonably assume the target is on the
+ // same machine. The server ALSO defensively gates pid acceptance on
+ // IsLocalMachineRequest(), so sending a pid for a non-local URL doesn't
+ // cause false positives — this heuristic just avoids the redundant send.
+ if (m_Options.ClientPid == 0)
+ {
+ const bool IsUnixSocket = !m_Options.ClientSettings.UnixSocketPath.empty();
+ const bool LooksLocal = IsUnixSocket || m_Options.TargetUrl.find("localhost") != std::string::npos ||
+ m_Options.TargetUrl.find("127.0.0.1") != std::string::npos;
+ if (LooksLocal)
+ {
+ m_Options.ClientPid = static_cast<uint32_t>(GetCurrentProcessId());
+ }
+ }
+
m_WorkerThread = std::thread([this]() {
zen::SetCurrentThreadName("SessionIO");
WorkerLoop();
@@ -98,6 +121,18 @@ SessionsServiceClient::BuildRequestBody(CbObjectView Metadata) const
{
Writer << "mode" << m_Options.Mode;
}
+ if (!m_Options.Platform.empty())
+ {
+ Writer << "platform" << m_Options.Platform;
+ }
+ if (m_Options.ClientPid != 0)
+ {
+ Writer << "pid" << m_Options.ClientPid;
+ }
+ if (m_Options.ParentSessionId != Oid::Zero)
+ {
+ Writer << "parent_session_id" << m_Options.ParentSessionId;
+ }
if (m_Options.JobId != Oid::Zero)
{
Writer << "jobid" << m_Options.JobId;