Skip to content

Commit

Permalink
Return Unavailable status if not able to parse request (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
ni-sujain authored May 8, 2023
1 parent 8de8fb6 commit 058070d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/event_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,19 @@ namespace grpc_labview
auto responseMetadata = _server->FindMetadata(eventData.responseMetadataName);
_request = std::make_shared<LVMessage>(requestMetadata);
_response = std::make_shared<LVMessage>(responseMetadata);
_request->ParseFromByteBuffer(_rb);
_requestDataReady = true;

_methodData = std::make_shared<GenericMethodData>(this, &_ctx, _request, _response);
gPointerManager.RegisterPointer(_methodData);
_server->SendEvent(name, static_cast<gRPCid*>(_methodData.get()));
if (_request->ParseFromByteBuffer(_rb))
{
_requestDataReady = true;
_methodData = std::make_shared<GenericMethodData>(this, &_ctx, _request, _response);
gPointerManager.RegisterPointer(_methodData);
_server->SendEvent(name, static_cast<gRPCid*>(_methodData.get()));
}
else
{
_status = CallStatus::Finish;
_stream.Finish(grpc::Status(grpc::StatusCode::UNAVAILABLE, ""), this);
}
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions src/lv_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ namespace grpc_labview
}
else
{
if (tag == 0 || WireFormatLite::GetTagWireType(tag) == WireFormatLite::WIRETYPE_END_GROUP) {
ctx->SetLastTag(tag);
return ptr;
}
ptr = UnknownFieldParse(tag, &_unknownFields, ptr, ctx);
assert(ptr != nullptr);
}
Expand Down

0 comments on commit 058070d

Please sign in to comment.