From f852c060384027ae1c82b1ea5d8dae62c9c5ea3c Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 17 Nov 2017 16:50:12 -0800 Subject: [PATCH] Fix TSAN attempt --- src/core/lib/transport/error_utils.cc | 9 ++++++--- src/core/lib/transport/error_utils.h | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index 723663a6d78..acac1330b56 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -43,7 +43,7 @@ static grpc_error* recursively_find_error_with_field(grpc_error* error, void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, grpc_millis deadline, grpc_status_code* code, grpc_slice* slice, grpc_http2_error_code* http_error, - const char** full_error_details) { + const char** error_string) { // Start with the parent error and recurse through the tree of children // until we find the first one that has a status code. grpc_error* found_error = @@ -70,8 +70,11 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, } if (code != nullptr) *code = status; - if (full_error_details != NULL && status != GRPC_STATUS_OK) { - *full_error_details = gpr_strdup(grpc_error_string(error)); + if (error_string != NULL && status != GRPC_STATUS_OK) { + const char* str = grpc_error_string(error); + if (str != nullptr) { + *error_string = gpr_strdup(str); + } } if (http_error != nullptr) { diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h index d47c4f2a3be..6f21f484e5c 100644 --- a/src/core/lib/transport/error_utils.h +++ b/src/core/lib/transport/error_utils.h @@ -30,15 +30,15 @@ extern "C" { /// A utility function to get the status code and message to be returned /// to the application. If not set in the top-level message, looks /// through child errors until it finds the first one with these attributes. -/// All attributes are pulled from the same child error. full_error_details will +/// All attributes are pulled from the same child error. error_string will /// be populated with the entire error string. If any of the attributes (code, -/// msg, http_status, full_error_details) are unneeded, they can be passed as +/// msg, http_status, error_string) are unneeded, they can be passed as /// NULL. void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, grpc_millis deadline, grpc_status_code* code, grpc_slice* slice, grpc_http2_error_code* http_status, - const char** full_error_details); + const char** error_string); /// A utility function to check whether there is a clear status code that /// doesn't need to be guessed in \a error. This means that \a error or some