Skip to content

Commit e970ce6

Browse files
miltalexteo
authored andcommitted
[occ] Export PID to protobuf
1 parent d7e053c commit e970ce6

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

occ/occlib/OccServer.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#include <boost/algorithm/string.hpp>
3838
#include <boost/property_tree/ptree.hpp>
3939

40+
#include <sys/types.h>
41+
#include <unistd.h>
42+
4043
#include "RuntimeControlledObject.h"
4144
#include "RuntimeControlledObjectPrivate.h"
4245

@@ -139,7 +142,10 @@ grpc::Status OccServer::GetState(grpc::ServerContext* context,
139142
(void) request;
140143

141144
auto state = getStringFromState(m_rco->getState());
145+
pid_t pid = getpid();
146+
142147
response->set_state(state);
148+
response->set_pid(pid);
143149

144150
return grpc::Status::OK;
145151
}

occ/plugin/OccLiteServer.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include <boost/algorithm/string/predicate.hpp>
4040
#include <boost/algorithm/string/split.hpp>
4141

42+
#include <sys/types.h>
43+
#include <unistd.h>
44+
4245
#include <condition_variable>
4346
#include <iomanip>
4447

@@ -77,7 +80,10 @@ ::grpc::Status OccLite::Service::GetState(::grpc_impl::ServerContext* context,
7780
(void) request;
7881

7982
auto state = fair::mq::PluginServices::ToStr(m_pluginServices->GetCurrentDeviceState());
83+
pid_t pid = getpid();
84+
8085
response->state = state;
86+
response->pid = pid;
8187
OLOG(INFO) << "GetState response: " << response->state;
8288

8389
return grpc::Status::OK;

occ/plugin/OccPluginServer.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include <condition_variable>
3939
#include <iomanip>
4040

41+
#include <sys/types.h>
42+
#include <unistd.h>
43+
4144
OccPluginServer::OccPluginServer(fair::mq::PluginServices* pluginServices)
4245
: Service(), m_pluginServices(pluginServices)
4346
{
@@ -149,7 +152,10 @@ grpc::Status OccPluginServer::GetState(grpc::ServerContext* context,
149152
(void) request;
150153

151154
auto state = fair::mq::PluginServices::ToStr(m_pluginServices->GetCurrentDeviceState());
155+
pid_t pid = getpid();
156+
152157
response->set_state(state);
158+
response->set_pid(pid);
153159

154160
return grpc::Status::OK;
155161
}
@@ -230,4 +236,3 @@ OccPluginServer::Transition(grpc::ServerContext* context,
230236

231237
return grpc::Status::OK;
232238
}
233-

occ/plugin/litestructs/GetState.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ bool OccLite::nopb::GetStateResponse::Serialize(rapidjson::Writer<rapidjson::Str
3131
writer->String("state");
3232
writer->String(state);
3333

34+
writer->String("pid");
35+
writer->Int(pid);
36+
3437
writer->EndObject();
3538
return true;
3639
}
3740

3841
bool OccLite::nopb::GetStateResponse::Deserialize(const rapidjson::Value& obj)
3942
{
4043
state = obj["state"].GetString();
44+
pid = obj["pid"].GetInt();
4145
return true;
4246
}
4347

occ/plugin/litestructs/GetState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct GetStateRequest : public JsonMessage
4646
struct GetStateResponse : public JsonMessage
4747
{
4848
std::string state;
49+
int pid;
4950

5051
bool Serialize(rapidjson::Writer<rapidjson::StringBuffer>* writer) const override;
5152
bool Deserialize(const rapidjson::Value& obj) override;

occ/protos/occ.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ message EventStreamReply {
7474
message GetStateRequest {}
7575
message GetStateReply {
7676
string state = 1;
77+
int32 pid = 2;
7778
}
7879

7980
message ConfigEntry {

0 commit comments

Comments
 (0)