Skip to content

Commit 5fdf0b2

Browse files
authored
NO_MODULE_PARENT fix (#516)
1 parent d7781f3 commit 5fdf0b2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/viam/sdk/common/private/service_helper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ class ServiceHelper : public ServiceHelperBase {
9999
}
100100

101101
ResourceServer* rs_;
102-
const ::grpc::ServerContext* context_;
102+
const GrpcServerContext* context_;
103103
RequestType* request_;
104104
};
105105

106106
template <typename ServiceType, typename RequestType>
107107
auto make_service_helper(const char* method,
108108
ResourceServer* rs,
109-
::grpc::ServerContext* context,
109+
GrpcServerContext* context,
110110
RequestType* request) {
111111
return ServiceHelper<ServiceType, RequestType>{method, rs, context, request};
112112
}

src/viam/sdk/module/service.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <string>
1717

1818
#include <boost/none.hpp>
19+
#include <boost/utility/string_ref.hpp>
1920
#include <google/protobuf/descriptor.h>
2021
#include <grpcpp/channel.h>
2122
#include <grpcpp/create_channel.h>
@@ -209,9 +210,15 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
209210
const viam::module::v1::HandlerMap hm = to_proto(parent.module_->handles());
210211
*response->mutable_handlermap() = hm;
211212

212-
const char* no_module_parent =
213-
std::getenv("VIAM_NO_MODULE_PARENT"); // NOLINT(concurrency-mt-unsafe)
214-
if (strcmp(no_module_parent, "true") != 0) {
213+
// Using string_ref is more verbose but I think more readable than strcmp
214+
boost::string_ref no_module_parent;
215+
216+
if (const char* envp =
217+
std::getenv("VIAM_NO_MODULE_PARENT")) { // NOLINT(concurrency-mt-unsafe)
218+
no_module_parent = envp;
219+
}
220+
221+
if (no_module_parent != "true") {
215222
auto new_parent_addr = parent.grpc_conn_protocol_ + request->parent_address();
216223
if (parent.parent_addr_ != new_parent_addr) {
217224
parent.parent_addr_ = std::move(new_parent_addr);

0 commit comments

Comments
 (0)