From e970ce6fb49fe90d4cc6c274c1ba010cce5ebbe9 Mon Sep 17 00:00:00 2001 From: miltalex Date: Wed, 22 Jul 2020 18:22:21 +0300 Subject: [PATCH] [occ] Export PID to protobuf --- occ/occlib/OccServer.cxx | 6 ++++++ occ/plugin/OccLiteServer.cxx | 6 ++++++ occ/plugin/OccPluginServer.cxx | 7 ++++++- occ/plugin/litestructs/GetState.cxx | 4 ++++ occ/plugin/litestructs/GetState.h | 1 + occ/protos/occ.proto | 1 + 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/occ/occlib/OccServer.cxx b/occ/occlib/OccServer.cxx index 56611ba93..c0b611d0c 100644 --- a/occ/occlib/OccServer.cxx +++ b/occ/occlib/OccServer.cxx @@ -37,6 +37,9 @@ #include #include +#include +#include + #include "RuntimeControlledObject.h" #include "RuntimeControlledObjectPrivate.h" @@ -139,7 +142,10 @@ grpc::Status OccServer::GetState(grpc::ServerContext* context, (void) request; auto state = getStringFromState(m_rco->getState()); + pid_t pid = getpid(); + response->set_state(state); + response->set_pid(pid); return grpc::Status::OK; } diff --git a/occ/plugin/OccLiteServer.cxx b/occ/plugin/OccLiteServer.cxx index 09d8b9d83..833e183ba 100644 --- a/occ/plugin/OccLiteServer.cxx +++ b/occ/plugin/OccLiteServer.cxx @@ -39,6 +39,9 @@ #include #include +#include +#include + #include #include @@ -77,7 +80,10 @@ ::grpc::Status OccLite::Service::GetState(::grpc_impl::ServerContext* context, (void) request; auto state = fair::mq::PluginServices::ToStr(m_pluginServices->GetCurrentDeviceState()); + pid_t pid = getpid(); + response->state = state; + response->pid = pid; OLOG(INFO) << "GetState response: " << response->state; return grpc::Status::OK; diff --git a/occ/plugin/OccPluginServer.cxx b/occ/plugin/OccPluginServer.cxx index ef2e4c85d..e013a866a 100644 --- a/occ/plugin/OccPluginServer.cxx +++ b/occ/plugin/OccPluginServer.cxx @@ -38,6 +38,9 @@ #include #include +#include +#include + OccPluginServer::OccPluginServer(fair::mq::PluginServices* pluginServices) : Service(), m_pluginServices(pluginServices) { @@ -149,7 +152,10 @@ grpc::Status OccPluginServer::GetState(grpc::ServerContext* context, (void) request; auto state = fair::mq::PluginServices::ToStr(m_pluginServices->GetCurrentDeviceState()); + pid_t pid = getpid(); + response->set_state(state); + response->set_pid(pid); return grpc::Status::OK; } @@ -230,4 +236,3 @@ OccPluginServer::Transition(grpc::ServerContext* context, return grpc::Status::OK; } - diff --git a/occ/plugin/litestructs/GetState.cxx b/occ/plugin/litestructs/GetState.cxx index 82984f572..439c31721 100644 --- a/occ/plugin/litestructs/GetState.cxx +++ b/occ/plugin/litestructs/GetState.cxx @@ -31,6 +31,9 @@ bool OccLite::nopb::GetStateResponse::Serialize(rapidjson::WriterString("state"); writer->String(state); + writer->String("pid"); + writer->Int(pid); + writer->EndObject(); return true; } @@ -38,6 +41,7 @@ bool OccLite::nopb::GetStateResponse::Serialize(rapidjson::Writer* writer) const override; bool Deserialize(const rapidjson::Value& obj) override; diff --git a/occ/protos/occ.proto b/occ/protos/occ.proto index c047a9dba..c4fa429bc 100644 --- a/occ/protos/occ.proto +++ b/occ/protos/occ.proto @@ -74,6 +74,7 @@ message EventStreamReply { message GetStateRequest {} message GetStateReply { string state = 1; + int32 pid = 2; } message ConfigEntry {