diff options
Diffstat (limited to 'src/core/lib/iomgr')
39 files changed, 455 insertions, 411 deletions
diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index d45719608b..74b077de06 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -120,7 +120,7 @@ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx, bool empty; grpc_closure* closure = (grpc_closure*)gpr_mpscq_pop_and_check_end( &call_combiner->queue, &empty); - if (closure == NULL) { + if (closure == nullptr) { // This can happen either due to a race condition within the mpscq // code or because of a race with grpc_call_combiner_start(). if (GRPC_TRACER_ON(grpc_call_combiner_trace)) { diff --git a/src/core/lib/iomgr/closure.cc b/src/core/lib/iomgr/closure.cc index 60e99d0e4e..09257d258c 100644 --- a/src/core/lib/iomgr/closure.cc +++ b/src/core/lib/iomgr/closure.cc @@ -43,7 +43,7 @@ grpc_closure* grpc_closure_init(grpc_closure* closure, grpc_iomgr_cb_func cb, closure->scheduler = scheduler; #ifndef NDEBUG closure->scheduled = false; - closure->file_initiated = NULL; + closure->file_initiated = nullptr; closure->line_initiated = 0; closure->run = false; closure->file_created = file; @@ -53,18 +53,18 @@ grpc_closure* grpc_closure_init(grpc_closure* closure, grpc_iomgr_cb_func cb, } void grpc_closure_list_init(grpc_closure_list* closure_list) { - closure_list->head = closure_list->tail = NULL; + closure_list->head = closure_list->tail = nullptr; } bool grpc_closure_list_append(grpc_closure_list* closure_list, grpc_closure* closure, grpc_error* error) { - if (closure == NULL) { + if (closure == nullptr) { GRPC_ERROR_UNREF(error); return false; } closure->error_data.error = error; - closure->next_data.next = NULL; - bool was_empty = (closure_list->head == NULL); + closure->next_data.next = nullptr; + bool was_empty = (closure_list->head == nullptr); if (was_empty) { closure_list->head = closure; } else { @@ -76,7 +76,7 @@ bool grpc_closure_list_append(grpc_closure_list* closure_list, void grpc_closure_list_fail_all(grpc_closure_list* list, grpc_error* forced_failure) { - for (grpc_closure* c = list->head; c != NULL; c = c->next_data.next) { + for (grpc_closure* c = list->head; c != nullptr; c = c->next_data.next) { if (c->error_data.error == GRPC_ERROR_NONE) { c->error_data.error = GRPC_ERROR_REF(forced_failure); } @@ -85,20 +85,20 @@ void grpc_closure_list_fail_all(grpc_closure_list* list, } bool grpc_closure_list_empty(grpc_closure_list closure_list) { - return closure_list.head == NULL; + return closure_list.head == nullptr; } void grpc_closure_list_move(grpc_closure_list* src, grpc_closure_list* dst) { - if (src->head == NULL) { + if (src->head == nullptr) { return; } - if (dst->head == NULL) { + if (dst->head == nullptr) { *dst = *src; } else { dst->tail->next_data.next = src->head; dst->tail = src->tail; } - src->head = src->tail = NULL; + src->head = src->tail = nullptr; } typedef struct { @@ -143,7 +143,7 @@ void grpc_closure_run(grpc_exec_ctx* exec_ctx, grpc_closure* c, grpc_error* error) { #endif GPR_TIMER_BEGIN("grpc_closure_run", 0); - if (c != NULL) { + if (c != nullptr) { #ifndef NDEBUG c->file_initiated = file; c->line_initiated = line; @@ -165,7 +165,7 @@ void grpc_closure_sched(grpc_exec_ctx* exec_ctx, grpc_closure* c, grpc_error* error) { #endif GPR_TIMER_BEGIN("grpc_closure_sched", 0); - if (c != NULL) { + if (c != nullptr) { #ifndef NDEBUG if (c->scheduled) { gpr_log(GPR_ERROR, @@ -195,7 +195,7 @@ void grpc_closure_list_sched(const char* file, int line, void grpc_closure_list_sched(grpc_exec_ctx* exec_ctx, grpc_closure_list* list) { #endif grpc_closure* c = list->head; - while (c != NULL) { + while (c != nullptr) { grpc_closure* next = c->next_data.next; #ifndef NDEBUG if (c->scheduled) { @@ -215,5 +215,5 @@ void grpc_closure_list_sched(grpc_exec_ctx* exec_ctx, grpc_closure_list* list) { c->scheduler->vtable->sched(exec_ctx, c, c->error_data.error); c = next; } - list->head = list->tail = NULL; + list->head = list->tail = nullptr; } diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index ca9c00b935..b28ca3464c 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -132,8 +132,8 @@ grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) { static void push_last_on_exec_ctx(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) { - lock->next_combiner_on_this_exec_ctx = NULL; - if (exec_ctx->active_combiner == NULL) { + lock->next_combiner_on_this_exec_ctx = nullptr; + if (exec_ctx->active_combiner == nullptr) { exec_ctx->active_combiner = exec_ctx->last_combiner = lock; } else { exec_ctx->last_combiner->next_combiner_on_this_exec_ctx = lock; @@ -145,7 +145,7 @@ static void push_first_on_exec_ctx(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) { lock->next_combiner_on_this_exec_ctx = exec_ctx->active_combiner; exec_ctx->active_combiner = lock; - if (lock->next_combiner_on_this_exec_ctx == NULL) { + if (lock->next_combiner_on_this_exec_ctx == nullptr) { exec_ctx->last_combiner = lock; } } @@ -190,8 +190,8 @@ static void combiner_exec(grpc_exec_ctx* exec_ctx, grpc_closure* cl, static void move_next(grpc_exec_ctx* exec_ctx) { exec_ctx->active_combiner = exec_ctx->active_combiner->next_combiner_on_this_exec_ctx; - if (exec_ctx->active_combiner == NULL) { - exec_ctx->last_combiner = NULL; + if (exec_ctx->active_combiner == nullptr) { + exec_ctx->last_combiner = nullptr; } } @@ -210,7 +210,7 @@ static void queue_offload(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) { bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) { GPR_TIMER_BEGIN("combiner.continue_exec_ctx", 0); grpc_combiner* lock = exec_ctx->active_combiner; - if (lock == NULL) { + if (lock == nullptr) { GPR_TIMER_END("combiner.continue_exec_ctx", 0); return false; } @@ -244,7 +244,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) { gpr_mpscq_node* n = gpr_mpscq_pop(&lock->queue); GRPC_COMBINER_TRACE( gpr_log(GPR_DEBUG, "C:%p maybe_finish_one n=%p", lock, n)); - if (n == NULL) { + if (n == nullptr) { // queue is in an inconsistent state: use this as a cue that we should // go off and do something else for a while (and come back later) GPR_TIMER_MARK("delay_busy", 0); @@ -263,10 +263,10 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) { GPR_TIMER_END("combiner.exec1", 0); } else { grpc_closure* c = lock->final_list.head; - GPR_ASSERT(c != NULL); + GPR_ASSERT(c != nullptr); grpc_closure_list_init(&lock->final_list); int loops = 0; - while (c != NULL) { + while (c != nullptr) { GPR_TIMER_BEGIN("combiner.exec_1final", 0); GRPC_COMBINER_TRACE( gpr_log(GPR_DEBUG, "C:%p execute_final[%d] c=%p", lock, loops, c)); diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index 123ff72851..581b903f1a 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -325,7 +325,7 @@ grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc, (uint8_t)(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY); grpc_error* err = (grpc_error*)gpr_malloc( sizeof(*err) + initial_arena_capacity * sizeof(intptr_t)); - if (err == NULL) { // TODO(ctiller): make gpr_malloc return NULL + if (err == nullptr) { // TODO(ctiller): make gpr_malloc return NULL return GRPC_ERROR_OOM; } #ifndef NDEBUG @@ -457,7 +457,7 @@ bool grpc_error_get_int(grpc_error* err, grpc_error_ints which, intptr_t* p) { if (which == GRPC_ERROR_INT_GRPC_STATUS) { for (size_t i = 0; i < GPR_ARRAY_SIZE(error_status_map); i++) { if (error_status_map[i].error == err) { - if (p != NULL) *p = error_status_map[i].code; + if (p != nullptr) *p = error_status_map[i].code; GPR_TIMER_END("grpc_error_get_int", 0); return true; } @@ -468,7 +468,7 @@ bool grpc_error_get_int(grpc_error* err, grpc_error_ints which, intptr_t* p) { } uint8_t slot = err->ints[which]; if (slot != UINT8_MAX) { - if (p != NULL) *p = err->arena[slot]; + if (p != nullptr) *p = err->arena[slot]; GPR_TIMER_END("grpc_error_get_int", 0); return true; } @@ -618,7 +618,7 @@ static char* key_str(grpc_error_strs which) { } static char* fmt_str(grpc_slice slice) { - char* s = NULL; + char* s = nullptr; size_t sz = 0; size_t cap = 0; append_esc_str((const uint8_t*)GRPC_SLICE_START_PTR(slice), @@ -688,7 +688,7 @@ static void add_errs(grpc_error* err, char** s, size_t* sz, size_t* cap) { } static char* errs_string(grpc_error* err) { - char* s = NULL; + char* s = nullptr; size_t sz = 0; size_t cap = 0; append_chr('[', &s, &sz, &cap); @@ -705,7 +705,7 @@ static int cmp_kvs(const void* a, const void* b) { } static char* finish_kvs(kv_pairs* kvs) { - char* s = NULL; + char* s = nullptr; size_t sz = 0; size_t cap = 0; @@ -733,7 +733,7 @@ const char* grpc_error_string(grpc_error* err) { if (err == GRPC_ERROR_CANCELLED) return cancelled_error_string; void* p = (void*)gpr_atm_acq_load(&err->atomics.error_string); - if (p != NULL) { + if (p != nullptr) { GPR_TIMER_END("grpc_error_string", 0); return (const char*)p; } @@ -767,8 +767,8 @@ grpc_error* grpc_os_error(const char* file, int line, int err, grpc_error_set_str( grpc_error_set_int( grpc_error_create(file, line, - grpc_slice_from_static_string("OS Error"), NULL, - 0), + grpc_slice_from_static_string("OS Error"), + nullptr, 0), GRPC_ERROR_INT_ERRNO, err), GRPC_ERROR_STR_OS_ERROR, grpc_slice_from_static_string(strerror(err))), diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index 36ba440c8a..8d7aea4872 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -24,6 +24,7 @@ #include <grpc/slice.h> #include <grpc/status.h> +#include <grpc/support/log.h> #include <grpc/support/time.h> #include "src/core/lib/debug/trace.h" @@ -184,9 +185,15 @@ grpc_error* grpc_error_add_child(grpc_error* src, grpc_error* child) GRPC_MUST_USE_RESULT; grpc_error* grpc_os_error(const char* file, int line, int err, const char* call_name) GRPC_MUST_USE_RESULT; + +inline grpc_error* grpc_assert_never_ok(grpc_error* error) { + GPR_ASSERT(error != GRPC_ERROR_NONE); + return error; +} + /// create an error associated with errno!=0 (an 'operating system' error) #define GRPC_OS_ERROR(err, call_name) \ - grpc_os_error(__FILE__, __LINE__, err, call_name) + grpc_assert_never_ok(grpc_os_error(__FILE__, __LINE__, err, call_name)) grpc_error* grpc_wsa_error(const char* file, int line, int err, const char* call_name) GRPC_MUST_USE_RESULT; /// windows only: create an error associated with WSAGetLastError()!=0 diff --git a/src/core/lib/iomgr/error_internal.h b/src/core/lib/iomgr/error_internal.h index acf6e04e9c..d5ccbae9e7 100644 --- a/src/core/lib/iomgr/error_internal.h +++ b/src/core/lib/iomgr/error_internal.h @@ -23,6 +23,7 @@ #include <stdbool.h> // TODO, do we need this? #include <grpc/support/sync.h> +#include "src/core/lib/iomgr/error.h" #ifdef __cplusplus extern "C" { @@ -59,7 +60,7 @@ struct grpc_error { intptr_t arena[0]; }; -bool grpc_error_is_special(grpc_error* err); +bool grpc_error_is_special(struct grpc_error* err); #ifdef __cplusplus } diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 61da996781..918bc6f933 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -235,7 +235,7 @@ static bool append_error(grpc_error** composite, grpc_error* error, * alarm 'epoch'). This wakeup_fd gives us something to alert on when such a * case occurs. */ -static grpc_fd* fd_freelist = NULL; +static grpc_fd* fd_freelist = nullptr; static gpr_mu fd_freelist_mu; static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); } @@ -243,7 +243,7 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); } static void fd_global_shutdown(void) { gpr_mu_lock(&fd_freelist_mu); gpr_mu_unlock(&fd_freelist_mu); - while (fd_freelist != NULL) { + while (fd_freelist != nullptr) { grpc_fd* fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; gpr_free(fd); @@ -252,16 +252,16 @@ static void fd_global_shutdown(void) { } static grpc_fd* fd_create(int fd, const char* name) { - grpc_fd* new_fd = NULL; + grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); - if (fd_freelist != NULL) { + if (fd_freelist != nullptr) { new_fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; } gpr_mu_unlock(&fd_freelist_mu); - if (new_fd == NULL) { + if (new_fd == nullptr) { new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd)); } @@ -270,7 +270,7 @@ static grpc_fd* fd_create(int fd, const char* name) { new_fd->write_closure.Init(); gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); - new_fd->freelist_next = NULL; + new_fd->freelist_next = nullptr; char* fd_name; gpr_asprintf(&fd_name, "%s fd=%d", name, fd); @@ -317,7 +317,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_closure* on_done, int* release_fd, bool already_closed, const char* reason) { grpc_error* error = GRPC_ERROR_NONE; - bool is_release_fd = (release_fd != NULL); + bool is_release_fd = (release_fd != nullptr); if (!fd->read_closure->IsShutdown()) { fd_shutdown_internal(exec_ctx, fd, @@ -391,7 +391,7 @@ static size_t g_num_neighborhoods; /* Return true if first in list */ static bool worker_insert(grpc_pollset* pollset, grpc_pollset_worker* worker) { - if (pollset->root_worker == NULL) { + if (pollset->root_worker == nullptr) { pollset->root_worker = worker; worker->next = worker->prev = worker; return true; @@ -411,7 +411,7 @@ static worker_remove_result worker_remove(grpc_pollset* pollset, grpc_pollset_worker* worker) { if (worker == pollset->root_worker) { if (worker == worker->next) { - pollset->root_worker = NULL; + pollset->root_worker = nullptr; return EMPTIED; } else { pollset->root_worker = worker->next; @@ -468,13 +468,13 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { *mu = &pollset->mu; pollset->neighborhood = &g_neighborhoods[choose_neighborhood()]; pollset->reassigning_neighborhood = false; - pollset->root_worker = NULL; + pollset->root_worker = nullptr; pollset->kicked_without_poller = false; pollset->seen_inactive = true; pollset->shutting_down = false; - pollset->shutdown_closure = NULL; + pollset->shutdown_closure = nullptr; pollset->begin_refs = 0; - pollset->next = pollset->prev = NULL; + pollset->next = pollset->prev = nullptr; } static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) { @@ -496,7 +496,7 @@ static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) { pollset->next->prev = pollset->prev; if (pollset == pollset->neighborhood->active_root) { pollset->neighborhood->active_root = - pollset->next == pollset ? NULL : pollset->next; + pollset->next == pollset ? nullptr : pollset->next; } } gpr_mu_unlock(&pollset->neighborhood->mu); @@ -509,7 +509,7 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) { GPR_TIMER_BEGIN("pollset_kick_all", 0); grpc_error* error = GRPC_ERROR_NONE; - if (pollset->root_worker != NULL) { + if (pollset->root_worker != nullptr) { grpc_pollset_worker* worker = pollset->root_worker; do { GRPC_STATS_INC_POLLSET_KICK(exec_ctx); @@ -543,18 +543,18 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx, static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) { - if (pollset->shutdown_closure != NULL && pollset->root_worker == NULL && + if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr && pollset->begin_refs == 0) { GPR_TIMER_MARK("pollset_finish_shutdown", 0); GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE); - pollset->shutdown_closure = NULL; + pollset->shutdown_closure = nullptr; } } static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_closure* closure) { GPR_TIMER_BEGIN("pollset_shutdown", 0); - GPR_ASSERT(pollset->shutdown_closure == NULL); + GPR_ASSERT(pollset->shutdown_closure == nullptr); GPR_ASSERT(!pollset->shutting_down); pollset->shutdown_closure = closure; pollset->shutting_down = true; @@ -667,7 +667,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_pollset_worker** worker_hdl, grpc_millis deadline) { GPR_TIMER_BEGIN("begin_worker", 0); - if (worker_hdl != NULL) *worker_hdl = worker; + if (worker_hdl != nullptr) *worker_hdl = worker; worker->initialized_cv = false; SET_KICK_STATE(worker, UNKICKED); worker->schedule_on_end_work = (grpc_closure_list)GRPC_CLOSURE_LIST_INIT; @@ -716,7 +716,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, not visible in the "kick any" path yet */ if (worker->state == UNKICKED) { pollset->seen_inactive = false; - if (neighborhood->active_root == NULL) { + if (neighborhood->active_root == nullptr) { neighborhood->active_root = pollset->next = pollset->prev = pollset; /* Make this the designated poller if there isn't one already */ if (worker->state == UNKICKED && @@ -794,13 +794,13 @@ static bool check_neighborhood_for_available_poller( bool found_worker = false; do { grpc_pollset* inspect = neighborhood->active_root; - if (inspect == NULL) { + if (inspect == nullptr) { break; } gpr_mu_lock(&inspect->mu); GPR_ASSERT(!inspect->seen_inactive); grpc_pollset_worker* inspect_worker = inspect->root_worker; - if (inspect_worker != NULL) { + if (inspect_worker != nullptr) { do { switch (inspect_worker->state) { case UNKICKED: @@ -841,11 +841,11 @@ static bool check_neighborhood_for_available_poller( inspect->seen_inactive = true; if (inspect == neighborhood->active_root) { neighborhood->active_root = - inspect->next == inspect ? NULL : inspect->next; + inspect->next == inspect ? nullptr : inspect->next; } inspect->next->prev = inspect->prev; inspect->prev->next = inspect->next; - inspect->next = inspect->prev = NULL; + inspect->next = inspect->prev = nullptr; } gpr_mu_unlock(&inspect->mu); } while (!found_worker); @@ -860,7 +860,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "PS:%p END_WORKER:%p", pollset, worker); } - if (worker_hdl != NULL) *worker_hdl = NULL; + if (worker_hdl != nullptr) *worker_hdl = nullptr; /* Make sure we appear kicked */ SET_KICK_STATE(worker, KICKED); grpc_closure_list_move(&worker->schedule_on_end_work, @@ -1002,28 +1002,28 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, (void*)gpr_tls_get(&g_current_thread_worker), pollset->root_worker); gpr_strvec_add(&log, tmp); - if (pollset->root_worker != NULL) { + if (pollset->root_worker != nullptr) { gpr_asprintf(&tmp, " {kick_state=%s next=%p {kick_state=%s}}", kick_state_string(pollset->root_worker->state), pollset->root_worker->next, kick_state_string(pollset->root_worker->next->state)); gpr_strvec_add(&log, tmp); } - if (specific_worker != NULL) { + if (specific_worker != nullptr) { gpr_asprintf(&tmp, " worker_kick_state=%s", kick_state_string(specific_worker->state)); gpr_strvec_add(&log, tmp); } - tmp = gpr_strvec_flatten(&log, NULL); + tmp = gpr_strvec_flatten(&log, nullptr); gpr_strvec_destroy(&log); gpr_log(GPR_ERROR, "%s", tmp); gpr_free(tmp); } - if (specific_worker == NULL) { + if (specific_worker == nullptr) { if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) { grpc_pollset_worker* root_worker = pollset->root_worker; - if (root_worker == NULL) { + if (root_worker == nullptr) { GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx); pollset->kicked_without_poller = true; if (GRPC_TRACER_ON(grpc_polling_trace)) { @@ -1232,11 +1232,11 @@ static const grpc_event_engine_vtable vtable = { const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) { if (!grpc_has_wakeup_fd()) { gpr_log(GPR_ERROR, "Skipping epoll1 because of no wakeup fd."); - return NULL; + return nullptr; } if (!epoll_set_init()) { - return NULL; + return nullptr; } fd_global_init(); @@ -1244,7 +1244,7 @@ const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) { if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) { fd_global_shutdown(); epoll_set_shutdown(); - return NULL; + return nullptr; } return &vtable; diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index caaee76b8c..bfd2ac4326 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -254,7 +254,7 @@ static bool append_error(grpc_error** composite, grpc_error* error, * becomes a spurious read notification on a reused fd. */ -static grpc_fd* fd_freelist = NULL; +static grpc_fd* fd_freelist = nullptr; static gpr_mu fd_freelist_mu; #ifndef NDEBUG @@ -322,7 +322,7 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); } static void fd_global_shutdown(void) { gpr_mu_lock(&fd_freelist_mu); gpr_mu_unlock(&fd_freelist_mu); - while (fd_freelist != NULL) { + while (fd_freelist != nullptr) { grpc_fd* fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; gpr_free(fd); @@ -331,30 +331,30 @@ static void fd_global_shutdown(void) { } static grpc_fd* fd_create(int fd, const char* name) { - grpc_fd* new_fd = NULL; + grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); - if (fd_freelist != NULL) { + if (fd_freelist != nullptr) { new_fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; } gpr_mu_unlock(&fd_freelist_mu); - if (new_fd == NULL) { + if (new_fd == nullptr) { new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd)); } gpr_mu_init(&new_fd->pollable_mu); gpr_mu_init(&new_fd->orphan_mu); - new_fd->pollable_obj = NULL; + new_fd->pollable_obj = nullptr; gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1); new_fd->fd = fd; new_fd->read_closure.Init(); new_fd->write_closure.Init(); gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); - new_fd->freelist_next = NULL; - new_fd->on_done_closure = NULL; + new_fd->freelist_next = nullptr; + new_fd->on_done_closure = nullptr; char* fd_name; gpr_asprintf(&fd_name, "%s fd=%d", name, fd); @@ -384,7 +384,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, /* If release_fd is not NULL, we should be relinquishing control of the file descriptor fd->fd (but we still own the grpc_fd structure). */ - if (release_fd != NULL) { + if (release_fd != nullptr) { *release_fd = fd->fd; } else if (!is_fd_closed) { close(fd->fd); @@ -440,7 +440,7 @@ static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd, */ static grpc_error* pollable_create(pollable_type type, pollable** p) { - *p = NULL; + *p = nullptr; int epfd = epoll_create1(EPOLL_CLOEXEC); if (epfd == -1) { @@ -451,7 +451,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { if (err != GRPC_ERROR_NONE) { close(epfd); gpr_free(*p); - *p = NULL; + *p = nullptr; return err; } struct epoll_event ev; @@ -462,7 +462,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { close(epfd); grpc_wakeup_fd_destroy(&(*p)->wakeup); gpr_free(*p); - *p = NULL; + *p = nullptr; return err; } @@ -470,10 +470,10 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { gpr_ref_init(&(*p)->refs, 1); gpr_mu_init(&(*p)->mu); (*p)->epfd = epfd; - (*p)->owner_fd = NULL; - (*p)->pollset_set = NULL; + (*p)->owner_fd = nullptr; + (*p)->pollset_set = nullptr; (*p)->next = (*p)->prev = *p; - (*p)->root_worker = NULL; + (*p)->root_worker = nullptr; (*p)->event_cursor = 0; (*p)->event_count = 0; return GRPC_ERROR_NONE; @@ -497,14 +497,14 @@ static pollable* pollable_ref(pollable* p, int line, const char* reason) { static void pollable_unref(pollable* p) { #else static void pollable_unref(pollable* p, int line, const char* reason) { - if (p == NULL) return; + if (p == nullptr) return; if (GRPC_TRACER_ON(grpc_trace_pollable_refcount)) { int r = (int)gpr_atm_no_barrier_load(&p->refs.count); gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG, "POLLABLE:%p unref %d->%d %s", p, r, r - 1, reason); } #endif - if (p != NULL && gpr_unref(&p->refs)) { + if (p != nullptr && gpr_unref(&p->refs)) { close(p->epfd); grpc_wakeup_fd_destroy(&p->wakeup); gpr_free(p); @@ -565,10 +565,10 @@ static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx, pollset, pollset->active_pollable, pollset->shutdown_closure, pollset->root_worker, pollset->containing_pollset_set_count); } - if (pollset->shutdown_closure != NULL && pollset->root_worker == NULL && + if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr && pollset->containing_pollset_set_count == 0) { GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE); - pollset->shutdown_closure = NULL; + pollset->shutdown_closure = nullptr; } } @@ -579,7 +579,7 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx, grpc_pollset_worker* specific_worker) { pollable* p = specific_worker->pollable_obj; grpc_core::mu_guard lock(&p->mu); - GPR_ASSERT(specific_worker != NULL); + GPR_ASSERT(specific_worker != nullptr); if (specific_worker->kicked) { if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p); @@ -628,9 +628,9 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, (void*)gpr_tls_get(&g_current_thread_pollset), (void*)gpr_tls_get(&g_current_thread_worker), pollset->root_worker); } - if (specific_worker == NULL) { + if (specific_worker == nullptr) { if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) { - if (pollset->root_worker == NULL) { + if (pollset->root_worker == nullptr) { if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", pollset); } @@ -673,7 +673,7 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx, grpc_error* error = GRPC_ERROR_NONE; const char* err_desc = "pollset_kick_all"; grpc_pollset_worker* w = pollset->root_worker; - if (w != NULL) { + if (w != nullptr) { do { GRPC_STATS_INC_POLLSET_KICK(exec_ctx); append_error(&error, kick_one_worker(exec_ctx, w), err_desc); @@ -722,23 +722,23 @@ static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) { gpr_mu_lock(&fd->pollable_mu); grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "fd_get_or_become_pollable"; - if (fd->pollable_obj == NULL) { + if (fd->pollable_obj == nullptr) { if (append_error(&error, pollable_create(PO_FD, &fd->pollable_obj), err_desc)) { fd->pollable_obj->owner_fd = fd; if (!append_error(&error, pollable_add_fd(fd->pollable_obj, fd), err_desc)) { POLLABLE_UNREF(fd->pollable_obj, "fd_pollable"); - fd->pollable_obj = NULL; + fd->pollable_obj = nullptr; } } } if (error == GRPC_ERROR_NONE) { - GPR_ASSERT(fd->pollable_obj != NULL); + GPR_ASSERT(fd->pollable_obj != nullptr); *p = POLLABLE_REF(fd->pollable_obj, "pollset"); } else { - GPR_ASSERT(fd->pollable_obj == NULL); - *p = NULL; + GPR_ASSERT(fd->pollable_obj == nullptr); + *p = nullptr; } gpr_mu_unlock(&fd->pollable_mu); return error; @@ -747,7 +747,7 @@ static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) { /* pollset->po.mu lock must be held by the caller before calling this */ static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_closure* closure) { - GPR_ASSERT(pollset->shutdown_closure == NULL); + GPR_ASSERT(pollset->shutdown_closure == nullptr); pollset->shutdown_closure = closure; GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(exec_ctx, pollset)); pollset_maybe_finish_shutdown(exec_ctx, pollset); @@ -798,7 +798,7 @@ static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx, /* pollset_shutdown is guaranteed to be called before pollset_destroy. */ static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) { POLLABLE_UNREF(pollset->active_pollable, "pollset"); - pollset->active_pollable = NULL; + pollset->active_pollable = nullptr; } static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p, @@ -838,7 +838,7 @@ static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p, /* Return true if first in list */ static bool worker_insert(grpc_pollset_worker** root_worker, grpc_pollset_worker* worker, pwlinks link) { - if (*root_worker == NULL) { + if (*root_worker == nullptr) { *root_worker = worker; worker->links[link].next = worker->links[link].prev = worker; return true; @@ -859,7 +859,7 @@ static worker_remove_result worker_remove(grpc_pollset_worker** root_worker, pwlinks link) { if (worker == *root_worker) { if (worker == worker->links[link].next) { - *root_worker = NULL; + *root_worker = nullptr; return WRR_EMPTIED; } else { *root_worker = worker->links[link].next; @@ -880,7 +880,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_pollset_worker** worker_hdl, grpc_millis deadline) { bool do_poll = (pollset->shutdown_closure == nullptr); - if (worker_hdl != NULL) *worker_hdl = worker; + if (worker_hdl != nullptr) *worker_hdl = worker; worker->initialized_cv = false; worker->kicked = false; worker->pollset = pollset; @@ -1053,12 +1053,12 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked( append_error(&error, pollset_kick_all(exec_ctx, pollset), err_desc); grpc_fd* initial_fd = pollset->active_pollable->owner_fd; POLLABLE_UNREF(pollset->active_pollable, "pollset"); - pollset->active_pollable = NULL; + pollset->active_pollable = nullptr; if (append_error(&error, pollable_create(PO_MULTI, &pollset->active_pollable), err_desc)) { append_error(&error, pollable_add_fd(pollset->active_pollable, initial_fd), err_desc); - if (and_add_fd != NULL) { + if (and_add_fd != nullptr) { append_error(&error, pollable_add_fd(pollset->active_pollable, and_add_fd), err_desc); @@ -1124,7 +1124,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx, error = pollable_create(PO_MULTI, &pollset->active_pollable); } else { error = pollset_transition_pollable_from_fd_to_multi_locked( - exec_ctx, pollset, NULL); + exec_ctx, pollset, nullptr); } gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu); break; @@ -1134,7 +1134,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx, if (error != GRPC_ERROR_NONE) { POLLABLE_UNREF(pollset->active_pollable, "pollset"); pollset->active_pollable = po_at_start; - *pollable_obj = NULL; + *pollable_obj = nullptr; } else { *pollable_obj = POLLABLE_REF(pollset->active_pollable, "pollset_set"); POLLABLE_UNREF(po_at_start, "pollset_as_multipollable"); @@ -1156,7 +1156,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, static grpc_pollset_set* pss_lock_adam(grpc_pollset_set* pss) { gpr_mu_lock(&pss->mu); - while (pss->parent != NULL) { + while (pss->parent != nullptr) { gpr_mu_unlock(&pss->mu); pss = pss->parent; gpr_mu_lock(&pss->mu); @@ -1172,7 +1172,7 @@ static grpc_pollset_set* pollset_set_create(void) { } static void pollset_set_unref(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss) { - if (pss == NULL) return; + if (pss == nullptr) return; if (!gpr_unref(&pss->refs)) return; pollset_set_unref(exec_ctx, pss->parent); gpr_mu_destroy(&pss->mu); @@ -1294,11 +1294,11 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx, } grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "pollset_set_add_pollset"; - pollable* pollable_obj = NULL; + pollable* pollable_obj = nullptr; gpr_mu_lock(&ps->mu); if (!GRPC_LOG_IF_ERROR(err_desc, pollset_as_multipollable_locked( exec_ctx, ps, &pollable_obj))) { - GPR_ASSERT(pollable_obj == NULL); + GPR_ASSERT(pollable_obj == nullptr); gpr_mu_unlock(&ps->mu); return; } @@ -1343,9 +1343,9 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx, gpr_mu* b_mu = &b->mu; gpr_mu_lock(a_mu); gpr_mu_lock(b_mu); - if (a->parent != NULL) { + if (a->parent != nullptr) { a = a->parent; - } else if (b->parent != NULL) { + } else if (b->parent != nullptr) { b = b->parent; } else { break; // exit loop, both pollsets locked @@ -1394,8 +1394,8 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx, a->pollset_count += b->pollset_count; gpr_free(b->fds); gpr_free(b->pollsets); - b->fds = NULL; - b->pollsets = NULL; + b->fds = nullptr; + b->pollsets = nullptr; b->fd_count = b->fd_capacity = b->pollset_count = b->pollset_capacity = 0; gpr_mu_unlock(&a->mu); gpr_mu_unlock(&b->mu); @@ -1448,17 +1448,17 @@ static const grpc_event_engine_vtable vtable = { const grpc_event_engine_vtable* grpc_init_epollex_linux( bool explicitly_requested) { if (!explicitly_requested) { - return NULL; + return nullptr; } if (!grpc_has_wakeup_fd()) { gpr_log(GPR_ERROR, "Skipping epollex because of no wakeup fd."); - return NULL; + return nullptr; } if (!grpc_is_epollexclusive_available()) { gpr_log(GPR_INFO, "Skipping epollex because it is not supported."); - return NULL; + return nullptr; } #ifndef NDEBUG @@ -1470,7 +1470,7 @@ const grpc_event_engine_vtable* grpc_init_epollex_linux( if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) { pollset_global_shutdown(); fd_global_shutdown(); - return NULL; + return nullptr; } return &vtable; diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 42806e9d14..5b4a7ba19c 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -328,7 +328,7 @@ static void pi_unref(grpc_exec_ctx* exec_ctx, polling_island* pi) { if (1 == gpr_atm_full_fetch_add(&pi->ref_count, -1)) { polling_island* next = (polling_island*)gpr_atm_acq_load(&pi->merged_to); polling_island_delete(exec_ctx, pi); - if (next != NULL) { + if (next != nullptr) { PI_UNREF(exec_ctx, next, "pi_delete"); /* Recursive call */ } } @@ -414,7 +414,7 @@ static void polling_island_remove_all_fds_locked(polling_island* pi, const char* err_desc = "polling_island_remove_fds"; for (i = 0; i < pi->fd_cnt; i++) { - err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, pi->fds[i]->fd, NULL); + err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, pi->fds[i]->fd, nullptr); if (err < 0 && errno != ENOENT) { gpr_asprintf(&err_msg, "epoll_ctl (epoll_fd: %d) delete fds[%zu]: %d failed with " @@ -444,7 +444,7 @@ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd, /* If fd is already closed, then it would have been automatically been removed from the epoll set */ if (!is_fd_closed) { - err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, NULL); + err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, nullptr); if (err < 0 && errno != ENOENT) { gpr_asprintf( &err_msg, @@ -468,7 +468,7 @@ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd, static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx, grpc_fd* initial_fd, grpc_error** error) { - polling_island* pi = NULL; + polling_island* pi = nullptr; const char* err_desc = "polling_island_create"; *error = GRPC_ERROR_NONE; @@ -477,7 +477,7 @@ static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx, gpr_mu_init(&pi->mu); pi->fd_cnt = 0; pi->fd_capacity = 0; - pi->fds = NULL; + pi->fds = nullptr; pi->epoll_fd = -1; gpr_atm_rel_store(&pi->ref_count, 0); @@ -491,14 +491,14 @@ static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx, goto done; } - if (initial_fd != NULL) { + if (initial_fd != nullptr) { polling_island_add_fds_locked(pi, &initial_fd, 1, true, error); } done: if (*error != GRPC_ERROR_NONE) { polling_island_delete(exec_ctx, pi); - pi = NULL; + pi = nullptr; } return pi; } @@ -519,7 +519,7 @@ static void polling_island_delete(grpc_exec_ctx* exec_ctx, polling_island* pi) { * guarantees that the island returned is the last island */ static polling_island* polling_island_maybe_get_latest(polling_island* pi) { polling_island* next = (polling_island*)gpr_atm_acq_load(&pi->merged_to); - while (next != NULL) { + while (next != nullptr) { pi = next; next = (polling_island*)gpr_atm_acq_load(&pi->merged_to); } @@ -537,18 +537,18 @@ static polling_island* polling_island_maybe_get_latest(polling_island* pi) { ... gpr_mu_unlock(&pi_latest->mu); // NOTE: use pi_latest->mu. NOT pi->mu */ static polling_island* polling_island_lock(polling_island* pi) { - polling_island* next = NULL; + polling_island* next = nullptr; while (true) { next = (polling_island*)gpr_atm_acq_load(&pi->merged_to); - if (next == NULL) { + if (next == nullptr) { /* Looks like 'pi' is the last node in the linked list but unless we check this by holding the pi->mu lock, we cannot be sure (i.e without the pi->mu lock, we don't prevent island merges). To be absolutely sure, check once more by holding the pi->mu lock */ gpr_mu_lock(&pi->mu); next = (polling_island*)gpr_atm_acq_load(&pi->merged_to); - if (next == NULL) { + if (next == nullptr) { /* pi is infact the last node and we have the pi->mu lock. we're done */ break; } @@ -588,8 +588,8 @@ static polling_island* polling_island_lock(polling_island* pi) { static void polling_island_lock_pair(polling_island** p, polling_island** q) { polling_island* pi_1 = *p; polling_island* pi_2 = *q; - polling_island* next_1 = NULL; - polling_island* next_2 = NULL; + polling_island* next_1 = nullptr; + polling_island* next_2 = nullptr; /* The algorithm is simple: - Go to the last polling islands in the linked lists *pi_1 and *pi_2 (and @@ -607,13 +607,13 @@ static void polling_island_lock_pair(polling_island** p, polling_island** q) { release the locks and continue the process from the first step */ while (true) { next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to); - while (next_1 != NULL) { + while (next_1 != nullptr) { pi_1 = next_1; next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to); } next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to); - while (next_2 != NULL) { + while (next_2 != nullptr) { pi_2 = next_2; next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to); } @@ -633,7 +633,7 @@ static void polling_island_lock_pair(polling_island** p, polling_island** q) { next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to); next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to); - if (next_1 == NULL && next_2 == NULL) { + if (next_1 == nullptr && next_2 == nullptr) { break; } @@ -725,7 +725,7 @@ static void polling_island_global_shutdown() { * alarm 'epoch'). This wakeup_fd gives us something to alert on when such a * case occurs. */ -static grpc_fd* fd_freelist = NULL; +static grpc_fd* fd_freelist = nullptr; static gpr_mu fd_freelist_mu; #ifndef NDEBUG @@ -797,7 +797,7 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); } static void fd_global_shutdown(void) { gpr_mu_lock(&fd_freelist_mu); gpr_mu_unlock(&fd_freelist_mu); - while (fd_freelist != NULL) { + while (fd_freelist != nullptr) { grpc_fd* fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; gpr_mu_destroy(&fd->po.mu); @@ -807,16 +807,16 @@ static void fd_global_shutdown(void) { } static grpc_fd* fd_create(int fd, const char* name) { - grpc_fd* new_fd = NULL; + grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); - if (fd_freelist != NULL) { + if (fd_freelist != nullptr) { new_fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; } gpr_mu_unlock(&fd_freelist_mu); - if (new_fd == NULL) { + if (new_fd == nullptr) { new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd)); gpr_mu_init(&new_fd->po.mu); } @@ -825,7 +825,7 @@ static grpc_fd* fd_create(int fd, const char* name) { * is a newly created fd (or an fd we got from the freelist), no one else * would be holding a lock to it anyway. */ gpr_mu_lock(&new_fd->po.mu); - new_fd->po.pi = NULL; + new_fd->po.pi = nullptr; #ifndef NDEBUG new_fd->po.obj_type = POLL_OBJ_FD; #endif @@ -837,8 +837,8 @@ static grpc_fd* fd_create(int fd, const char* name) { new_fd->write_closure.Init(); gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); - new_fd->freelist_next = NULL; - new_fd->on_done_closure = NULL; + new_fd->freelist_next = nullptr; + new_fd->on_done_closure = nullptr; gpr_mu_unlock(&new_fd->po.mu); @@ -864,7 +864,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_closure* on_done, int* release_fd, bool already_closed, const char* reason) { grpc_error* error = GRPC_ERROR_NONE; - polling_island* unref_pi = NULL; + polling_island* unref_pi = nullptr; gpr_mu_lock(&fd->po.mu); fd->on_done_closure = on_done; @@ -881,18 +881,18 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, - Unlock the latest polling island - Set fd->po.pi to NULL (but remove the ref on the polling island before doing this.) */ - if (fd->po.pi != NULL) { + if (fd->po.pi != nullptr) { polling_island* pi_latest = polling_island_lock(fd->po.pi); polling_island_remove_fd_locked(pi_latest, fd, already_closed, &error); gpr_mu_unlock(&pi_latest->mu); unref_pi = fd->po.pi; - fd->po.pi = NULL; + fd->po.pi = nullptr; } /* If release_fd is not NULL, we should be relinquishing control of the file descriptor fd->fd (but we still own the grpc_fd structure). */ - if (release_fd != NULL) { + if (release_fd != nullptr) { *release_fd = fd->fd; } else { close(fd->fd); @@ -904,7 +904,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, gpr_mu_unlock(&fd->po.mu); UNREF_BY(fd, 2, reason); /* Drop the reference */ - if (unref_pi != NULL) { + if (unref_pi != nullptr) { /* Unref stale polling island here, outside the fd lock above. The polling island owns a workqueue which owns an fd, and unreffing inside the lock can cause an eventual lock loop that makes TSAN very @@ -1009,7 +1009,7 @@ static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) { remove_worker(p, w); return w; } else { - return NULL; + return nullptr; } } @@ -1033,7 +1033,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p, GRPC_STATS_INC_POLLSET_KICK(exec_ctx); const char* err_desc = "Kick Failure"; grpc_pollset_worker* worker = specific_worker; - if (worker != NULL) { + if (worker != nullptr) { if (worker == GRPC_POLLSET_KICK_BROADCAST) { if (pollset_has_workers(p)) { GPR_TIMER_BEGIN("pollset_kick.broadcast", 0); @@ -1063,7 +1063,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p, GPR_TIMER_MARK("kick_anonymous", 0); worker = pop_front_worker(p); - if (worker != NULL) { + if (worker != nullptr) { GPR_TIMER_MARK("finally_kick", 0); push_back_worker(p, worker); append_error(&error, pollset_worker_kick(worker), err_desc); @@ -1081,7 +1081,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p, static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { gpr_mu_init(&pollset->po.mu); *mu = &pollset->po.mu; - pollset->po.pi = NULL; + pollset->po.pi = nullptr; #ifndef NDEBUG pollset->po.obj_type = POLL_OBJ_POLLSET; #endif @@ -1091,7 +1091,7 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { pollset->shutting_down = false; pollset->finish_shutdown_called = false; - pollset->shutdown_done = NULL; + pollset->shutdown_done = nullptr; } static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx, @@ -1126,10 +1126,10 @@ static void fd_become_writable(grpc_exec_ctx* exec_ctx, grpc_fd* fd) { static void pollset_release_polling_island(grpc_exec_ctx* exec_ctx, grpc_pollset* ps, const char* reason) { - if (ps->po.pi != NULL) { + if (ps->po.pi != nullptr) { PI_UNREF(exec_ctx, ps->po.pi, reason); } - ps->po.pi = NULL; + ps->po.pi = nullptr; } static void finish_shutdown_locked(grpc_exec_ctx* exec_ctx, @@ -1181,7 +1181,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx, struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS]; int epoll_fd = -1; int ep_rv; - polling_island* pi = NULL; + polling_island* pi = nullptr; char* err_msg; const char* err_desc = "pollset_work_and_unlock"; GPR_TIMER_BEGIN("pollset_work_and_unlock", 0); @@ -1196,9 +1196,9 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx, right-away from epoll_wait() and pick up the latest polling_island the next this function (i.e pollset_work_and_unlock()) is called */ - if (pollset->po.pi == NULL) { - pollset->po.pi = polling_island_create(exec_ctx, NULL, error); - if (pollset->po.pi == NULL) { + if (pollset->po.pi == nullptr) { + pollset->po.pi = polling_island_create(exec_ctx, nullptr, error); + if (pollset->po.pi == nullptr) { GPR_TIMER_END("pollset_work_and_unlock", 0); return; /* Fatal error. We cannot continue */ } @@ -1280,10 +1280,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx, } } - g_current_thread_polling_island = NULL; + g_current_thread_polling_island = nullptr; gpr_atm_no_barrier_fetch_add(&pi->poller_count, -1); - GPR_ASSERT(pi != NULL); + GPR_ASSERT(pi != nullptr); /* Before leaving, release the extra ref we added to the polling island. It is important to use "pi" here (i.e our old copy of pollset->po.pi @@ -1309,7 +1309,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, sigset_t new_mask; grpc_pollset_worker worker; - worker.next = worker.prev = NULL; + worker.next = worker.prev = nullptr; worker.pt_id = pthread_self(); gpr_atm_no_barrier_store(&worker.is_kicked, (gpr_atm)0); @@ -1391,7 +1391,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, gpr_mu_lock(&pollset->po.mu); } - if (worker_hdl) *worker_hdl = NULL; + if (worker_hdl) *worker_hdl = nullptr; gpr_tls_set(&g_current_thread_pollset, (intptr_t)0); gpr_tls_set(&g_current_thread_worker, (intptr_t)0); @@ -1413,7 +1413,7 @@ static void add_poll_object(grpc_exec_ctx* exec_ctx, poll_obj* bag, #endif grpc_error* error = GRPC_ERROR_NONE; - polling_island* pi_new = NULL; + polling_island* pi_new = nullptr; gpr_mu_lock(&bag->mu); gpr_mu_lock(&item->mu); @@ -1440,7 +1440,7 @@ retry: if (item->pi == bag->pi) { pi_new = item->pi; - if (pi_new == NULL) { + if (pi_new == nullptr) { /* GPR_ASSERT(item->pi == bag->pi == NULL) */ /* If we are adding an fd to a bag (i.e pollset or pollset_set), then @@ -1460,7 +1460,7 @@ retry: /* Need to reverify any assumptions made between the initial lock and getting to this branch: if they've changed, we need to throw away our work and figure things out again. */ - if (item->pi != NULL) { + if (item->pi != nullptr) { GRPC_POLLING_TRACE( "add_poll_object: Raced creating new polling island. pi_new: %p " "(fd: %d, %s: %p)", @@ -1477,7 +1477,7 @@ retry: goto retry; } } else { - pi_new = polling_island_create(exec_ctx, NULL, &error); + pi_new = polling_island_create(exec_ctx, nullptr, &error); } GRPC_POLLING_TRACE( @@ -1490,7 +1490,7 @@ retry: "add_poll_object: Same polling island. pi: %p (%s, %s)", (void*)pi_new, poll_obj_string(item_type), poll_obj_string(bag_type)); } - } else if (item->pi == NULL) { + } else if (item->pi == nullptr) { /* GPR_ASSERT(bag->pi != NULL) */ /* Make pi_new point to latest pi*/ pi_new = polling_island_lock(bag->pi); @@ -1506,7 +1506,7 @@ retry: "bag(%s): %p)", (void*)pi_new, poll_obj_string(item_type), (void*)item, poll_obj_string(bag_type), (void*)bag); - } else if (bag->pi == NULL) { + } else if (bag->pi == nullptr) { /* GPR_ASSERT(item->pi != NULL) */ /* Make pi_new to point to latest pi */ pi_new = polling_island_lock(item->pi); @@ -1530,7 +1530,7 @@ retry: if (item->pi != pi_new) { PI_ADD_REF(pi_new, poll_obj_string(item_type)); - if (item->pi != NULL) { + if (item->pi != nullptr) { PI_UNREF(exec_ctx, item->pi, poll_obj_string(item_type)); } item->pi = pi_new; @@ -1538,7 +1538,7 @@ retry: if (bag->pi != pi_new) { PI_ADD_REF(pi_new, poll_obj_string(bag_type)); - if (bag->pi != NULL) { + if (bag->pi != nullptr) { PI_UNREF(exec_ctx, bag->pi, poll_obj_string(bag_type)); } bag->pi = pi_new; @@ -1564,7 +1564,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, static grpc_pollset_set* pollset_set_create(void) { grpc_pollset_set* pss = (grpc_pollset_set*)gpr_malloc(sizeof(*pss)); gpr_mu_init(&pss->po.mu); - pss->po.pi = NULL; + pss->po.pi = nullptr; #ifndef NDEBUG pss->po.obj_type = POLL_OBJ_POLLSET_SET; #endif @@ -1575,7 +1575,7 @@ static void pollset_set_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss) { gpr_mu_destroy(&pss->po.mu); - if (pss->po.pi != NULL) { + if (pss->po.pi != nullptr) { PI_UNREF(exec_ctx, pss->po.pi, "pss_destroy"); } @@ -1712,17 +1712,17 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux( /* If use of signals is disabled, we cannot use epoll engine*/ if (is_grpc_wakeup_signal_initialized && grpc_wakeup_signal < 0) { gpr_log(GPR_ERROR, "Skipping epollsig because use of signals is disabled."); - return NULL; + return nullptr; } if (!grpc_has_wakeup_fd()) { gpr_log(GPR_ERROR, "Skipping epollsig because of no wakeup fd."); - return NULL; + return nullptr; } if (!is_epoll_available()) { gpr_log(GPR_ERROR, "Skipping epollsig because epoll is unavailable."); - return NULL; + return nullptr; } if (!is_grpc_wakeup_signal_initialized) { @@ -1731,19 +1731,19 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux( } else { gpr_log(GPR_ERROR, "Skipping epollsig because uninitialized wakeup signal."); - return NULL; + return nullptr; } } fd_global_init(); if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) { - return NULL; + return nullptr; } if (!GRPC_LOG_IF_ERROR("polling_island_global_init", polling_island_global_init())) { - return NULL; + return nullptr; } return &vtable; diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 5745a2ae5b..f8b9629462 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -335,11 +335,11 @@ static grpc_fd* fd_create(int fd, const char* name) { r->fd = fd; r->inactive_watcher_root.next = r->inactive_watcher_root.prev = &r->inactive_watcher_root; - r->read_watcher = r->write_watcher = NULL; - r->on_done_closure = NULL; + r->read_watcher = r->write_watcher = nullptr; + r->on_done_closure = nullptr; r->closed = 0; r->released = 0; - r->read_notifier_pollset = NULL; + r->read_notifier_pollset = nullptr; char* name2; gpr_asprintf(&name2, "%s fd=%d", name, fd); @@ -355,7 +355,7 @@ static bool fd_is_orphaned(grpc_fd* fd) { /* Return the read-notifier pollset */ static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx, grpc_fd* fd) { - grpc_pollset* notifier = NULL; + grpc_pollset* notifier = nullptr; gpr_mu_lock(&fd->mu); notifier = fd->read_notifier_pollset; @@ -401,7 +401,7 @@ static void wake_all_watchers_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd) { } static int has_watchers(grpc_fd* fd) { - return fd->read_watcher != NULL || fd->write_watcher != NULL || + return fd->read_watcher != nullptr || fd->write_watcher != nullptr || fd->inactive_watcher_root.next != &fd->inactive_watcher_root; } @@ -425,8 +425,8 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_closure* on_done, int* release_fd, bool already_closed, const char* reason) { fd->on_done_closure = on_done; - fd->released = release_fd != NULL; - if (release_fd != NULL) { + fd->released = release_fd != nullptr; + if (release_fd != nullptr) { *release_fd = fd->fd; fd->released = true; } else if (already_closed) { @@ -565,9 +565,9 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, /* if we are shutdown, then don't add to the watcher set */ if (fd->shutdown) { - watcher->fd = NULL; - watcher->pollset = NULL; - watcher->worker = NULL; + watcher->fd = nullptr; + watcher->pollset = nullptr; + watcher->worker = nullptr; gpr_mu_unlock(&fd->mu); GRPC_FD_UNREF(fd, "poll"); return 0; @@ -576,7 +576,7 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, /* if there is nobody polling for read, but we need to, then start doing so */ cur = fd->read_closure; requested = cur != CLOSURE_READY; - if (read_mask && fd->read_watcher == NULL && requested) { + if (read_mask && fd->read_watcher == nullptr && requested) { fd->read_watcher = watcher; mask |= read_mask; } @@ -584,12 +584,12 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset, */ cur = fd->write_closure; requested = cur != CLOSURE_READY; - if (write_mask && fd->write_watcher == NULL && requested) { + if (write_mask && fd->write_watcher == nullptr && requested) { fd->write_watcher = watcher; mask |= write_mask; } /* if not polling, remember this watcher in case we need someone to later */ - if (mask == 0 && worker != NULL) { + if (mask == 0 && worker != nullptr) { watcher->next = &fd->inactive_watcher_root; watcher->prev = watcher->next->prev; watcher->next->prev = watcher->prev->next = watcher; @@ -609,7 +609,7 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher, int kick = 0; grpc_fd* fd = watcher->fd; - if (fd == NULL) { + if (fd == nullptr) { return; } @@ -621,7 +621,7 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher, if (!got_read) { kick = 1; } - fd->read_watcher = NULL; + fd->read_watcher = nullptr; } if (watcher == fd->write_watcher) { /* remove write watcher, kick if we still need a write */ @@ -629,9 +629,9 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher, if (!got_write) { kick = 1; } - fd->write_watcher = NULL; + fd->write_watcher = nullptr; } - if (!was_polling && watcher->worker != NULL) { + if (!was_polling && watcher->worker != nullptr) { /* remove from inactive list */ watcher->next->prev = watcher->prev; watcher->prev->next = watcher->next; @@ -640,7 +640,7 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher, if (set_ready_locked(exec_ctx, fd, &fd->read_closure)) { kick = 1; } - if (read_notifier_pollset != NULL) { + if (read_notifier_pollset != nullptr) { set_read_notifier_pollset_locked(exec_ctx, fd, read_notifier_pollset); } } @@ -690,7 +690,7 @@ static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) { remove_worker(p, w); return w; } else { - return NULL; + return nullptr; } } @@ -722,7 +722,7 @@ static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p, GRPC_STATS_INC_POLLSET_KICK(exec_ctx); /* pollset->mu already held */ - if (specific_worker != NULL) { + if (specific_worker != nullptr) { if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) { GPR_TIMER_BEGIN("pollset_kick_ext.broadcast", 0); GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); @@ -756,7 +756,7 @@ static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p, GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); GPR_TIMER_MARK("kick_anonymous", 0); specific_worker = pop_front_worker(p); - if (specific_worker != NULL) { + if (specific_worker != nullptr) { if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) { GPR_TIMER_MARK("kick_anonymous_not_self", 0); push_back_worker(p, specific_worker); @@ -765,10 +765,10 @@ static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p, gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) { push_back_worker(p, specific_worker); - specific_worker = NULL; + specific_worker = nullptr; } } - if (specific_worker != NULL) { + if (specific_worker != nullptr) { GPR_TIMER_MARK("finally_kick", 0); push_back_worker(p, specific_worker); kick_append_error( @@ -812,12 +812,12 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { pollset->shutting_down = 0; pollset->called_shutdown = 0; pollset->kicked_without_pollers = 0; - pollset->idle_jobs.head = pollset->idle_jobs.tail = NULL; - pollset->local_wakeup_cache = NULL; + pollset->idle_jobs.head = pollset->idle_jobs.tail = nullptr; + pollset->local_wakeup_cache = nullptr; pollset->kicked_without_pollers = 0; pollset->fd_count = 0; pollset->fd_capacity = 0; - pollset->fds = NULL; + pollset->fds = nullptr; pollset->pollset_set_count = 0; } @@ -850,7 +850,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, } pollset->fds[pollset->fd_count++] = fd; GRPC_FD_REF(fd, "multipoller"); - pollset_kick(exec_ctx, pollset, NULL); + pollset_kick(exec_ctx, pollset, nullptr); exit: gpr_mu_unlock(&pollset->mu); } @@ -892,9 +892,9 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, int keep_polling = 0; GPR_TIMER_BEGIN("pollset_work", 0); /* this must happen before we (potentially) drop pollset->mu */ - worker.next = worker.prev = NULL; + worker.next = worker.prev = nullptr; worker.reevaluate_polling_on_wakeup = 0; - if (pollset->local_wakeup_cache != NULL) { + if (pollset->local_wakeup_cache != nullptr) { worker.wakeup_fd = pollset->local_wakeup_cache; pollset->local_wakeup_cache = worker.wakeup_fd->next; } else { @@ -1002,8 +1002,8 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, } for (i = 1; i < pfd_count; i++) { - if (watchers[i].fd == NULL) { - fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL); + if (watchers[i].fd == nullptr) { + fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr); } else { // Wake up all the file descriptors, if we have an invalid one // we can identify it on the next pollset_work() @@ -1012,7 +1012,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, } } else if (r == 0) { for (i = 1; i < pfd_count; i++) { - fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL); + fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr); } } else { if (pfds[0].revents & POLLIN_CHECK) { @@ -1023,8 +1023,8 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, &error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd)); } for (i = 1; i < pfd_count; i++) { - if (watchers[i].fd == NULL) { - fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL); + if (watchers[i].fd == nullptr) { + fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr); } else { if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset, @@ -1083,7 +1083,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, /* check shutdown conditions */ if (pollset->shutting_down) { if (pollset_has_workers(pollset)) { - pollset_kick(exec_ctx, pollset, NULL); + pollset_kick(exec_ctx, pollset, nullptr); } else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) { pollset->called_shutdown = 1; gpr_mu_unlock(&pollset->mu); @@ -1101,7 +1101,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, gpr_mu_lock(&pollset->mu); } } - if (worker_hdl) *worker_hdl = NULL; + if (worker_hdl) *worker_hdl = nullptr; GPR_TIMER_END("pollset_work", 0); GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error)); return error; @@ -1319,7 +1319,7 @@ static void cache_insert_locked(poll_args* args) { poll_cache.active_pollers[key]->prev = args; } args->next = poll_cache.active_pollers[key]; - args->prev = NULL; + args->prev = nullptr; poll_cache.active_pollers[key] = args; poll_cache.count++; } @@ -1327,7 +1327,7 @@ static void cache_insert_locked(poll_args* args) { static void init_result(poll_args* pargs) { pargs->result = (poll_result*)gpr_malloc(sizeof(poll_result)); gpr_ref_init(&pargs->result->refcount, 1); - pargs->result->watchers = NULL; + pargs->result->watchers = nullptr; pargs->result->watchcount = 0; pargs->result->fds = (struct pollfd*)gpr_malloc(sizeof(struct pollfd) * pargs->nfds); @@ -1358,12 +1358,12 @@ static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) { poll_args* pargs = poll_cache.free_pollers; poll_cache.free_pollers = pargs->next; if (poll_cache.free_pollers) { - poll_cache.free_pollers->prev = NULL; + poll_cache.free_pollers->prev = nullptr; } pargs->fds = fds; pargs->nfds = count; - pargs->next = NULL; - pargs->prev = NULL; + pargs->next = nullptr; + pargs->prev = nullptr; init_result(pargs); cache_poller_locked(pargs); return pargs; @@ -1373,8 +1373,8 @@ static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) { gpr_cv_init(&pargs->trigger); pargs->fds = fds; pargs->nfds = count; - pargs->next = NULL; - pargs->prev = NULL; + pargs->next = nullptr; + pargs->prev = nullptr; pargs->trigger_set = 0; init_result(pargs); cache_poller_locked(pargs); @@ -1405,7 +1405,7 @@ static void cache_delete_locked(poll_args* args) { if (poll_cache.free_pollers) { poll_cache.free_pollers->prev = args; } - args->prev = NULL; + args->prev = nullptr; args->next = poll_cache.free_pollers; gpr_free(args->fds); poll_cache.free_pollers = args; @@ -1419,11 +1419,11 @@ static void cache_poller_locked(poll_args* args) { poll_cache.active_pollers = (poll_args**)gpr_malloc(sizeof(void*) * poll_cache.size); for (unsigned int i = 0; i < poll_cache.size; i++) { - poll_cache.active_pollers[i] = NULL; + poll_cache.active_pollers[i] = nullptr; } for (unsigned int i = 0; i < poll_cache.size / 2; i++) { poll_args* curr = old_active_pollers[i]; - poll_args* next = NULL; + poll_args* next = nullptr; while (curr) { next = curr->next; cache_insert_locked(curr); @@ -1520,10 +1520,10 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) { cv_node* pollcv; int skip_poll = 0; nfds_t nsockfds = 0; - poll_result* result = NULL; + poll_result* result = nullptr; gpr_mu_lock(&g_cvfds.mu); pollcv = (cv_node*)gpr_malloc(sizeof(cv_node)); - pollcv->next = NULL; + pollcv->next = nullptr; gpr_cv pollcv_cv; gpr_cv_init(&pollcv_cv); pollcv->cv = &pollcv_cv; @@ -1534,7 +1534,7 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) { if (fds[i].fd < 0 && (fds[i].events & POLLIN)) { idx = GRPC_FD_TO_IDX(fds[i].fd); fd_cvs[i].cv = &pollcv_cv; - fd_cvs[i].prev = NULL; + fd_cvs[i].prev = nullptr; fd_cvs[i].next = g_cvfds.cvfds[idx].cvs; if (g_cvfds.cvfds[idx].cvs) { g_cvfds.cvfds[idx].cvs->prev = &(fd_cvs[i]); @@ -1573,7 +1573,7 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) { poll_args* pargs = get_poller_locked(pollfds, nsockfds); result = pargs->result; pollcv->next = result->watchers; - pollcv->prev = NULL; + pollcv->prev = nullptr; if (result->watchers) { result->watchers->prev = pollcv; } @@ -1624,11 +1624,11 @@ static void global_cv_fd_table_init() { gpr_ref_init(&g_cvfds.pollcount, 1); g_cvfds.size = CV_DEFAULT_TABLE_SIZE; g_cvfds.cvfds = (fd_node*)gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE); - g_cvfds.free_fds = NULL; + g_cvfds.free_fds = nullptr; thread_grace = gpr_time_from_millis(POLLCV_THREAD_GRACE_MS, GPR_TIMESPAN); for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) { g_cvfds.cvfds[i].is_set = 0; - g_cvfds.cvfds[i].cvs = NULL; + g_cvfds.cvfds[i].cvs = nullptr; g_cvfds.cvfds[i].next_free = g_cvfds.free_fds; g_cvfds.free_fds = &g_cvfds.cvfds[i]; } @@ -1639,10 +1639,10 @@ static void global_cv_fd_table_init() { // Initialize the cache poll_cache.size = 32; poll_cache.count = 0; - poll_cache.free_pollers = NULL; + poll_cache.free_pollers = nullptr; poll_cache.active_pollers = (poll_args**)gpr_malloc(sizeof(void*) * 32); for (unsigned int i = 0; i < poll_cache.size; i++) { - poll_cache.active_pollers[i] = NULL; + poll_cache.active_pollers[i] = nullptr; } gpr_mu_unlock(&g_cvfds.mu); @@ -1713,10 +1713,10 @@ static const grpc_event_engine_vtable vtable = { const grpc_event_engine_vtable* grpc_init_poll_posix(bool explicit_request) { if (!grpc_has_wakeup_fd()) { gpr_log(GPR_ERROR, "Skipping poll because of no wakeup fd."); - return NULL; + return nullptr; } if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) { - return NULL; + return nullptr; } return &vtable; } @@ -1727,7 +1727,7 @@ const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request) { if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) { global_cv_fd_table_shutdown(); grpc_enable_cv_wakeup_fds(0); - return NULL; + return nullptr; } return &vtable; } diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index a05279a4aa..076d2e6bab 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -51,7 +51,7 @@ grpc_poll_function_type grpc_poll_function = poll; grpc_wakeup_fd grpc_global_wakeup_fd; static const grpc_event_engine_vtable* g_event_engine; -static const char* g_poll_strategy_name = NULL; +static const char* g_poll_strategy_name = nullptr; typedef const grpc_event_engine_vtable* (*event_engine_factory_fn)( bool explicit_request); @@ -114,7 +114,7 @@ static void add(const char* beg, const char* end, char*** ss, size_t* ns) { static void split(const char* s, char*** ss, size_t* ns) { const char* c = strchr(s, ','); - if (c == NULL) { + if (c == nullptr) { add(s, s + strlen(s), ss, ns); } else { add(s, c, ss, ns); @@ -156,15 +156,15 @@ void grpc_event_engine_init(void) { grpc_register_tracer(&grpc_polling_trace); char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s == NULL) { + if (s == nullptr) { s = gpr_strdup("all"); } - char** strings = NULL; + char** strings = nullptr; size_t nstrings = 0; split(s, &strings, &nstrings); - for (size_t i = 0; g_event_engine == NULL && i < nstrings; i++) { + for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) { try_engine(strings[i]); } @@ -173,7 +173,7 @@ void grpc_event_engine_init(void) { } gpr_free(strings); - if (g_event_engine == NULL) { + if (g_event_engine == nullptr) { gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s); abort(); } @@ -182,7 +182,7 @@ void grpc_event_engine_init(void) { void grpc_event_engine_shutdown(void) { g_event_engine->shutdown_engine(); - g_event_engine = NULL; + g_event_engine = nullptr; } grpc_fd* grpc_fd_create(int fd, const char* name) { diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index 423e8d059f..27c769a7ed 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -50,7 +50,7 @@ bool grpc_always_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored) { } bool grpc_exec_ctx_has_work(grpc_exec_ctx* exec_ctx) { - return exec_ctx->active_combiner != NULL || + return exec_ctx->active_combiner != nullptr || !grpc_closure_list_empty(exec_ctx->closure_list); } @@ -85,8 +85,8 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx) { for (;;) { if (!grpc_closure_list_empty(exec_ctx->closure_list)) { grpc_closure* c = exec_ctx->closure_list.head; - exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL; - while (c != NULL) { + exec_ctx->closure_list.head = exec_ctx->closure_list.tail = nullptr; + while (c != nullptr) { grpc_closure* next = c->next_data.next; grpc_error* error = c->error_data.error; did_something = true; @@ -97,7 +97,7 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx) { break; } } - GPR_ASSERT(exec_ctx->active_combiner == NULL); + GPR_ASSERT(exec_ctx->active_combiner == nullptr); GPR_TIMER_END("grpc_exec_ctx_flush", 0); return did_something; } diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 2786492494..6097d66024 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -60,7 +60,7 @@ static size_t run_closures(grpc_exec_ctx* exec_ctx, grpc_closure_list list) { size_t n = 0; grpc_closure* c = list.head; - while (c != NULL) { + while (c != nullptr) { grpc_closure* next = c->next_data.next; grpc_error* error = c->error_data.error; if (GRPC_TRACER_ON(executor_trace)) { @@ -148,7 +148,7 @@ static void executor_thread(void* arg) { gpr_tls_set(&g_this_thread_state, (intptr_t)ts); grpc_exec_ctx exec_ctx = - GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL); + GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr); size_t subtract_depth = 0; for (;;) { @@ -208,7 +208,7 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure, return; } thread_state* ts = (thread_state*)gpr_tls_get(&g_this_thread_state); - if (ts == NULL) { + if (ts == nullptr) { ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)]; } else { GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx); diff --git a/src/core/lib/iomgr/gethostname_host_name_max.cc b/src/core/lib/iomgr/gethostname_host_name_max.cc index 987ff1eac1..2487160916 100644 --- a/src/core/lib/iomgr/gethostname_host_name_max.cc +++ b/src/core/lib/iomgr/gethostname_host_name_max.cc @@ -30,7 +30,7 @@ char* grpc_gethostname() { char* hostname = (char*)gpr_malloc(HOST_NAME_MAX); if (gethostname(hostname, HOST_NAME_MAX) != 0) { gpr_free(hostname); - return NULL; + return nullptr; } return hostname; } diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h index ff9b31efe2..d112c50538 100644 --- a/src/core/lib/iomgr/iocp_windows.h +++ b/src/core/lib/iomgr/iocp_windows.h @@ -21,6 +21,10 @@ #include <grpc/support/sync.h> +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_WINSOCK_SOCKET + #include "src/core/lib/iomgr/socket_windows.h" #ifdef __cplusplus @@ -45,4 +49,6 @@ void grpc_iocp_add_socket(grpc_winsocket*); } #endif +#endif + #endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc index 86ea08e901..e077b35014 100644 --- a/src/core/lib/iomgr/iomgr.cc +++ b/src/core/lib/iomgr/iomgr.cc @@ -100,7 +100,7 @@ void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx) { } exec_ctx->now_is_valid = true; exec_ctx->now = GRPC_MILLIS_INF_FUTURE; - if (grpc_timer_check(exec_ctx, NULL) == GRPC_TIMERS_FIRED) { + if (grpc_timer_check(exec_ctx, nullptr) == GRPC_TIMERS_FIRED) { gpr_mu_unlock(&g_mu); grpc_exec_ctx_flush(exec_ctx); grpc_iomgr_platform_flush(); diff --git a/src/core/lib/iomgr/is_epollexclusive_available.cc b/src/core/lib/iomgr/is_epollexclusive_available.cc index d08844c0df..e5803532e7 100644 --- a/src/core/lib/iomgr/is_epollexclusive_available.cc +++ b/src/core/lib/iomgr/is_epollexclusive_available.cc @@ -62,7 +62,7 @@ bool grpc_is_epollexclusive_available(void) { EPOLLEXCLUSIVE enabled kernels - specifically the combination of EPOLLONESHOT and EPOLLEXCLUSIVE */ ev.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE | EPOLLONESHOT); - ev.data.ptr = NULL; + ev.data.ptr = nullptr; if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) { if (errno != EINVAL) { if (!logged_why_not) { diff --git a/src/core/lib/iomgr/load_file.cc b/src/core/lib/iomgr/load_file.cc index 97e448fb32..4a05de1410 100644 --- a/src/core/lib/iomgr/load_file.cc +++ b/src/core/lib/iomgr/load_file.cc @@ -30,7 +30,7 @@ grpc_error* grpc_load_file(const char* filename, int add_null_terminator, grpc_slice* output) { - unsigned char* contents = NULL; + unsigned char* contents = nullptr; size_t contents_size = 0; grpc_slice result = grpc_empty_slice(); FILE* file; @@ -39,7 +39,7 @@ grpc_error* grpc_load_file(const char* filename, int add_null_terminator, GRPC_SCHEDULING_START_BLOCKING_REGION; file = fopen(filename, "rb"); - if (file == NULL) { + if (file == nullptr) { error = GRPC_OS_ERROR(errno, "fopen"); goto end; } @@ -62,7 +62,7 @@ grpc_error* grpc_load_file(const char* filename, int add_null_terminator, end: *output = result; - if (file != NULL) fclose(file); + if (file != nullptr) fclose(file); if (error != GRPC_ERROR_NONE) { grpc_error* error_out = grpc_error_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( diff --git a/src/core/lib/iomgr/polling_entity.cc b/src/core/lib/iomgr/polling_entity.cc index f0ef2cfe3d..0ee4ea1255 100644 --- a/src/core/lib/iomgr/polling_entity.cc +++ b/src/core/lib/iomgr/polling_entity.cc @@ -41,7 +41,7 @@ grpc_pollset* grpc_polling_entity_pollset(grpc_polling_entity* pollent) { if (pollent->tag == GRPC_POLLS_POLLSET) { return pollent->pollent.pollset; } - return NULL; + return nullptr; } grpc_pollset_set* grpc_polling_entity_pollset_set( @@ -49,7 +49,7 @@ grpc_pollset_set* grpc_polling_entity_pollset_set( if (pollent->tag == GRPC_POLLS_POLLSET_SET) { return pollent->pollent.pollset_set; } - return NULL; + return nullptr; } bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent) { @@ -60,10 +60,10 @@ void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_polling_entity* pollent, grpc_pollset_set* pss_dst) { if (pollent->tag == GRPC_POLLS_POLLSET) { - GPR_ASSERT(pollent->pollent.pollset != NULL); + GPR_ASSERT(pollent->pollent.pollset != nullptr); grpc_pollset_set_add_pollset(exec_ctx, pss_dst, pollent->pollent.pollset); } else if (pollent->tag == GRPC_POLLS_POLLSET_SET) { - GPR_ASSERT(pollent->pollent.pollset_set != NULL); + GPR_ASSERT(pollent->pollent.pollset_set != nullptr); grpc_pollset_set_add_pollset_set(exec_ctx, pss_dst, pollent->pollent.pollset_set); } else { @@ -76,10 +76,10 @@ void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx* exec_ctx, grpc_polling_entity* pollent, grpc_pollset_set* pss_dst) { if (pollent->tag == GRPC_POLLS_POLLSET) { - GPR_ASSERT(pollent->pollent.pollset != NULL); + GPR_ASSERT(pollent->pollent.pollset != nullptr); grpc_pollset_set_del_pollset(exec_ctx, pss_dst, pollent->pollent.pollset); } else if (pollent->tag == GRPC_POLLS_POLLSET_SET) { - GPR_ASSERT(pollent->pollent.pollset_set != NULL); + GPR_ASSERT(pollent->pollent.pollset_set != nullptr); grpc_pollset_set_del_pollset_set(exec_ctx, pss_dst, pollent->pollent.pollset_set); } else { diff --git a/src/core/lib/iomgr/pollset_windows.h b/src/core/lib/iomgr/pollset_windows.h index aaeb5f585f..f6da9da601 100644 --- a/src/core/lib/iomgr/pollset_windows.h +++ b/src/core/lib/iomgr/pollset_windows.h @@ -21,6 +21,9 @@ #include <grpc/support/sync.h> +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_WINSOCK_SOCKET #include "src/core/lib/iomgr/socket_windows.h" #ifdef __cplusplus @@ -68,4 +71,6 @@ void grpc_pollset_global_shutdown(void); } #endif +#endif + #endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index e27c730204..fb5fa9d422 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -43,7 +43,7 @@ static grpc_error* blocking_resolve_address_impl( const char* name, const char* default_port, grpc_resolved_addresses** addresses) { struct addrinfo hints; - struct addrinfo *result = NULL, *resp; + struct addrinfo *result = nullptr, *resp; char* host; char* port; int s; @@ -57,14 +57,14 @@ static grpc_error* blocking_resolve_address_impl( /* parse name, splitting it into host and port parts */ gpr_split_host_port(name, &host, &port); - if (host == NULL) { + if (host == nullptr) { err = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"), GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); goto done; } - if (port == NULL) { - if (default_port == NULL) { + if (port == nullptr) { + if (default_port == nullptr) { err = grpc_error_set_str( GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"), GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name)); @@ -115,13 +115,13 @@ static grpc_error* blocking_resolve_address_impl( *addresses = (grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses)); (*addresses)->naddrs = 0; - for (resp = result; resp != NULL; resp = resp->ai_next) { + for (resp = result; resp != nullptr; resp = resp->ai_next) { (*addresses)->naddrs++; } (*addresses)->addrs = (grpc_resolved_address*)gpr_malloc( sizeof(grpc_resolved_address) * (*addresses)->naddrs); i = 0; - for (resp = result; resp != NULL; resp = resp->ai_next) { + for (resp = result; resp != nullptr; resp = resp->ai_next) { memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen); (*addresses)->addrs[i].len = resp->ai_addrlen; i++; @@ -164,7 +164,7 @@ static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp, } void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) { - if (addrs != NULL) { + if (addrs != nullptr) { gpr_free(addrs->addrs); } gpr_free(addrs); diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index 5077554a56..9a44fa203c 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -166,7 +166,7 @@ static void rulist_add_head(grpc_resource_user* resource_user, grpc_rulist list) { grpc_resource_quota* resource_quota = resource_user->resource_quota; grpc_resource_user** root = &resource_quota->roots[list]; - if (*root == NULL) { + if (*root == nullptr) { *root = resource_user; resource_user->links[list].next = resource_user->links[list].prev = resource_user; @@ -183,7 +183,7 @@ static void rulist_add_tail(grpc_resource_user* resource_user, grpc_rulist list) { grpc_resource_quota* resource_quota = resource_user->resource_quota; grpc_resource_user** root = &resource_quota->roots[list]; - if (*root == NULL) { + if (*root == nullptr) { *root = resource_user; resource_user->links[list].next = resource_user->links[list].prev = resource_user; @@ -197,18 +197,18 @@ static void rulist_add_tail(grpc_resource_user* resource_user, static bool rulist_empty(grpc_resource_quota* resource_quota, grpc_rulist list) { - return resource_quota->roots[list] == NULL; + return resource_quota->roots[list] == nullptr; } static grpc_resource_user* rulist_pop_head(grpc_resource_quota* resource_quota, grpc_rulist list) { grpc_resource_user** root = &resource_quota->roots[list]; grpc_resource_user* resource_user = *root; - if (resource_user == NULL) { - return NULL; + if (resource_user == nullptr) { + return nullptr; } if (resource_user->links[list].next == resource_user) { - *root = NULL; + *root = nullptr; } else { resource_user->links[list].next->links[list].prev = resource_user->links[list].prev; @@ -216,24 +216,24 @@ static grpc_resource_user* rulist_pop_head(grpc_resource_quota* resource_quota, resource_user->links[list].next; *root = resource_user->links[list].next; } - resource_user->links[list].next = resource_user->links[list].prev = NULL; + resource_user->links[list].next = resource_user->links[list].prev = nullptr; return resource_user; } static void rulist_remove(grpc_resource_user* resource_user, grpc_rulist list) { - if (resource_user->links[list].next == NULL) return; + if (resource_user->links[list].next == nullptr) return; grpc_resource_quota* resource_quota = resource_user->resource_quota; if (resource_quota->roots[list] == resource_user) { resource_quota->roots[list] = resource_user->links[list].next; if (resource_quota->roots[list] == resource_user) { - resource_quota->roots[list] = NULL; + resource_quota->roots[list] = nullptr; } } resource_user->links[list].next->links[list].prev = resource_user->links[list].prev; resource_user->links[list].prev->links[list].next = resource_user->links[list].next; - resource_user->links[list].next = resource_user->links[list].prev = NULL; + resource_user->links[list].next = resource_user->links[list].prev = nullptr; } /******************************************************************************* @@ -380,7 +380,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx, grpc_rulist list = destructive ? GRPC_RULIST_RECLAIMER_DESTRUCTIVE : GRPC_RULIST_RECLAIMER_BENIGN; grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list); - if (resource_user == NULL) return false; + if (resource_user == nullptr) return false; if (GRPC_TRACER_ON(grpc_resource_quota_trace)) { gpr_log(GPR_DEBUG, "RQ %s %s: initiate %s reclamation", resource_quota->name, resource_user->name, @@ -392,7 +392,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx, GPR_ASSERT(c); resource_quota->debug_only_last_reclaimer_resource_user = resource_user; resource_quota->debug_only_last_initiated_reclaimer = c; - resource_user->reclaimers[destructive] = NULL; + resource_user->reclaimers[destructive] = nullptr; GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_NONE); return true; } @@ -471,9 +471,9 @@ static bool ru_post_reclaimer(grpc_exec_ctx* exec_ctx, grpc_resource_user* resource_user, bool destructive) { grpc_closure* closure = resource_user->new_reclaimers[destructive]; - GPR_ASSERT(closure != NULL); - resource_user->new_reclaimers[destructive] = NULL; - GPR_ASSERT(resource_user->reclaimers[destructive] == NULL); + GPR_ASSERT(closure != nullptr); + resource_user->new_reclaimers[destructive] = nullptr; + GPR_ASSERT(resource_user->reclaimers[destructive] == nullptr); if (gpr_atm_acq_load(&resource_user->shutdown) > 0) { GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CANCELLED); return false; @@ -523,8 +523,8 @@ static void ru_shutdown(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) { GRPC_ERROR_CANCELLED); GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1], GRPC_ERROR_CANCELLED); - resource_user->reclaimers[0] = NULL; - resource_user->reclaimers[1] = NULL; + resource_user->reclaimers[0] = nullptr; + resource_user->reclaimers[1] = nullptr; rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN); rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE); if (resource_user->allocating) { @@ -612,7 +612,7 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) { resource_quota->step_scheduled = false; resource_quota->reclaiming = false; gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, 0); - if (name != NULL) { + if (name != nullptr) { resource_quota->name = gpr_strdup(name); } else { gpr_asprintf(&resource_quota->name, "anonymous_pool_%" PRIxPTR, @@ -624,7 +624,7 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) { rq_reclamation_done, resource_quota, grpc_combiner_scheduler(resource_quota->combiner)); for (int i = 0; i < GRPC_RULIST_COUNT; i++) { - resource_quota->roots[i] = NULL; + resource_quota->roots[i] = nullptr; } return resource_quota; } @@ -697,7 +697,7 @@ grpc_resource_quota* grpc_resource_quota_from_channel_args( } } } - return grpc_resource_quota_create(NULL); + return grpc_resource_quota_create(nullptr); } static void* rq_copy(void* rq) { @@ -747,15 +747,15 @@ grpc_resource_user* grpc_resource_user_create( grpc_closure_list_init(&resource_user->on_allocated); resource_user->allocating = false; resource_user->added_to_free_pool = false; - resource_user->reclaimers[0] = NULL; - resource_user->reclaimers[1] = NULL; - resource_user->new_reclaimers[0] = NULL; - resource_user->new_reclaimers[1] = NULL; + resource_user->reclaimers[0] = nullptr; + resource_user->reclaimers[1] = nullptr; + resource_user->new_reclaimers[0] = nullptr; + resource_user->new_reclaimers[1] = nullptr; resource_user->outstanding_allocations = 0; for (int i = 0; i < GRPC_RULIST_COUNT; i++) { - resource_user->links[i].next = resource_user->links[i].prev = NULL; + resource_user->links[i].next = resource_user->links[i].prev = nullptr; } - if (name != NULL) { + if (name != nullptr) { resource_user->name = gpr_strdup(name); } else { gpr_asprintf(&resource_user->name, "anonymous_resource_user_%" PRIxPTR, @@ -858,7 +858,7 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx, grpc_resource_user* resource_user, bool destructive, grpc_closure* closure) { - GPR_ASSERT(resource_user->new_reclaimers[destructive] == NULL); + GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr); resource_user->new_reclaimers[destructive] = closure; GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->post_reclaimer_closure[destructive], @@ -900,6 +900,6 @@ void grpc_resource_user_alloc_slices( grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx* exec_ctx, grpc_resource_user* resource_user, size_t size) { - grpc_resource_user_alloc(exec_ctx, resource_user, size, NULL); + grpc_resource_user_alloc(exec_ctx, resource_user, size, nullptr); return ru_slice_create(resource_user, size); } diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc index 2dbc5aa6e7..3477fb52cd 100644 --- a/src/core/lib/iomgr/sockaddr_utils.cc +++ b/src/core/lib/iomgr/sockaddr_utils.cc @@ -41,14 +41,14 @@ int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* resolved_addr, GPR_ASSERT(resolved_addr != resolved_addr4_out); const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr; struct sockaddr_in* addr4_out = - resolved_addr4_out == NULL - ? NULL + resolved_addr4_out == nullptr + ? nullptr : (struct sockaddr_in*)resolved_addr4_out->addr; if (addr->sa_family == AF_INET6) { const struct sockaddr_in6* addr6 = (const struct sockaddr_in6*)addr; if (memcmp(addr6->sin6_addr.s6_addr, kV4MappedPrefix, sizeof(kV4MappedPrefix)) == 0) { - if (resolved_addr4_out != NULL) { + if (resolved_addr4_out != nullptr) { /* Normalize ::ffff:0.0.0.0/96 to IPv4. */ memset(resolved_addr4_out, 0, sizeof(*resolved_addr4_out)); addr4_out->sin_family = AF_INET; @@ -147,12 +147,12 @@ int grpc_sockaddr_to_string(char** out, const int save_errno = errno; grpc_resolved_address addr_normalized; char ntop_buf[INET6_ADDRSTRLEN]; - const void* ip = NULL; + const void* ip = nullptr; int port; uint32_t sin6_scope_id = 0; int ret; - *out = NULL; + *out = nullptr; if (normalize && grpc_sockaddr_is_v4mapped(resolved_addr, &addr_normalized)) { resolved_addr = &addr_normalized; } @@ -167,8 +167,8 @@ int grpc_sockaddr_to_string(char** out, port = ntohs(addr6->sin6_port); sin6_scope_id = addr6->sin6_scope_id; } - if (ip != NULL && - grpc_inet_ntop(addr->sa_family, ip, ntop_buf, sizeof(ntop_buf)) != NULL) { + if (ip != nullptr && grpc_inet_ntop(addr->sa_family, ip, ntop_buf, + sizeof(ntop_buf)) != nullptr) { if (sin6_scope_id != 0) { char* host_with_scope; /* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */ @@ -192,18 +192,18 @@ char* grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) { resolved_addr = &addr_normalized; } const char* scheme = grpc_sockaddr_get_uri_scheme(resolved_addr); - if (scheme == NULL || strcmp("unix", scheme) == 0) { + if (scheme == nullptr || strcmp("unix", scheme) == 0) { return grpc_sockaddr_to_uri_unix_if_possible(resolved_addr); } - char* path = NULL; - char* uri_str = NULL; + char* path = nullptr; + char* uri_str = nullptr; if (grpc_sockaddr_to_string(&path, resolved_addr, false /* suppress errors */) && - scheme != NULL) { + scheme != nullptr) { gpr_asprintf(&uri_str, "%s:%s", scheme, path); } gpr_free(path); - return uri_str != NULL ? uri_str : NULL; + return uri_str != nullptr ? uri_str : nullptr; } const char* grpc_sockaddr_get_uri_scheme( @@ -217,7 +217,7 @@ const char* grpc_sockaddr_get_uri_scheme( case AF_UNIX: return "unix"; } - return NULL; + return nullptr; } int grpc_sockaddr_get_family(const grpc_resolved_address* resolved_addr) { diff --git a/src/core/lib/iomgr/sockaddr_windows.h b/src/core/lib/iomgr/sockaddr_windows.h index cf0f6b914d..20e37c9fc4 100644 --- a/src/core/lib/iomgr/sockaddr_windows.h +++ b/src/core/lib/iomgr/sockaddr_windows.h @@ -19,10 +19,16 @@ #ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H #define GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_WINSOCK_SOCKET + #include <winsock2.h> #include <ws2tcpip.h> // must be included after the above #include <mswsock.h> +#endif + #endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H */ diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 88b757a4ae..2d4b8f0add 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -263,13 +263,13 @@ static grpc_error* error_for_fd(int fd, const grpc_resolved_address* addr) { grpc_error* grpc_create_dualstack_socket( const grpc_resolved_address* resolved_addr, int type, int protocol, grpc_dualstack_mode* dsmode, int* newfd) { - return grpc_create_dualstack_socket_using_factory(NULL, resolved_addr, type, - protocol, dsmode, newfd); + return grpc_create_dualstack_socket_using_factory( + nullptr, resolved_addr, type, protocol, dsmode, newfd); } static int create_socket(grpc_socket_factory* factory, int domain, int type, int protocol) { - return (factory != NULL) + return (factory != nullptr) ? grpc_socket_factory_socket(factory, domain, type, protocol) : socket(domain, type, protocol); } @@ -292,7 +292,7 @@ grpc_error* grpc_create_dualstack_socket_using_factory( return GRPC_ERROR_NONE; } /* If this isn't an IPv4 address, then return whatever we've got. */ - if (!grpc_sockaddr_is_v4mapped(resolved_addr, NULL)) { + if (!grpc_sockaddr_is_v4mapped(resolved_addr, nullptr)) { *dsmode = GRPC_DSMODE_IPV6; return error_for_fd(*newfd, resolved_addr); } diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index 6f6c7a7024..c3ad99d82f 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -20,6 +20,9 @@ #define GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H #include <grpc/support/port_platform.h> +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_WINSOCK_SOCKET #include <winsock2.h> #include <grpc/support/atm.h> @@ -115,4 +118,6 @@ void grpc_socket_become_ready(grpc_exec_ctx* exec_ctx, } #endif +#endif + #endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index e72d70c027..cb0f627c94 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -105,7 +105,7 @@ static void tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) { str); } gpr_mu_lock(&ac->mu); - if (ac->fd != NULL) { + if (ac->fd != nullptr) { grpc_fd_shutdown( exec_ctx, ac->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("connect() timed out")); @@ -147,7 +147,7 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) { gpr_mu_lock(&ac->mu); GPR_ASSERT(ac->fd); fd = ac->fd; - ac->fd = NULL; + ac->fd = nullptr; gpr_mu_unlock(&ac->mu); grpc_timer_cancel(exec_ctx, &ac->alarm); @@ -175,7 +175,7 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) { grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd); *ep = grpc_tcp_client_create_from_fd(exec_ctx, fd, ac->channel_args, ac->addr_str); - fd = NULL; + fd = nullptr; break; case ENOBUFS: /* We will get one of these errors if we have run out of @@ -208,11 +208,11 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) { } finish: - if (fd != NULL) { + if (fd != nullptr) { grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd); - grpc_fd_orphan(exec_ctx, fd, NULL, NULL, false /* already_closed */, + grpc_fd_orphan(exec_ctx, fd, nullptr, nullptr, false /* already_closed */, "tcp_client_orphan"); - fd = NULL; + fd = nullptr; } done = (--ac->refs == 0); gpr_mu_unlock(&ac->mu); @@ -256,7 +256,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx, char* addr_str; grpc_error* error; - *ep = NULL; + *ep = nullptr; /* Use dualstack sockets where available. */ if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) { @@ -296,8 +296,8 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx, } if (errno != EWOULDBLOCK && errno != EINPROGRESS) { - grpc_fd_orphan(exec_ctx, fdobj, NULL, NULL, false /* already_closed */, - "tcp_client_connect_error"); + grpc_fd_orphan(exec_ctx, fdobj, nullptr, nullptr, + false /* already_closed */, "tcp_client_connect_error"); GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_OS_ERROR(errno, "connect")); goto done; } @@ -310,7 +310,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx, ac->fd = fdobj; ac->interested_parties = interested_parties; ac->addr_str = addr_str; - addr_str = NULL; + addr_str = nullptr; gpr_mu_init(&ac->mu); ac->refs = 2; GRPC_CLOSURE_INIT(&ac->write_closure, on_writable, ac, diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index fbbb1762b7..cb90933e31 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -139,7 +139,7 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* bp, GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx); GRPC_LOG_IF_ERROR( "backup_poller:pollset_work", - grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL, deadline)); + grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), nullptr, deadline)); gpr_mu_unlock(p->pollset_mu); /* last "uncovered" notification is the ref that keeps us polling, if we get * there try a cas to release it */ @@ -198,7 +198,8 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) { grpc_executor_scheduler(GRPC_EXECUTOR_LONG)), GRPC_ERROR_NONE); } else { - while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) == NULL) { + while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) == + nullptr) { // spin waiting for backup poller } } @@ -368,8 +369,8 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp, } } - tcp->read_cb = NULL; - tcp->incoming_buffer = NULL; + tcp->read_cb = nullptr; + tcp->incoming_buffer = nullptr; GRPC_CLOSURE_RUN(exec_ctx, cb, error); } @@ -389,11 +390,11 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) { iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]); } - msg.msg_name = NULL; + msg.msg_name = nullptr; msg.msg_namelen = 0; msg.msg_iov = iov; msg.msg_iovlen = (msg_iovlen_type)tcp->incoming_buffer->count; - msg.msg_control = NULL; + msg.msg_control = nullptr; msg.msg_controllen = 0; msg.msg_flags = 0; @@ -504,7 +505,7 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */, static void tcp_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer, grpc_closure* cb) { grpc_tcp* tcp = (grpc_tcp*)ep; - GPR_ASSERT(tcp->read_cb == NULL); + GPR_ASSERT(tcp->read_cb == nullptr); tcp->read_cb = cb; tcp->incoming_buffer = incoming_buffer; grpc_slice_buffer_reset_and_unref_internal(exec_ctx, incoming_buffer); @@ -552,11 +553,11 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp, } GPR_ASSERT(iov_size > 0); - msg.msg_name = NULL; + msg.msg_name = nullptr; msg.msg_namelen = 0; msg.msg_iov = iov; msg.msg_iovlen = iov_size; - msg.msg_control = NULL; + msg.msg_control = nullptr; msg.msg_controllen = 0; msg.msg_flags = 0; @@ -617,7 +618,7 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */, if (error != GRPC_ERROR_NONE) { cb = tcp->write_cb; - tcp->write_cb = NULL; + tcp->write_cb = nullptr; cb->cb(exec_ctx, cb->cb_arg, error); TCP_UNREF(exec_ctx, tcp, "write"); return; @@ -630,7 +631,7 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */, notify_on_write(exec_ctx, tcp); } else { cb = tcp->write_cb; - tcp->write_cb = NULL; + tcp->write_cb = nullptr; if (GRPC_TRACER_ON(grpc_tcp_trace)) { const char* str = grpc_error_string(error); gpr_log(GPR_DEBUG, "write: %s", str); @@ -658,7 +659,7 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, } GPR_TIMER_BEGIN("tcp_write", 0); - GPR_ASSERT(tcp->write_cb == NULL); + GPR_ASSERT(tcp->write_cb == nullptr); if (buf->length == 0) { GPR_TIMER_END("tcp_write", 0); @@ -745,8 +746,8 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd, int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE; int tcp_max_read_chunk_size = 4 * 1024 * 1024; int tcp_min_read_chunk_size = 256; - grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL); - if (channel_args != NULL) { + grpc_resource_quota* resource_quota = grpc_resource_quota_create(nullptr); + if (channel_args != nullptr) { for (size_t i = 0; i < channel_args->num_args; i++) { if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) { @@ -785,11 +786,11 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd, tcp->base.vtable = &vtable; tcp->peer_string = gpr_strdup(peer_string); tcp->fd = grpc_fd_wrapped_fd(em_fd); - tcp->read_cb = NULL; - tcp->write_cb = NULL; - tcp->release_fd_cb = NULL; - tcp->release_fd = NULL; - tcp->incoming_buffer = NULL; + tcp->read_cb = nullptr; + tcp->write_cb = nullptr; + tcp->release_fd_cb = nullptr; + tcp->release_fd = nullptr; + tcp->incoming_buffer = nullptr; tcp->target_length = (double)tcp_read_chunk_size; tcp->min_read_chunk_size = tcp_min_read_chunk_size; tcp->max_read_chunk_size = tcp_max_read_chunk_size; diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index 6fcbac03a2..f84fa9751d 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -77,7 +77,7 @@ grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s = (grpc_tcp_server*)gpr_zalloc(sizeof(grpc_tcp_server)); s->so_reuseport = has_so_reuseport; s->expand_wildcard_addrs = false; - for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) { + for (size_t i = 0; i < (args == nullptr ? 0 : args->num_args); i++) { if (0 == strcmp(GRPC_ARG_ALLOW_REUSEPORT, args->args[i].key)) { if (args->args[i].type == GRPC_ARG_INTEGER) { s->so_reuseport = @@ -102,13 +102,13 @@ grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx, s->active_ports = 0; s->destroyed_ports = 0; s->shutdown = false; - s->shutdown_starting.head = NULL; - s->shutdown_starting.tail = NULL; + s->shutdown_starting.head = nullptr; + s->shutdown_starting.tail = nullptr; s->shutdown_complete = shutdown_complete; - s->on_accept_cb = NULL; - s->on_accept_cb_arg = NULL; - s->head = NULL; - s->tail = NULL; + s->on_accept_cb = nullptr; + s->on_accept_cb_arg = nullptr; + s->head = nullptr; + s->tail = nullptr; s->nports = 0; s->channel_args = grpc_channel_args_copy(args); gpr_atm_no_barrier_store(&s->next_pollset_to_assign, 0); @@ -120,7 +120,7 @@ static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) { gpr_mu_lock(&s->mu); GPR_ASSERT(s->shutdown); gpr_mu_unlock(&s->mu); - if (s->shutdown_complete != NULL) { + if (s->shutdown_complete != nullptr) { GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE); } @@ -165,7 +165,7 @@ static void deactivated_all_ports(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) { grpc_unlink_if_unix_domain_socket(&sp->addr); GRPC_CLOSURE_INIT(&sp->destroyed_closure, destroyed_port, s, grpc_schedule_on_exec_ctx); - grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL, + grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, nullptr, false /* already_closed */, "tcp_listener_shutdown"); } gpr_mu_unlock(&s->mu); @@ -288,8 +288,8 @@ static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s, grpc_resolved_address wild6; unsigned fd_index = 0; grpc_dualstack_mode dsmode; - grpc_tcp_listener* sp = NULL; - grpc_tcp_listener* sp2 = NULL; + grpc_tcp_listener* sp = nullptr; + grpc_tcp_listener* sp2 = nullptr; grpc_error* v6_err = GRPC_ERROR_NONE; grpc_error* v4_err = GRPC_ERROR_NONE; *out_port = -1; @@ -314,7 +314,7 @@ static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s, if ((v4_err = grpc_tcp_server_add_addr(s, &wild4, port_index, fd_index, &dsmode, &sp2)) == GRPC_ERROR_NONE) { *out_port = sp2->port; - if (sp != NULL) { + if (sp != nullptr) { sp2->is_sibling = 1; sp->sibling = sp2; } @@ -346,7 +346,7 @@ static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s, } static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) { - grpc_tcp_listener* sp = NULL; + grpc_tcp_listener* sp = nullptr; char* addr_str; char* name; grpc_error* err; @@ -383,7 +383,7 @@ static grpc_error* clone_port(grpc_tcp_listener* listener, unsigned count) { sp->port_index = listener->port_index; sp->fd_index = listener->fd_index + count - i; GPR_ASSERT(sp->emfd); - while (listener->server->tail->next != NULL) { + while (listener->server->tail->next != nullptr) { listener->server->tail = listener->server->tail->next; } gpr_free(addr_str); @@ -404,7 +404,7 @@ grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s, grpc_dualstack_mode dsmode; grpc_error* err; *out_port = -1; - if (s->tail != NULL) { + if (s->tail != nullptr) { port_index = s->tail->port_index + 1; } grpc_unlink_if_unix_domain_socket(addr); @@ -454,7 +454,7 @@ static grpc_tcp_listener* get_port_index(grpc_tcp_server* s, } } } - return NULL; + return nullptr; } unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server* s, @@ -498,7 +498,7 @@ void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s, s->pollsets = pollsets; s->pollset_count = pollset_count; sp = s->head; - while (sp != NULL) { + while (sp != nullptr) { if (s->so_reuseport && !grpc_is_unix_socket(&sp->addr) && pollset_count > 1) { GPR_ASSERT(GRPC_LOG_IF_ERROR( diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc index 51e6731729..72443cc29e 100644 --- a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +++ b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc @@ -47,7 +47,7 @@ static void init_max_accept_queue_size(void) { int n = SOMAXCONN; char buf[64]; FILE* fp = fopen("/proc/sys/net/core/somaxconn", "r"); - if (fp == NULL) { + if (fp == nullptr) { /* 2.4 kernel. */ s_max_accept_queue_size = SOMAXCONN; return; @@ -79,7 +79,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd, const grpc_resolved_address* addr, unsigned port_index, unsigned fd_index, grpc_tcp_listener** listener) { - grpc_tcp_listener* sp = NULL; + grpc_tcp_listener* sp = nullptr; int port = -1; char* addr_str; char* name; @@ -94,8 +94,8 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd, s->nports++; GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server"); sp = (grpc_tcp_listener*)gpr_malloc(sizeof(grpc_tcp_listener)); - sp->next = NULL; - if (s->head == NULL) { + sp->next = nullptr; + if (s->head == nullptr) { s->head = sp; } else { s->tail->next = sp; @@ -109,7 +109,7 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd, sp->port_index = port_index; sp->fd_index = fd_index; sp->is_sibling = 0; - sp->sibling = NULL; + sp->sibling = nullptr; GPR_ASSERT(sp->emfd); gpr_mu_unlock(&s->mu); gpr_free(addr_str); diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc index b7437dbf4d..227bf94aa7 100644 --- a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +++ b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc @@ -40,7 +40,7 @@ static grpc_tcp_listener* find_listener_with_addr(grpc_tcp_server* s, grpc_resolved_address* addr) { grpc_tcp_listener* l; gpr_mu_lock(&s->mu); - for (l = s->head; l != NULL; l = l->next) { + for (l = s->head; l != nullptr; l = l->next) { if (l->addr.len != addr->len) { continue; } @@ -87,10 +87,10 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s, unsigned port_index, int requested_port, int* out_port) { - struct ifaddrs* ifa = NULL; + struct ifaddrs* ifa = nullptr; struct ifaddrs* ifa_it; unsigned fd_index = 0; - grpc_tcp_listener* sp = NULL; + grpc_tcp_listener* sp = nullptr; grpc_error* err = GRPC_ERROR_NONE; if (requested_port == 0) { /* Note: There could be a race where some local addrs can listen on the @@ -104,16 +104,16 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s, } gpr_log(GPR_DEBUG, "Picked unused port %d", requested_port); } - if (getifaddrs(&ifa) != 0 || ifa == NULL) { + if (getifaddrs(&ifa) != 0 || ifa == nullptr) { return GRPC_OS_ERROR(errno, "getifaddrs"); } - for (ifa_it = ifa; ifa_it != NULL; ifa_it = ifa_it->ifa_next) { + for (ifa_it = ifa; ifa_it != nullptr; ifa_it = ifa_it->ifa_next) { grpc_resolved_address addr; - char* addr_str = NULL; + char* addr_str = nullptr; grpc_dualstack_mode dsmode; - grpc_tcp_listener* new_sp = NULL; + grpc_tcp_listener* new_sp = nullptr; const char* ifa_name = (ifa_it->ifa_name ? ifa_it->ifa_name : "<unknown>"); - if (ifa_it->ifa_addr == NULL) { + if (ifa_it->ifa_addr == nullptr) { continue; } else if (ifa_it->ifa_addr->sa_family == AF_INET) { addr.len = sizeof(struct sockaddr_in); @@ -136,7 +136,7 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s, ifa_name, ifa_it->ifa_flags, addr_str); /* We could have multiple interfaces with the same address (e.g., bonding), so look for duplicates. */ - if (find_listener_with_addr(s, &addr) != NULL) { + if (find_listener_with_addr(s, &addr) != nullptr) { gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s", addr_str, ifa_name); gpr_free(addr_str); @@ -144,7 +144,7 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s, } if ((err = grpc_tcp_server_add_addr(s, &addr, port_index, fd_index, &dsmode, &new_sp)) != GRPC_ERROR_NONE) { - char* err_str = NULL; + char* err_str = nullptr; grpc_error* root_err; if (gpr_asprintf(&err_str, "Failed to add listener: %s", addr_str) < 0) { err_str = gpr_strdup("Failed to add listener"); @@ -157,7 +157,7 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s, } else { GPR_ASSERT(requested_port == new_sp->port); ++fd_index; - if (sp != NULL) { + if (sp != nullptr) { new_sp->is_sibling = 1; sp->sibling = new_sp; } @@ -168,7 +168,7 @@ grpc_error* grpc_tcp_server_add_all_local_addrs(grpc_tcp_server* s, freeifaddrs(ifa); if (err != GRPC_ERROR_NONE) { return err; - } else if (sp == NULL) { + } else if (sp == nullptr) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No local addresses"); } else { *out_port = sp->port; diff --git a/src/core/lib/iomgr/tcp_uv.h b/src/core/lib/iomgr/tcp_uv.h index 8a4914935a..708e8469e6 100644 --- a/src/core/lib/iomgr/tcp_uv.h +++ b/src/core/lib/iomgr/tcp_uv.h @@ -32,6 +32,10 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_UV + #include <uv.h> extern grpc_tracer_flag grpc_tcp_trace; @@ -50,4 +54,6 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle, } #endif +#endif /* GRPC_UV */ + #endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */ diff --git a/src/core/lib/iomgr/tcp_windows.h b/src/core/lib/iomgr/tcp_windows.h index aea5bab47d..9c7ccdf132 100644 --- a/src/core/lib/iomgr/tcp_windows.h +++ b/src/core/lib/iomgr/tcp_windows.h @@ -29,6 +29,9 @@ otherwise specified. */ +#include "src/core/lib/iomgr/port.h" + +#ifdef GRPC_WINSOCK_SOCKET #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/socket_windows.h" @@ -49,4 +52,6 @@ grpc_error* grpc_tcp_prepare_socket(SOCKET sock); } #endif +#endif + #endif /* GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H */ diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc index 38ac66ea2f..a4bfbcb342 100644 --- a/src/core/lib/iomgr/timer_generic.cc +++ b/src/core/lib/iomgr/timer_generic.cc @@ -91,7 +91,7 @@ static timer_shard** g_shard_queue; #define NUM_HASH_BUCKETS 1009 /* Prime number close to 1000 */ static gpr_mu g_hash_mu[NUM_HASH_BUCKETS]; /* One mutex per bucket */ -static grpc_timer* g_timer_ht[NUM_HASH_BUCKETS] = {NULL}; +static grpc_timer* g_timer_ht[NUM_HASH_BUCKETS] = {nullptr}; static void init_timer_ht() { for (int i = 0; i < NUM_HASH_BUCKETS; i++) { @@ -104,7 +104,7 @@ static bool is_in_ht(grpc_timer* t) { gpr_mu_lock(&g_hash_mu[i]); grpc_timer* p = g_timer_ht[i]; - while (p != NULL && p != t) { + while (p != nullptr && p != t) { p = p->hash_table_next; } gpr_mu_unlock(&g_hash_mu[i]); @@ -118,7 +118,7 @@ static void add_to_ht(grpc_timer* t) { gpr_mu_lock(&g_hash_mu[i]); grpc_timer* p = g_timer_ht[i]; - while (p != NULL && p != t) { + while (p != nullptr && p != t) { p = p->hash_table_next; } @@ -146,9 +146,9 @@ static void remove_from_ht(grpc_timer* t) { if (g_timer_ht[i] == t) { g_timer_ht[i] = g_timer_ht[i]->hash_table_next; removed = true; - } else if (g_timer_ht[i] != NULL) { + } else if (g_timer_ht[i] != nullptr) { grpc_timer* p = g_timer_ht[i]; - while (p->hash_table_next != NULL && p->hash_table_next != t) { + while (p->hash_table_next != nullptr && p->hash_table_next != t) { p = p->hash_table_next; } @@ -169,7 +169,7 @@ static void remove_from_ht(grpc_timer* t) { abort(); } - t->hash_table_next = NULL; + t->hash_table_next = nullptr; } /* If a timer is added to a timer shard (either heap or a list), it cannot @@ -275,7 +275,7 @@ void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) { void grpc_timer_list_shutdown(grpc_exec_ctx* exec_ctx) { size_t i; run_some_expired_timers( - exec_ctx, GPR_ATM_MAX, NULL, + exec_ctx, GPR_ATM_MAX, nullptr, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Timer list shutdown")); for (i = 0; i < g_num_shards; i++) { timer_shard* shard = &g_shards[i]; @@ -336,7 +336,7 @@ void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer, timer->deadline = deadline; #ifndef NDEBUG - timer->hash_table_next = NULL; + timer->hash_table_next = nullptr; #endif if (GRPC_TRACER_ON(grpc_timer_trace)) { @@ -499,8 +499,8 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) { grpc_timer_heap_is_empty(&shard->heap) ? "true" : "false"); } if (grpc_timer_heap_is_empty(&shard->heap)) { - if (now < shard->queue_deadline_cap) return NULL; - if (!refill_heap(shard, now)) return NULL; + if (now < shard->queue_deadline_cap) return nullptr; + if (!refill_heap(shard, now)) return nullptr; } timer = grpc_timer_heap_top(&shard->heap); if (GRPC_TRACER_ON(grpc_timer_check_trace)) { @@ -508,7 +508,7 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) { " .. check top timer deadline=%" PRIdPTR " now=%" PRIdPTR, timer->deadline, now); } - if (timer->deadline > now) return NULL; + if (timer->deadline > now) return nullptr; if (GRPC_TRACER_ON(grpc_timer_trace)) { gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late via %s scheduler", timer, now - timer->deadline, @@ -550,7 +550,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx, gpr_atm min_timer = gpr_atm_no_barrier_load(&g_shared_mutables.min_timer); gpr_tls_set(&g_last_seen_min_timer, min_timer); if (now < min_timer) { - if (next != NULL) *next = GPR_MIN(*next, min_timer); + if (next != nullptr) *next = GPR_MIN(*next, min_timer); return GRPC_TIMERS_CHECKED_AND_EMPTY; } @@ -618,7 +618,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx, mutable cacheline in the common case */ grpc_millis min_timer = gpr_tls_get(&g_last_seen_min_timer); if (now < min_timer) { - if (next != NULL) { + if (next != nullptr) { *next = GPR_MIN(*next, min_timer); } if (GRPC_TRACER_ON(grpc_timer_check_trace)) { @@ -637,7 +637,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx, // tracing if (GRPC_TRACER_ON(grpc_timer_check_trace)) { char* next_str; - if (next == NULL) { + if (next == nullptr) { next_str = gpr_strdup("NULL"); } else { gpr_asprintf(&next_str, "%" PRIdPTR, *next); @@ -655,7 +655,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx, // tracing if (GRPC_TRACER_ON(grpc_timer_check_trace)) { char* next_str; - if (next == NULL) { + if (next == nullptr) { next_str = gpr_strdup("NULL"); } else { gpr_asprintf(&next_str, "%" PRIdPTR, *next); diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index bb2a0e0d44..acc40b6c9e 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -62,11 +62,11 @@ static uint64_t g_timed_waiter_generation; static void timer_thread(void* completed_thread_ptr); static void gc_completed_threads(void) { - if (g_completed_threads != NULL) { + if (g_completed_threads != nullptr) { completed_thread* to_gc = g_completed_threads; - g_completed_threads = NULL; + g_completed_threads = nullptr; gpr_mu_unlock(&g_mu); - while (to_gc != NULL) { + while (to_gc != nullptr) { gpr_thd_join(to_gc->t); completed_thread* next = to_gc->next; gpr_free(to_gc); @@ -280,7 +280,7 @@ static void timer_thread(void* completed_thread_ptr) { // this threads exec_ctx: we try to run things through to completion here // since it's easy to spin up new threads grpc_exec_ctx exec_ctx = - GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL); + GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr); timer_main_loop(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx); timer_thread_cleanup((completed_thread*)completed_thread_ptr); @@ -304,7 +304,7 @@ void grpc_timer_manager_init(void) { g_threaded = false; g_thread_count = 0; g_waiter_count = 0; - g_completed_threads = NULL; + g_completed_threads = nullptr; g_has_timed_waiter = false; g_timed_waiter_deadline = GRPC_MILLIS_INF_FUTURE; diff --git a/src/core/lib/iomgr/udp_server.cc b/src/core/lib/iomgr/udp_server.cc index 8ce8b961ff..68ab9355ca 100644 --- a/src/core/lib/iomgr/udp_server.cc +++ b/src/core/lib/iomgr/udp_server.cc @@ -121,7 +121,7 @@ static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) { return (grpc_socket_factory*)arg->value.pointer.p; } } - return NULL; + return nullptr; } grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) { @@ -134,8 +134,8 @@ grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) { s->active_ports = 0; s->destroyed_ports = 0; s->shutdown = 0; - s->head = NULL; - s->tail = NULL; + s->head = nullptr; + s->tail = nullptr; s->nports = 0; return s; @@ -155,7 +155,7 @@ static void dummy_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { } static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) { - if (s->shutdown_complete != NULL) { + if (s->shutdown_complete != nullptr) { GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE); } @@ -213,7 +213,7 @@ static void deactivated_all_ports(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) { sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure, sp->server->user_data); } - grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL, + grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, nullptr, false /* already_closed */, "udp_listener_shutdown"); } gpr_mu_unlock(&s->mu); @@ -256,7 +256,7 @@ void grpc_udp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_udp_server* s, static int bind_socket(grpc_socket_factory* socket_factory, int sockfd, const grpc_resolved_address* addr) { - return (socket_factory != NULL) + return (socket_factory != nullptr) ? grpc_socket_factory_bind(socket_factory, sockfd, addr) : bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len); } @@ -394,8 +394,8 @@ static int add_socket_to_server(grpc_udp_server* s, int fd, gpr_mu_lock(&s->mu); s->nports++; sp = (grpc_udp_listener*)gpr_malloc(sizeof(grpc_udp_listener)); - sp->next = NULL; - if (s->head == NULL) { + sp->next = nullptr; + if (s->head == nullptr) { s->head = sp; } else { s->tail->next = sp; @@ -431,7 +431,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s, grpc_resolved_address wild4; grpc_resolved_address wild6; grpc_resolved_address addr4_copy; - grpc_resolved_address* allocated_addr = NULL; + grpc_resolved_address* allocated_addr = nullptr; grpc_resolved_address sockname_temp; int port; @@ -508,6 +508,7 @@ int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index) { for (sp = s->head; sp && port_index != 0; sp = sp->next) { --port_index; } + GPR_ASSERT(sp); // if this fails, our check earlier was bogus return sp->fd; } @@ -522,7 +523,7 @@ void grpc_udp_server_start(grpc_exec_ctx* exec_ctx, grpc_udp_server* s, s->user_data = user_data; sp = s->head; - while (sp != NULL) { + while (sp != nullptr) { for (i = 0; i < pollset_count; i++) { grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd); } diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc index 5d3689c38f..af862c00dc 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.cc +++ b/src/core/lib/iomgr/unix_sockets_posix.cc @@ -39,7 +39,8 @@ void grpc_create_socketpair_if_unix(int sv[2]) { grpc_error* grpc_resolve_unix_domain_address(const char* name, grpc_resolved_addresses** addrs) { struct sockaddr_un* un; - if (strlen(name) > GPR_ARRAY_SIZE(((struct sockaddr_un*)0)->sun_path) - 1) { + if (strlen(name) > + GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) - 1) { char* err_msg; grpc_error* err; gpr_asprintf(&err_msg, @@ -56,7 +57,7 @@ grpc_error* grpc_resolve_unix_domain_address(const char* name, (grpc_resolved_address*)gpr_malloc(sizeof(grpc_resolved_address)); un = (struct sockaddr_un*)(*addrs)->addrs->addr; un->sun_family = AF_UNIX; - strcpy(un->sun_path, name); + strncpy(un->sun_path, name, sizeof(un->sun_path)); (*addrs)->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1; return GRPC_ERROR_NONE; } @@ -84,7 +85,7 @@ char* grpc_sockaddr_to_uri_unix_if_possible( const grpc_resolved_address* resolved_addr) { const struct sockaddr* addr = (const struct sockaddr*)resolved_addr->addr; if (addr->sa_family != AF_UNIX) { - return NULL; + return nullptr; } char* result; diff --git a/src/core/lib/iomgr/wakeup_fd_cv.cc b/src/core/lib/iomgr/wakeup_fd_cv.cc index 268e0175dd..5c1f16d3fc 100644 --- a/src/core/lib/iomgr/wakeup_fd_cv.cc +++ b/src/core/lib/iomgr/wakeup_fd_cv.cc @@ -46,7 +46,7 @@ static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) { (fd_node*)gpr_realloc(g_cvfds.cvfds, sizeof(fd_node) * newsize); for (i = g_cvfds.size; i < newsize; i++) { g_cvfds.cvfds[i].is_set = 0; - g_cvfds.cvfds[i].cvs = NULL; + g_cvfds.cvfds[i].cvs = nullptr; g_cvfds.cvfds[i].next_free = g_cvfds.free_fds; g_cvfds.free_fds = &g_cvfds.cvfds[i]; } @@ -55,7 +55,7 @@ static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) { idx = (int)(g_cvfds.free_fds - g_cvfds.cvfds); g_cvfds.free_fds = g_cvfds.free_fds->next_free; - g_cvfds.cvfds[idx].cvs = NULL; + g_cvfds.cvfds[idx].cvs = nullptr; g_cvfds.cvfds[idx].is_set = 0; fd_info->read_fd = GRPC_IDX_TO_FD(idx); fd_info->write_fd = -1; diff --git a/src/core/lib/iomgr/wakeup_fd_posix.cc b/src/core/lib/iomgr/wakeup_fd_posix.cc index dcad61b097..e8de208a25 100644 --- a/src/core/lib/iomgr/wakeup_fd_posix.cc +++ b/src/core/lib/iomgr/wakeup_fd_posix.cc @@ -25,7 +25,7 @@ #include "src/core/lib/iomgr/wakeup_fd_pipe.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" -static const grpc_wakeup_fd_vtable* wakeup_fd_vtable = NULL; +static const grpc_wakeup_fd_vtable* wakeup_fd_vtable = nullptr; int grpc_allow_specialized_wakeup_fd = 1; int grpc_allow_pipe_wakeup_fd = 1; @@ -45,7 +45,7 @@ void grpc_wakeup_fd_global_init(void) { } } -void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = NULL; } +void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = nullptr; } int grpc_has_wakeup_fd(void) { return has_real_wakeup_fd; } |