diff options
Diffstat (limited to 'src/core/lib/transport')
20 files changed, 149 insertions, 239 deletions
diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index e09ae8e6a6..bb0e583045 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -23,8 +23,7 @@ #include <grpc/support/useful.h> -grpc_tracer_flag grpc_bdp_estimator_trace = - GRPC_TRACER_INITIALIZER(false, "bdp_estimator"); +grpc_core::TraceFlag grpc_bdp_estimator_trace(false, "bdp_estimator"); namespace grpc_core { @@ -44,7 +43,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) { double dt = (double)dt_ts.tv_sec + 1e-9 * (double)dt_ts.tv_nsec; double bw = dt > 0 ? ((double)accumulator_ / dt) : 0; int start_inter_ping_delay = inter_ping_delay_; - if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64 " dt=%lf bw=%lfMbs bw_est=%lfMbs", @@ -55,7 +54,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) { if (accumulator_ > 2 * estimate_ / 3 && bw > bw_est_) { estimate_ = GPR_MAX(accumulator_, estimate_ * 2); bw_est_ = bw; - if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64, name_, estimate_); } @@ -72,7 +71,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) { } if (start_inter_ping_delay != inter_ping_delay_) { stable_estimate_count_ = 0; - if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "bdp[%s]:update_inter_time to %dms", name_, inter_ping_delay_); } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index f7b94a81d3..df3a86c5f1 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -31,7 +31,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" -extern grpc_tracer_flag grpc_bdp_estimator_trace; +extern grpc_core::TraceFlag grpc_bdp_estimator_trace; namespace grpc_core { @@ -49,7 +49,7 @@ class BdpEstimator { // grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a // transport (but not necessarily started) void SchedulePing() { - if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_, accumulator_, estimate_); } @@ -62,7 +62,7 @@ class BdpEstimator { // once // the ping is on the wire void StartPing() { - if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + if (grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_, accumulator_, estimate_); } diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index 54ad4b9796..6bca154cb5 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -28,10 +28,6 @@ /** Mask of all valid internal flags. */ #define GRPC_WRITE_INTERNAL_USED_MASK (GRPC_WRITE_INTERNAL_COMPRESS) -#ifdef __cplusplus -extern "C" { -#endif - typedef struct grpc_byte_stream grpc_byte_stream; typedef struct { @@ -139,8 +135,4 @@ void grpc_caching_byte_stream_init(grpc_caching_byte_stream* stream, // Resets the byte stream to the start of the underlying stream. void grpc_caching_byte_stream_reset(grpc_caching_byte_stream* stream); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index bdaf0243f9..e7e5dbd1f1 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -24,8 +24,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> -grpc_tracer_flag grpc_connectivity_state_trace = - GRPC_TRACER_INITIALIZER(false, "connectivity_state"); +grpc_core::TraceFlag grpc_connectivity_state_trace(false, "connectivity_state"); const char* grpc_connectivity_state_name(grpc_connectivity_state state) { switch (state) { @@ -48,7 +47,7 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker, const char* name) { gpr_atm_no_barrier_store(&tracker->current_state_atm, init_state); tracker->current_error = GRPC_ERROR_NONE; - tracker->watchers = NULL; + tracker->watchers = nullptr; tracker->name = gpr_strdup(name); } @@ -78,7 +77,7 @@ grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state cur = (grpc_connectivity_state)gpr_atm_no_barrier_load( &tracker->current_state_atm); - if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) { + if (grpc_connectivity_state_trace.enabled()) { gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name, grpc_connectivity_state_name(cur)); } @@ -90,11 +89,11 @@ grpc_connectivity_state grpc_connectivity_state_get( grpc_connectivity_state cur = (grpc_connectivity_state)gpr_atm_no_barrier_load( &tracker->current_state_atm); - if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) { + if (grpc_connectivity_state_trace.enabled()) { gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name, grpc_connectivity_state_name(cur)); } - if (error != NULL) { + if (error != nullptr) { *error = GRPC_ERROR_REF(tracker->current_error); } return cur; @@ -102,7 +101,7 @@ grpc_connectivity_state grpc_connectivity_state_get( bool grpc_connectivity_state_has_watchers( grpc_connectivity_state_tracker* connectivity_state) { - return connectivity_state->watchers != NULL; + return connectivity_state->watchers != nullptr; } bool grpc_connectivity_state_notify_on_state_change( @@ -111,8 +110,8 @@ bool grpc_connectivity_state_notify_on_state_change( grpc_connectivity_state cur = (grpc_connectivity_state)gpr_atm_no_barrier_load( &tracker->current_state_atm); - if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) { - if (current == NULL) { + if (grpc_connectivity_state_trace.enabled()) { + if (current == nullptr) { gpr_log(GPR_DEBUG, "CONWATCH: %p %s: unsubscribe notify=%p", tracker, tracker->name, notify); } else { @@ -121,17 +120,17 @@ bool grpc_connectivity_state_notify_on_state_change( grpc_connectivity_state_name(cur), notify); } } - if (current == NULL) { + if (current == nullptr) { grpc_connectivity_state_watcher* w = tracker->watchers; - if (w != NULL && w->notify == notify) { + if (w != nullptr && w->notify == notify) { GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED); tracker->watchers = w->next; gpr_free(w); return false; } - while (w != NULL) { + while (w != nullptr) { grpc_connectivity_state_watcher* rm_candidate = w->next; - if (rm_candidate != NULL && rm_candidate->notify == notify) { + if (rm_candidate != nullptr && rm_candidate->notify == notify) { GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED); w->next = w->next->next; gpr_free(rm_candidate); @@ -165,7 +164,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx, (grpc_connectivity_state)gpr_atm_no_barrier_load( &tracker->current_state_atm); grpc_connectivity_state_watcher* w; - if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) { + if (grpc_connectivity_state_trace.enabled()) { const char* error_string = grpc_error_string(error); gpr_log(GPR_DEBUG, "SET: %p %s: %s --> %s [%s] error=%p %s", tracker, tracker->name, grpc_connectivity_state_name(cur), @@ -189,10 +188,10 @@ void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx, } GPR_ASSERT(cur != GRPC_CHANNEL_SHUTDOWN); gpr_atm_no_barrier_store(&tracker->current_state_atm, state); - while ((w = tracker->watchers) != NULL) { + while ((w = tracker->watchers) != nullptr) { *w->current = state; tracker->watchers = w->next; - if (GRPC_TRACER_ON(grpc_connectivity_state_trace)) { + if (grpc_connectivity_state_trace.enabled()) { gpr_log(GPR_DEBUG, "NOTIFY: %p %s: %p", tracker, tracker->name, w->notify); } diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 792e27c43d..653637ebea 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -23,10 +23,6 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct grpc_connectivity_state_watcher { /** we keep watchers in a linked list */ struct grpc_connectivity_state_watcher* next; @@ -47,7 +43,7 @@ typedef struct { char* name; } grpc_connectivity_state_tracker; -extern grpc_tracer_flag grpc_connectivity_state_trace; +extern grpc_core::TraceFlag grpc_connectivity_state_trace; /** enum --> string conversion */ const char* grpc_connectivity_state_name(grpc_connectivity_state state); @@ -88,8 +84,4 @@ bool grpc_connectivity_state_notify_on_state_change( grpc_exec_ctx* exec_ctx, grpc_connectivity_state_tracker* tracker, grpc_connectivity_state* current, grpc_closure* notify); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index d968b04fd8..69c8ae6de3 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -18,16 +18,17 @@ #include "src/core/lib/transport/error_utils.h" +#include <grpc/support/string_util.h> #include "src/core/lib/iomgr/error_internal.h" #include "src/core/lib/transport/status_conversion.h" static grpc_error* recursively_find_error_with_field(grpc_error* error, grpc_error_ints which) { // If the error itself has a status code, return it. - if (grpc_error_get_int(error, which, NULL)) { + if (grpc_error_get_int(error, which, nullptr)) { return error; } - if (grpc_error_is_special(error)) return NULL; + if (grpc_error_is_special(error)) return nullptr; // Otherwise, search through its children. uint8_t slot = error->first_err; while (slot != UINT8_MAX) { @@ -36,18 +37,18 @@ static grpc_error* recursively_find_error_with_field(grpc_error* error, if (result) return result; slot = lerr->next; } - return NULL; + return nullptr; } 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) { + grpc_slice* slice, grpc_http2_error_code* http_error, + 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 = recursively_find_error_with_field(error, GRPC_ERROR_INT_GRPC_STATUS); - if (found_error == NULL) { + if (found_error == nullptr) { /// If no grpc-status exists, retry through the tree to find a http2 error /// code found_error = @@ -56,7 +57,7 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, // If we found an error with a status code above, use that; otherwise, // fall back to using the parent error. - if (found_error == NULL) found_error = error; + if (found_error == nullptr) found_error = error; grpc_status_code status = GRPC_STATUS_UNKNOWN; intptr_t integer; @@ -67,9 +68,13 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, status = grpc_http2_error_to_grpc_status( exec_ctx, (grpc_http2_error_code)integer, deadline); } - if (code != NULL) *code = status; + if (code != nullptr) *code = status; - if (http_error != NULL) { + if (error_string != NULL && status != GRPC_STATUS_OK) { + *error_string = gpr_strdup(grpc_error_string(error)); + } + + if (http_error != nullptr) { if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR, &integer)) { *http_error = (grpc_http2_error_code)integer; } else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_GRPC_STATUS, @@ -83,19 +88,17 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, // If the error has a status message, use it. Otherwise, fall back to // the error description. - if (slice != NULL) { + if (slice != nullptr) { if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_GRPC_MESSAGE, slice)) { if (!grpc_error_get_str(found_error, GRPC_ERROR_STR_DESCRIPTION, slice)) { *slice = grpc_slice_from_static_string("unknown error"); } } } - - if (found_error == NULL) found_error = error; } bool grpc_error_has_clear_grpc_status(grpc_error* error) { - if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, NULL)) { + if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, nullptr)) { return true; } uint8_t slot = error->first_err; diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h index 690e42058a..8b006ae992 100644 --- a/src/core/lib/transport/error_utils.h +++ b/src/core/lib/transport/error_utils.h @@ -23,20 +23,18 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" -#ifdef __cplusplus -extern "C" { -#endif - /// 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. If any of the -/// attributes (code, msg, http_status) are unneeded, they can be passed as +/// 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, 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); + grpc_http2_error_code* http_status, + 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 @@ -44,8 +42,4 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error, /// GRPC_ERROR_CANCELLED bool grpc_error_has_clear_grpc_status(grpc_error* error); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */ diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index ff11ddec13..0f30c7533d 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -48,9 +48,9 @@ * used to determine which kind of element a pointer refers to. */ +grpc_core::DebugOnlyTraceFlag grpc_trace_metadata(false, "metadata"); + #ifndef NDEBUG -grpc_tracer_flag grpc_trace_metadata = - GRPC_TRACER_INITIALIZER(false, "metadata"); #define DEBUG_ARGS , const char *file, int line #define FWD_DEBUG_ARGS , file, line #define REF_MD_LOCKED(shard, s) ref_md_locked((shard), (s), __FILE__, __LINE__) @@ -149,7 +149,7 @@ static int is_mdelem_static(grpc_mdelem e) { static void ref_md_locked(mdtab_shard* shard, interned_metadata* md DEBUG_ARGS) { #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(md->key); char* value_str = grpc_slice_to_c_string(md->value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -241,7 +241,7 @@ grpc_mdelem grpc_mdelem_create( grpc_exec_ctx* exec_ctx, grpc_slice key, grpc_slice value, grpc_mdelem_data* compatible_external_backing_store) { if (!grpc_slice_is_interned(key) || !grpc_slice_is_interned(value)) { - if (compatible_external_backing_store != NULL) { + if (compatible_external_backing_store != nullptr) { return GRPC_MAKE_MDELEM(compatible_external_backing_store, GRPC_MDELEM_STORAGE_EXTERNAL); } @@ -252,7 +252,7 @@ grpc_mdelem grpc_mdelem_create( allocated->value = grpc_slice_ref_internal(value); gpr_atm_rel_store(&allocated->refcnt, 1); #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(allocated->key); char* value_str = grpc_slice_to_c_string(allocated->value); gpr_log(GPR_DEBUG, "ELM ALLOC:%p:%" PRIdPTR ": '%s' = '%s'", @@ -306,7 +306,7 @@ grpc_mdelem grpc_mdelem_create( shard->elems[idx] = md; gpr_mu_init(&md->mu_user_data); #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(md->key); char* value_str = grpc_slice_to_c_string(md->value); gpr_log(GPR_DEBUG, "ELM NEW:%p:%" PRIdPTR ": '%s' = '%s'", (void*)md, @@ -330,7 +330,7 @@ grpc_mdelem grpc_mdelem_create( grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx* exec_ctx, grpc_slice key, grpc_slice value) { - grpc_mdelem out = grpc_mdelem_create(exec_ctx, key, value, NULL); + grpc_mdelem out = grpc_mdelem_create(exec_ctx, key, value, nullptr); grpc_slice_unref_internal(exec_ctx, key); grpc_slice_unref_internal(exec_ctx, value); return out; @@ -344,7 +344,7 @@ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx* exec_ctx, grpc_slice value_slice = grpc_slice_maybe_static_intern(metadata->value, &changed); return grpc_mdelem_create(exec_ctx, key_slice, value_slice, - changed ? NULL : (grpc_mdelem_data*)metadata); + changed ? nullptr : (grpc_mdelem_data*)metadata); } static size_t get_base64_encoded_size(size_t raw_length) { @@ -373,7 +373,7 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) { case GRPC_MDELEM_STORAGE_INTERNED: { interned_metadata* md = (interned_metadata*)GRPC_MDELEM_DATA(gmd); #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(md->key); char* value_str = grpc_slice_to_c_string(md->value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -395,7 +395,7 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) { case GRPC_MDELEM_STORAGE_ALLOCATED: { allocated_metadata* md = (allocated_metadata*)GRPC_MDELEM_DATA(gmd); #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(md->key); char* value_str = grpc_slice_to_c_string(md->value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -425,7 +425,7 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem gmd DEBUG_ARGS) { case GRPC_MDELEM_STORAGE_INTERNED: { interned_metadata* md = (interned_metadata*)GRPC_MDELEM_DATA(gmd); #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(md->key); char* value_str = grpc_slice_to_c_string(md->value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -451,7 +451,7 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem gmd DEBUG_ARGS) { case GRPC_MDELEM_STORAGE_ALLOCATED: { allocated_metadata* md = (allocated_metadata*)GRPC_MDELEM_DATA(gmd); #ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_metadata)) { + if (grpc_trace_metadata.enabled()) { char* key_str = grpc_slice_to_c_string(md->key); char* value_str = grpc_slice_to_c_string(md->value); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -478,7 +478,7 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) { switch (GRPC_MDELEM_STORAGE(md)) { case GRPC_MDELEM_STORAGE_EXTERNAL: case GRPC_MDELEM_STORAGE_ALLOCATED: - return NULL; + return nullptr; case GRPC_MDELEM_STORAGE_STATIC: return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) - grpc_static_mdelem_table]; @@ -488,12 +488,12 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) { if (gpr_atm_acq_load(&im->destroy_user_data) == (gpr_atm)destroy_func) { return (void*)gpr_atm_no_barrier_load(&im->user_data); } else { - return NULL; + return nullptr; } return result; } } - GPR_UNREACHABLE_CODE(return NULL); + GPR_UNREACHABLE_CODE(return nullptr); } void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), @@ -502,7 +502,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), case GRPC_MDELEM_STORAGE_EXTERNAL: case GRPC_MDELEM_STORAGE_ALLOCATED: destroy_func(user_data); - return NULL; + return nullptr; case GRPC_MDELEM_STORAGE_STATIC: destroy_func(user_data); return (void*)grpc_static_mdelem_user_data[GRPC_MDELEM_DATA(md) - @@ -510,12 +510,12 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), case GRPC_MDELEM_STORAGE_INTERNED: { interned_metadata* im = (interned_metadata*)GRPC_MDELEM_DATA(md); GPR_ASSERT(!is_mdelem_static(md)); - GPR_ASSERT((user_data == NULL) == (destroy_func == NULL)); + GPR_ASSERT((user_data == nullptr) == (destroy_func == nullptr)); gpr_mu_lock(&im->mu_user_data); if (gpr_atm_no_barrier_load(&im->destroy_user_data)) { /* user data can only be set once */ gpr_mu_unlock(&im->mu_user_data); - if (destroy_func != NULL) { + if (destroy_func != nullptr) { destroy_func(user_data); } return (void*)gpr_atm_no_barrier_load(&im->user_data); @@ -526,7 +526,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), return user_data; } } - GPR_UNREACHABLE_CODE(return NULL); + GPR_UNREACHABLE_CODE(return nullptr); } bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b) { diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 7e7e7b4c14..8d4868d031 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -25,13 +25,7 @@ #include "src/core/lib/iomgr/exec_ctx.h" -#ifndef NDEBUG -extern grpc_tracer_flag grpc_trace_metadata; -#endif - -#ifdef __cplusplus -extern "C" { -#endif +extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata; /* This file provides a mechanism for tracking metadata through the grpc stack. It's not intended for consumption outside of the library. @@ -170,8 +164,4 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem md); void grpc_mdctx_global_init(void); void grpc_mdctx_global_shutdown(grpc_exec_ctx* exec_ctx); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */ diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc index 90e84cd1e2..5817765aa3 100644 --- a/src/core/lib/transport/metadata_batch.cc +++ b/src/core/lib/transport/metadata_batch.cc @@ -32,17 +32,17 @@ static void assert_valid_list(grpc_mdelem_list* list) { #ifndef NDEBUG grpc_linked_mdelem* l; - GPR_ASSERT((list->head == NULL) == (list->tail == NULL)); + GPR_ASSERT((list->head == nullptr) == (list->tail == nullptr)); if (!list->head) return; - GPR_ASSERT(list->head->prev == NULL); - GPR_ASSERT(list->tail->next == NULL); - GPR_ASSERT((list->head == list->tail) == (list->head->next == NULL)); + GPR_ASSERT(list->head->prev == nullptr); + GPR_ASSERT(list->tail->next == nullptr); + GPR_ASSERT((list->head == list->tail) == (list->head->next == nullptr)); size_t verified_count = 0; for (l = list->head; l; l = l->next) { GPR_ASSERT(!GRPC_MDISNULL(l->md)); - GPR_ASSERT((l->prev == NULL) == (l == list->head)); - GPR_ASSERT((l->next == NULL) == (l == list->tail)); + GPR_ASSERT((l->prev == nullptr) == (l == list->head)); + GPR_ASSERT((l->next == nullptr) == (l == list->tail)); if (l->next) GPR_ASSERT(l->next->prev == l); if (l->prev) GPR_ASSERT(l->prev->next == l); verified_count++; @@ -54,7 +54,7 @@ static void assert_valid_list(grpc_mdelem_list* list) { static void assert_valid_callouts(grpc_exec_ctx* exec_ctx, grpc_metadata_batch* batch) { #ifndef NDEBUG - for (grpc_linked_mdelem* l = batch->list.head; l != NULL; l = l->next) { + for (grpc_linked_mdelem* l = batch->list.head; l != nullptr; l = l->next) { grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md)); grpc_metadata_batch_callouts_index callout_idx = GRPC_BATCH_INDEX_OF(key_interned); @@ -104,7 +104,7 @@ static grpc_error* maybe_link_callout(grpc_metadata_batch* batch, if (idx == GRPC_BATCH_CALLOUTS_COUNT) { return GRPC_ERROR_NONE; } - if (batch->idx.array[idx] == NULL) { + if (batch->idx.array[idx] == nullptr) { if (grpc_static_callout_is_default[idx]) ++batch->list.default_count; batch->idx.array[idx] = storage; return GRPC_ERROR_NONE; @@ -122,8 +122,8 @@ static void maybe_unlink_callout(grpc_metadata_batch* batch, return; } if (grpc_static_callout_is_default[idx]) --batch->list.default_count; - GPR_ASSERT(batch->idx.array[idx] != NULL); - batch->idx.array[idx] = NULL; + GPR_ASSERT(batch->idx.array[idx] != nullptr); + batch->idx.array[idx] = nullptr; } grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx, @@ -138,9 +138,9 @@ grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx, static void link_head(grpc_mdelem_list* list, grpc_linked_mdelem* storage) { assert_valid_list(list); GPR_ASSERT(!GRPC_MDISNULL(storage->md)); - storage->prev = NULL; + storage->prev = nullptr; storage->next = list->head; - if (list->head != NULL) { + if (list->head != nullptr) { list->head->prev = storage; } else { list->tail = storage; @@ -177,9 +177,9 @@ static void link_tail(grpc_mdelem_list* list, grpc_linked_mdelem* storage) { assert_valid_list(list); GPR_ASSERT(!GRPC_MDISNULL(storage->md)); storage->prev = list->tail; - storage->next = NULL; - storage->reserved = NULL; - if (list->tail != NULL) { + storage->next = nullptr; + storage->reserved = nullptr; + if (list->tail != nullptr) { list->tail->next = storage; } else { list->head = storage; @@ -206,12 +206,12 @@ grpc_error* grpc_metadata_batch_link_tail(grpc_exec_ctx* exec_ctx, static void unlink_storage(grpc_mdelem_list* list, grpc_linked_mdelem* storage) { assert_valid_list(list); - if (storage->prev != NULL) { + if (storage->prev != nullptr) { storage->prev->next = storage->next; } else { list->head = storage->next; } - if (storage->next != NULL) { + if (storage->next != nullptr) { storage->next->prev = storage->prev; } else { list->tail = storage->prev; @@ -270,12 +270,13 @@ void grpc_metadata_batch_clear(grpc_exec_ctx* exec_ctx, } bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch) { - return batch->list.head == NULL && batch->deadline == GRPC_MILLIS_INF_FUTURE; + return batch->list.head == nullptr && + batch->deadline == GRPC_MILLIS_INF_FUTURE; } size_t grpc_metadata_batch_size(grpc_metadata_batch* batch) { size_t size = 0; - for (grpc_linked_mdelem* elem = batch->list.head; elem != NULL; + for (grpc_linked_mdelem* elem = batch->list.head; elem != nullptr; elem = elem->next) { size += GRPC_MDELEM_LENGTH(elem->md); } diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 7d17393249..adfb2d8069 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -28,10 +28,6 @@ #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct grpc_linked_mdelem { grpc_mdelem md; struct grpc_linked_mdelem* next; @@ -146,8 +142,4 @@ void grpc_metadata_batch_assert_ok(grpc_metadata_batch* comd); } while (0) #endif -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H */ diff --git a/src/core/lib/transport/service_config.cc b/src/core/lib/transport/service_config.cc index 05907de7d7..adcec8c444 100644 --- a/src/core/lib/transport/service_config.cc +++ b/src/core/lib/transport/service_config.cc @@ -64,11 +64,11 @@ grpc_service_config* grpc_service_config_create(const char* json_string) { service_config->json_string = gpr_strdup(json_string); service_config->json_tree = grpc_json_parse_string(service_config->json_string); - if (service_config->json_tree == NULL) { + if (service_config->json_tree == nullptr) { gpr_log(GPR_INFO, "failed to parse JSON for service config"); gpr_free(service_config->json_string); gpr_free(service_config); - return NULL; + return nullptr; } return service_config; } @@ -83,9 +83,9 @@ void grpc_service_config_parse_global_params( const grpc_service_config* service_config, void (*process_json)(const grpc_json* json, void* arg), void* arg) { const grpc_json* json = service_config->json_tree; - if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return; - for (grpc_json* field = json->child; field != NULL; field = field->next) { - if (field->key == NULL) return; + if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return; + for (grpc_json* field = json->child; field != nullptr; field = field->next) { + if (field->key == nullptr) return; if (strcmp(field->key, "methodConfig") == 0) continue; process_json(field, arg); } @@ -94,13 +94,13 @@ void grpc_service_config_parse_global_params( const char* grpc_service_config_get_lb_policy_name( const grpc_service_config* service_config) { const grpc_json* json = service_config->json_tree; - if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; - const char* lb_policy_name = NULL; - for (grpc_json* field = json->child; field != NULL; field = field->next) { - if (field->key == NULL) return NULL; + if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr; + const char* lb_policy_name = nullptr; + for (grpc_json* field = json->child; field != nullptr; field = field->next) { + if (field->key == nullptr) return nullptr; if (strcmp(field->key, "loadBalancingPolicy") == 0) { - if (lb_policy_name != NULL) return NULL; // Duplicate. - if (field->type != GRPC_JSON_STRING) return NULL; + if (lb_policy_name != nullptr) return nullptr; // Duplicate. + if (field->type != GRPC_JSON_STRING) return nullptr; lb_policy_name = field->value; } } @@ -110,10 +110,10 @@ const char* grpc_service_config_get_lb_policy_name( // Returns the number of names specified in the method config \a json. static size_t count_names_in_method_config_json(grpc_json* json) { size_t num_names = 0; - for (grpc_json* field = json->child; field != NULL; field = field->next) { - if (field->key != NULL && strcmp(field->key, "name") == 0) { + for (grpc_json* field = json->child; field != nullptr; field = field->next) { + if (field->key != nullptr && strcmp(field->key, "name") == 0) { if (field->type != GRPC_JSON_ARRAY) return -1; - for (grpc_json* name = field->child; name != NULL; name = name->next) { + for (grpc_json* name = field->child; name != nullptr; name = name->next) { if (name->type != GRPC_JSON_OBJECT) return -1; ++num_names; } @@ -125,26 +125,26 @@ static size_t count_names_in_method_config_json(grpc_json* json) { // Returns a path string for the JSON name object specified by \a json. // Returns NULL on error. Caller takes ownership of result. static char* parse_json_method_name(grpc_json* json) { - if (json->type != GRPC_JSON_OBJECT) return NULL; - const char* service_name = NULL; - const char* method_name = NULL; - for (grpc_json* child = json->child; child != NULL; child = child->next) { - if (child->key == NULL) return NULL; - if (child->type != GRPC_JSON_STRING) return NULL; + if (json->type != GRPC_JSON_OBJECT) return nullptr; + const char* service_name = nullptr; + const char* method_name = nullptr; + for (grpc_json* child = json->child; child != nullptr; child = child->next) { + if (child->key == nullptr) return nullptr; + if (child->type != GRPC_JSON_STRING) return nullptr; if (strcmp(child->key, "service") == 0) { - if (service_name != NULL) return NULL; // Duplicate. - if (child->value == NULL) return NULL; + if (service_name != nullptr) return nullptr; // Duplicate. + if (child->value == nullptr) return nullptr; service_name = child->value; } else if (strcmp(child->key, "method") == 0) { - if (method_name != NULL) return NULL; // Duplicate. - if (child->value == NULL) return NULL; + if (method_name != nullptr) return nullptr; // Duplicate. + if (child->value == nullptr) return nullptr; method_name = child->value; } } - if (service_name == NULL) return NULL; // Required field. + if (service_name == nullptr) return nullptr; // Required field. char* path; gpr_asprintf(&path, "/%s/%s", service_name, - method_name == NULL ? "*" : method_name); + method_name == nullptr ? "*" : method_name); return path; } @@ -159,18 +159,18 @@ static bool parse_json_method_config( grpc_slice_hash_table_entry* entries, size_t* idx) { // Construct value. void* method_config = create_value(json); - if (method_config == NULL) return false; + if (method_config == nullptr) return false; // Construct list of paths. bool success = false; gpr_strvec paths; gpr_strvec_init(&paths); - for (grpc_json* child = json->child; child != NULL; child = child->next) { - if (child->key == NULL) continue; + for (grpc_json* child = json->child; child != nullptr; child = child->next) { + if (child->key == nullptr) continue; if (strcmp(child->key, "name") == 0) { if (child->type != GRPC_JSON_ARRAY) goto done; - for (grpc_json* name = child->child; name != NULL; name = name->next) { + for (grpc_json* name = child->child; name != nullptr; name = name->next) { char* path = parse_json_method_name(name); - if (path == NULL) goto done; + if (path == nullptr) goto done; gpr_strvec_add(&paths, path); } } @@ -196,26 +196,26 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table( void (*unref_value)(grpc_exec_ctx* exec_ctx, void* value)) { const grpc_json* json = service_config->json_tree; // Traverse parsed JSON tree. - if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; + if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr; size_t num_entries = 0; - grpc_slice_hash_table_entry* entries = NULL; - for (grpc_json* field = json->child; field != NULL; field = field->next) { - if (field->key == NULL) return NULL; + grpc_slice_hash_table_entry* entries = nullptr; + for (grpc_json* field = json->child; field != nullptr; field = field->next) { + if (field->key == nullptr) return nullptr; if (strcmp(field->key, "methodConfig") == 0) { - if (entries != NULL) return NULL; // Duplicate. - if (field->type != GRPC_JSON_ARRAY) return NULL; + if (entries != nullptr) return nullptr; // Duplicate. + if (field->type != GRPC_JSON_ARRAY) return nullptr; // Find number of entries. - for (grpc_json* method = field->child; method != NULL; + for (grpc_json* method = field->child; method != nullptr; method = method->next) { size_t count = count_names_in_method_config_json(method); - if (count <= 0) return NULL; + if (count <= 0) return nullptr; num_entries += count; } // Populate method config table entries. entries = (grpc_slice_hash_table_entry*)gpr_malloc( num_entries * sizeof(grpc_slice_hash_table_entry)); size_t idx = 0; - for (grpc_json* method = field->child; method != NULL; + for (grpc_json* method = field->child; method != nullptr; method = method->next) { if (!parse_json_method_config(exec_ctx, method, create_value, ref_value, unref_value, entries, &idx)) { @@ -224,17 +224,17 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table( unref_value(exec_ctx, entries[i].value); } gpr_free(entries); - return NULL; + return nullptr; } } GPR_ASSERT(idx == num_entries); } } // Instantiate method config table. - grpc_slice_hash_table* method_config_table = NULL; - if (entries != NULL) { - method_config_table = - grpc_slice_hash_table_create(num_entries, entries, unref_value, NULL); + grpc_slice_hash_table* method_config_table = nullptr; + if (entries != nullptr) { + method_config_table = grpc_slice_hash_table_create(num_entries, entries, + unref_value, nullptr); gpr_free(entries); } return method_config_table; @@ -246,7 +246,7 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx, void* value = grpc_slice_hash_table_get(table, path); // If we didn't find a match for the path, try looking for a wildcard // entry (i.e., change "/service/method" to "/service/*"). - if (value == NULL) { + if (value == nullptr) { char* path_str = grpc_slice_to_c_string(path); const char* sep = strrchr(path_str, '/') + 1; const size_t len = (size_t)(sep - path_str); diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h index 405d0f5b41..75a290bfd8 100644 --- a/src/core/lib/transport/service_config.h +++ b/src/core/lib/transport/service_config.h @@ -22,10 +22,6 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/slice/slice_hash_table.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct grpc_service_config grpc_service_config; grpc_service_config* grpc_service_config_create(const char* json_string); @@ -64,8 +60,4 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx, const grpc_slice_hash_table* table, grpc_slice path); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index 8e73d5f278..ce3a11b009 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -27,10 +27,6 @@ #ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H #define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H -#ifdef __cplusplus -extern "C" { -#endif - #include "src/core/lib/transport/metadata.h" #define GRPC_STATIC_MDSTR_COUNT 100 @@ -588,7 +584,5 @@ extern const uint8_t grpc_static_accept_stream_encoding_metadata[4]; (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table \ [grpc_static_accept_stream_encoding_metadata[(algs)]], \ GRPC_MDELEM_STORAGE_STATIC)) -#ifdef __cplusplus -} -#endif + #endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */ diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index b6fcebd4fa..3637b82801 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -23,10 +23,6 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" -#ifdef __cplusplus -extern "C" { -#endif - /* Conversion of grpc status codes to http2 error codes (for RST_STREAM) */ grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status); grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx* exec_ctx, @@ -37,8 +33,4 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx* exec_ctx, grpc_status_code grpc_http2_status_to_grpc_status(int status); int grpc_status_to_http2_status(grpc_status_code status); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H */ diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h index 9c3c4599c9..8611f49b00 100644 --- a/src/core/lib/transport/timeout_encoding.h +++ b/src/core/lib/transport/timeout_encoding.h @@ -27,17 +27,9 @@ #define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE (GPR_LTOA_MIN_BUFSIZE + 1) -#ifdef __cplusplus -extern "C" { -#endif - /* Encode/decode timeouts to the GRPC over HTTP/2 format; encoding may round up arbitrarily */ void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer); int grpc_http2_decode_timeout(grpc_slice text, grpc_millis* timeout); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index 021f1b799b..5bda1541a6 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -31,14 +31,12 @@ #include "src/core/lib/support/string.h" #include "src/core/lib/transport/transport_impl.h" -#ifndef NDEBUG -grpc_tracer_flag grpc_trace_stream_refcount = - GRPC_TRACER_INITIALIZER(false, "stream_refcount"); -#endif +grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount(false, + "stream_refcount"); #ifndef NDEBUG void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason) { - if (GRPC_TRACER_ON(grpc_trace_stream_refcount)) { + if (grpc_trace_stream_refcount.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count); gpr_log(GPR_DEBUG, "%s %p:%p REF %" PRIdPTR "->%" PRIdPTR " %s", refcount->object_type, refcount, refcount->destroy.cb_arg, val, @@ -53,7 +51,7 @@ void grpc_stream_ref(grpc_stream_refcount* refcount) { #ifndef NDEBUG void grpc_stream_unref(grpc_exec_ctx* exec_ctx, grpc_stream_refcount* refcount, const char* reason) { - if (GRPC_TRACER_ON(grpc_trace_stream_refcount)) { + if (grpc_trace_stream_refcount.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count); gpr_log(GPR_DEBUG, "%s %p:%p UNREF %" PRIdPTR "->%" PRIdPTR " %s", refcount->object_type, refcount, refcount->destroy.cb_arg, val, @@ -103,7 +101,7 @@ grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount, void* buffer, size_t length) { slice_stream_ref(&refcount->slice_refcount); grpc_slice res; - res.refcount = &refcount->slice_refcount, + res.refcount = &refcount->slice_refcount; res.data.refcounted.bytes = (uint8_t*)buffer; res.data.refcounted.length = length; return res; @@ -184,9 +182,10 @@ void grpc_transport_set_pops(grpc_exec_ctx* exec_ctx, grpc_transport* transport, grpc_polling_entity* pollent) { grpc_pollset* pollset; grpc_pollset_set* pollset_set; - if ((pollset = grpc_polling_entity_pollset(pollent)) != NULL) { + if ((pollset = grpc_polling_entity_pollset(pollent)) != nullptr) { transport->vtable->set_pollset(exec_ctx, transport, stream, pollset); - } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) != NULL) { + } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) != + nullptr) { transport->vtable->set_pollset_set(exec_ctx, transport, stream, pollset_set); } else { diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 973018e5a5..b3cf04c22d 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -31,10 +31,6 @@ #include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/metadata_batch.h" -#ifdef __cplusplus -extern "C" { -#endif - /* forward declarations */ typedef struct grpc_transport grpc_transport; @@ -43,9 +39,7 @@ typedef struct grpc_transport grpc_transport; for a stream. */ typedef struct grpc_stream grpc_stream; -#ifndef NDEBUG -extern grpc_tracer_flag grpc_trace_stream_refcount; -#endif +extern grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount; typedef struct grpc_stream_refcount { gpr_refcount refs; @@ -333,9 +327,6 @@ void grpc_transport_ping(grpc_transport* transport, grpc_closure* cb); void grpc_transport_goaway(grpc_transport* transport, grpc_status_code status, grpc_slice debug_data); -/* Close a transport. Aborts all open streams. */ -void grpc_transport_close(grpc_transport* transport); - /* Destroy the transport */ void grpc_transport_destroy(grpc_exec_ctx* exec_ctx, grpc_transport* transport); @@ -352,8 +343,4 @@ grpc_transport_op* grpc_make_transport_op(grpc_closure* on_consumed); grpc_transport_stream_op_batch* grpc_make_transport_stream_op( grpc_closure* on_consumed); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H */ diff --git a/src/core/lib/transport/transport_impl.h b/src/core/lib/transport/transport_impl.h index 22ad599e2e..46be61427e 100644 --- a/src/core/lib/transport/transport_impl.h +++ b/src/core/lib/transport/transport_impl.h @@ -21,10 +21,6 @@ #include "src/core/lib/transport/transport.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct grpc_transport_vtable { /* Memory required for a single stream element - this is allocated by upper layers and initialized by the transport */ @@ -73,8 +69,4 @@ struct grpc_transport { const grpc_transport_vtable* vtable; }; -#ifdef __cplusplus -} -#endif - #endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc index 24e74c10c5..e69ab02570 100644 --- a/src/core/lib/transport/transport_op_string.cc +++ b/src/core/lib/transport/transport_op_string.cc @@ -47,7 +47,7 @@ static void put_metadata(gpr_strvec* b, grpc_mdelem md) { static void put_metadata_list(gpr_strvec* b, grpc_metadata_batch md) { grpc_linked_mdelem* m; - for (m = md.list.head; m != NULL; m = m->next) { + for (m = md.list.head; m != nullptr; m = m->next) { if (m != md.list.head) gpr_strvec_add(b, gpr_strdup(", ")); put_metadata(b, m->md); } @@ -121,7 +121,7 @@ char* grpc_transport_stream_op_batch_string( gpr_strvec_add(&b, tmp); } - out = gpr_strvec_flatten(&b, NULL); + out = gpr_strvec_flatten(&b, nullptr); gpr_strvec_destroy(&b); return out; @@ -135,10 +135,10 @@ char* grpc_transport_op_string(grpc_transport_op* op) { gpr_strvec b; gpr_strvec_init(&b); - if (op->on_connectivity_state_change != NULL) { + if (op->on_connectivity_state_change != nullptr) { if (!first) gpr_strvec_add(&b, gpr_strdup(" ")); first = false; - if (op->connectivity_state != NULL) { + if (op->connectivity_state != nullptr) { gpr_asprintf(&tmp, "ON_CONNECTIVITY_STATE_CHANGE:p=%p:from=%s", op->on_connectivity_state_change, grpc_connectivity_state_name(*op->connectivity_state)); @@ -175,25 +175,25 @@ char* grpc_transport_op_string(grpc_transport_op* op) { gpr_strvec_add(&b, tmp); } - if (op->bind_pollset != NULL) { + if (op->bind_pollset != nullptr) { if (!first) gpr_strvec_add(&b, gpr_strdup(" ")); first = false; gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET")); } - if (op->bind_pollset_set != NULL) { + if (op->bind_pollset_set != nullptr) { if (!first) gpr_strvec_add(&b, gpr_strdup(" ")); first = false; gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET_SET")); } - if (op->send_ping != NULL) { + if (op->send_ping != nullptr) { if (!first) gpr_strvec_add(&b, gpr_strdup(" ")); - first = false; + // first = false; gpr_strvec_add(&b, gpr_strdup("SEND_PING")); } - out = gpr_strvec_flatten(&b, NULL); + out = gpr_strvec_flatten(&b, nullptr); gpr_strvec_destroy(&b); return out; |