Skip to content

Commit

Permalink
Initialize Local Request ID to Empty String (triton-inference-server#…
Browse files Browse the repository at this point in the history
…4900)

* Default initialization for request_id to empty string

* Use string compare

* Remove redundant check

* Remove extra parentheses

Co-authored-by: Ryan McCormick <rmccormick@nvidia.com>

* Remove extra parentheses

Co-authored-by: Ryan McCormick <rmccormick@nvidia.com>

* Remove extra parentheses

Co-authored-by: Ryan McCormick <rmccormick@nvidia.com>

Co-authored-by: Ryan McCormick <rmccormick@nvidia.com>
  • Loading branch information
dyastremsky and rmccorm4 committed Sep 20, 2022
1 parent 5e258d6 commit c8e1384
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/grpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3956,14 +3956,14 @@ ModelInferHandler::Process(InferHandler::State* state, bool rpc_ok)
InferResponseComplete, reinterpret_cast<void*>(state));
}
// Get request ID for logging in case of error.
const char* request_id = nullptr;
const char* request_id = "";
if (irequest != nullptr) {
LOG_TRITONSERVER_ERROR(
TRITONSERVER_InferenceRequestId(irequest, &request_id),
"unable to retrieve request ID string");
}

if ((request_id == nullptr) || (request_id[0] == '\0')) {
if (!strncmp(request_id, "", 1)) {
request_id = "<id_unknown>";
}
if (err == nullptr) {
Expand Down Expand Up @@ -4387,11 +4387,11 @@ ModelStreamInferHandler::Process(InferHandler::State* state, bool rpc_ok)
StreamInferResponseComplete, reinterpret_cast<void*>(state));
}
// Get request ID for logging in case of error.
const char* request_id = nullptr;
const char* request_id = "";
LOG_TRITONSERVER_ERROR(
TRITONSERVER_InferenceRequestId(irequest, &request_id),
"unable to retrieve request ID string");
if ((request_id == nullptr) || (request_id[0] == '\0')) {
if (!strncmp(request_id, "", 1)) {
request_id = "<id_unknown>";
}
if (err == nullptr) {
Expand Down
8 changes: 4 additions & 4 deletions src/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ HTTPAPIServer::HandleInfer(
err = GetInferenceHeaderLength(req, content_length, &header_length);
}
}
const char* request_id = nullptr;
const char* request_id = "";

if (err == nullptr) {
connection_paused = true;
Expand Down Expand Up @@ -2883,7 +2883,7 @@ HTTPAPIServer::HandleInfer(
LOG_TRITONSERVER_ERROR(
TRITONSERVER_InferenceRequestId(irequest, &request_id),
"unable to retrieve request ID string");
if ((request_id == nullptr) || (request_id[0] == '\0')) {
if (!strncmp(request_id, "", 1)) {
request_id = "<id_unknown>";
}
if (err == nullptr) {
Expand Down Expand Up @@ -3065,9 +3065,9 @@ HTTPAPIServer::InferRequestClass::FinalizeResponse(
triton::common::TritonJson::Value response_json(
triton::common::TritonJson::ValueType::OBJECT);

const char* request_id = nullptr;
const char* request_id = "";
RETURN_IF_ERR(TRITONSERVER_InferenceResponseId(response, &request_id));
if ((request_id != nullptr) && (request_id[0] != '\0')) {
if (strncmp(request_id, "", 1)) {
RETURN_IF_ERR(response_json.AddStringRef("id", request_id));
}

Expand Down

0 comments on commit c8e1384

Please sign in to comment.