Adding pointer conversions. Renaming a few variables and type names to avoid C++ compilation issues

pull/12499/head
Yash Tibrewal 7 years ago
parent a06e5fdfb7
commit 52778c4729
  1. 4
      src/core/lib/channel/channel_args.c
  2. 16
      src/core/lib/channel/channel_stack_builder.c
  3. 3
      src/core/lib/compression/stream_compression.c
  4. 3
      src/core/lib/iomgr/combiner.c
  5. 34
      src/core/lib/iomgr/error.c
  6. 6
      src/core/lib/iomgr/ev_epoll1_linux.c
  7. 45
      src/core/lib/iomgr/ev_epollex_linux.c
  8. 4
      src/core/lib/iomgr/polling_entity.h
  9. 6
      src/core/lib/iomgr/resource_quota.c
  10. 4
      src/core/lib/iomgr/socket_factory_posix.c
  11. 4
      src/core/lib/iomgr/socket_mutator.c
  12. 2
      src/core/lib/iomgr/timer_manager.c
  13. 2
      src/core/lib/iomgr/udp_server.c
  14. 4
      src/core/lib/slice/slice.c
  15. 58
      src/core/lib/surface/call.c

@ -212,7 +212,7 @@ void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a) {
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
const grpc_channel_args *a) { const grpc_channel_args *a) {
size_t i; size_t i;
if (a == NULL) return 0; if (a == NULL) return GRPC_COMPRESS_NONE;
for (i = 0; i < a->num_args; ++i) { for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER && if (a->args[i].type == GRPC_ARG_INTEGER &&
!strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) { !strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
@ -226,7 +226,7 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
grpc_stream_compression_algorithm grpc_stream_compression_algorithm
grpc_channel_args_get_stream_compression_algorithm(const grpc_channel_args *a) { grpc_channel_args_get_stream_compression_algorithm(const grpc_channel_args *a) {
size_t i; size_t i;
if (a == NULL) return 0; if (a == NULL) return GRPC_STREAM_COMPRESS_NONE;
for (i = 0; i < a->num_args; ++i) { for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER && if (a->args[i].type == GRPC_ARG_INTEGER &&
!strcmp(GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, !strcmp(GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,

@ -214,13 +214,13 @@ bool grpc_channel_stack_builder_prepend_filter(
static void add_after(filter_node *before, const grpc_channel_filter *filter, static void add_after(filter_node *before, const grpc_channel_filter *filter,
grpc_post_filter_create_init_func post_init_func, grpc_post_filter_create_init_func post_init_func,
void *user_data) { void *user_data) {
filter_node *new = (filter_node *)gpr_malloc(sizeof(*new)); filter_node *new_node = (filter_node *)gpr_malloc(sizeof(*new_node));
new->next = before->next; new_node->next = before->next;
new->prev = before; new_node->prev = before;
new->next->prev = new->prev->next = new; new_node->next->prev = new_node->prev->next = new_node;
new->filter = filter; new_node->filter = filter;
new->init = post_init_func; new_node->init = post_init_func;
new->init_arg = user_data; new_node->init_arg = user_data;
} }
bool grpc_channel_stack_builder_add_filter_before( bool grpc_channel_stack_builder_add_filter_before(
@ -268,7 +268,7 @@ grpc_error *grpc_channel_stack_builder_finish(
// create an array of filters // create an array of filters
const grpc_channel_filter **filters = const grpc_channel_filter **filters =
gpr_malloc(sizeof(*filters) * num_filters); (const grpc_channel_filter **)gpr_malloc(sizeof(*filters) * num_filters);
size_t i = 0; size_t i = 0;
for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) { for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
filters[i++] = p->filter; filters[i++] = p->filter;

@ -159,7 +159,8 @@ bool grpc_stream_decompress(grpc_stream_compression_context *ctx,
grpc_stream_compression_context *grpc_stream_compression_context_create( grpc_stream_compression_context *grpc_stream_compression_context_create(
grpc_stream_compression_method method) { grpc_stream_compression_method method) {
grpc_stream_compression_context *ctx = grpc_stream_compression_context *ctx =
gpr_zalloc(sizeof(grpc_stream_compression_context)); (grpc_stream_compression_context *)gpr_zalloc(
sizeof(grpc_stream_compression_context));
int r; int r;
if (ctx == NULL) { if (ctx == NULL) {
return NULL; return NULL;

@ -356,7 +356,8 @@ static void combiner_finally_exec(grpc_exec_ctx *exec_ctx,
static void enqueue_finally(grpc_exec_ctx *exec_ctx, void *closure, static void enqueue_finally(grpc_exec_ctx *exec_ctx, void *closure,
grpc_error *error) { grpc_error *error) {
combiner_finally_exec(exec_ctx, closure, GRPC_ERROR_REF(error)); combiner_finally_exec(exec_ctx, (grpc_closure *)closure,
GRPC_ERROR_REF(error));
} }
grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *combiner) { grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *combiner) {

@ -278,13 +278,13 @@ static void internal_set_time(grpc_error **err, grpc_error_times which,
memcpy((*err)->arena + slot, &value, sizeof(value)); memcpy((*err)->arena + slot, &value, sizeof(value));
} }
static void internal_add_error(grpc_error **err, grpc_error *new) { static void internal_add_error(grpc_error **err, grpc_error *new_err) {
grpc_linked_error new_last = {new, UINT8_MAX}; grpc_linked_error new_last = {new_err, UINT8_MAX};
uint8_t slot = get_placement(err, sizeof(grpc_linked_error)); uint8_t slot = get_placement(err, sizeof(grpc_linked_error));
if (slot == UINT8_MAX) { if (slot == UINT8_MAX) {
gpr_log(GPR_ERROR, "Error %p is full, dropping error %p = %s", *err, new, gpr_log(GPR_ERROR, "Error %p is full, dropping error %p = %s", *err,
grpc_error_string(new)); new_err, grpc_error_string(new_err));
GRPC_ERROR_UNREF(new); GRPC_ERROR_UNREF(new_err);
return; return;
} }
if ((*err)->first_err == UINT8_MAX) { if ((*err)->first_err == UINT8_MAX) {
@ -321,8 +321,8 @@ grpc_error *grpc_error_create(const char *file, int line, grpc_slice desc,
uint8_t initial_arena_capacity = (uint8_t)( uint8_t initial_arena_capacity = (uint8_t)(
DEFAULT_ERROR_CAPACITY + DEFAULT_ERROR_CAPACITY +
(uint8_t)(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY); (uint8_t)(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY);
grpc_error *err = grpc_error *err = (grpc_error *)gpr_malloc(
gpr_malloc(sizeof(*err) + initial_arena_capacity * sizeof(intptr_t)); sizeof(*err) + initial_arena_capacity * sizeof(intptr_t));
if (err == NULL) { // TODO(ctiller): make gpr_malloc return NULL if (err == NULL) { // TODO(ctiller): make gpr_malloc return NULL
return GRPC_ERROR_OOM; return GRPC_ERROR_OOM;
} }
@ -432,10 +432,10 @@ static grpc_error *copy_error_and_unref(grpc_error *in) {
grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which, grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
intptr_t value) { intptr_t value) {
GPR_TIMER_BEGIN("grpc_error_set_int", 0); GPR_TIMER_BEGIN("grpc_error_set_int", 0);
grpc_error *new = copy_error_and_unref(src); grpc_error *new_err = copy_error_and_unref(src);
internal_set_int(&new, which, value); internal_set_int(&new_err, which, value);
GPR_TIMER_END("grpc_error_set_int", 0); GPR_TIMER_END("grpc_error_set_int", 0);
return new; return new_err;
} }
typedef struct { typedef struct {
@ -477,10 +477,10 @@ bool grpc_error_get_int(grpc_error *err, grpc_error_ints which, intptr_t *p) {
grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which, grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
grpc_slice str) { grpc_slice str) {
GPR_TIMER_BEGIN("grpc_error_set_str", 0); GPR_TIMER_BEGIN("grpc_error_set_str", 0);
grpc_error *new = copy_error_and_unref(src); grpc_error *new_err = copy_error_and_unref(src);
internal_set_str(&new, which, str); internal_set_str(&new_err, which, str);
GPR_TIMER_END("grpc_error_set_str", 0); GPR_TIMER_END("grpc_error_set_str", 0);
return new; return new_err;
} }
bool grpc_error_get_str(grpc_error *err, grpc_error_strs which, bool grpc_error_get_str(grpc_error *err, grpc_error_strs which,
@ -507,10 +507,10 @@ bool grpc_error_get_str(grpc_error *err, grpc_error_strs which,
grpc_error *grpc_error_add_child(grpc_error *src, grpc_error *child) { grpc_error *grpc_error_add_child(grpc_error *src, grpc_error *child) {
GPR_TIMER_BEGIN("grpc_error_add_child", 0); GPR_TIMER_BEGIN("grpc_error_add_child", 0);
grpc_error *new = copy_error_and_unref(src); grpc_error *new_err = copy_error_and_unref(src);
internal_add_error(&new, child); internal_add_error(&new_err, child);
GPR_TIMER_END("grpc_error_add_child", 0); GPR_TIMER_END("grpc_error_add_child", 0);
return new; return new_err;
} }
static const char *no_error_string = "\"No Error\""; static const char *no_error_string = "\"No Error\"";
@ -733,7 +733,7 @@ const char *grpc_error_string(grpc_error *err) {
void *p = (void *)gpr_atm_acq_load(&err->atomics.error_string); void *p = (void *)gpr_atm_acq_load(&err->atomics.error_string);
if (p != NULL) { if (p != NULL) {
GPR_TIMER_END("grpc_error_string", 0); GPR_TIMER_END("grpc_error_string", 0);
return p; return (const char *)p;
} }
kv_pairs kvs; kv_pairs kvs;

@ -130,9 +130,9 @@ static void fd_global_shutdown(void);
* Pollset Declarations * Pollset Declarations
*/ */
typedef enum { UNKICKED, KICKED, DESIGNATED_POLLER } kick_state; typedef enum { UNKICKED, KICKED, DESIGNATED_POLLER } kick_state_t;
static const char *kick_state_string(kick_state st) { static const char *kick_state_string(kick_state_t st) {
switch (st) { switch (st) {
case UNKICKED: case UNKICKED:
return "UNKICKED"; return "UNKICKED";
@ -145,7 +145,7 @@ static const char *kick_state_string(kick_state st) {
} }
struct grpc_pollset_worker { struct grpc_pollset_worker {
kick_state kick_state; kick_state_t kick_state;
int kick_state_mutator; // which line of code last changed kick state int kick_state_mutator; // which line of code last changed kick state
bool initialized_cv; bool initialized_cv;
grpc_pollset_worker *next; grpc_pollset_worker *next;

@ -97,12 +97,12 @@ static void pg_join(grpc_exec_ctx *exec_ctx, polling_group *pg,
* pollable Declarations * pollable Declarations
*/ */
typedef struct pollable { typedef struct pollable_t {
polling_obj po; polling_obj po;
int epfd; int epfd;
grpc_wakeup_fd wakeup; grpc_wakeup_fd wakeup;
grpc_pollset_worker *root_worker; grpc_pollset_worker *root_worker;
} pollable; } pollable_t;
static const char *polling_obj_type_string(polling_obj_type t) { static const char *polling_obj_type_string(polling_obj_type t) {
switch (t) { switch (t) {
@ -122,7 +122,7 @@ static const char *polling_obj_type_string(polling_obj_type t) {
return "<invalid>"; return "<invalid>";
} }
static char *pollable_desc(pollable *p) { static char *pollable_desc(pollable_t *p) {
char *out; char *out;
gpr_asprintf(&out, "type=%s group=%p epfd=%d wakeup=%d", gpr_asprintf(&out, "type=%s group=%p epfd=%d wakeup=%d",
polling_obj_type_string(p->po.type), p->po.group, p->epfd, polling_obj_type_string(p->po.type), p->po.group, p->epfd,
@ -130,19 +130,19 @@ static char *pollable_desc(pollable *p) {
return out; return out;
} }
static pollable g_empty_pollable; static pollable_t g_empty_pollable;
static void pollable_init(pollable *p, polling_obj_type type); static void pollable_init(pollable_t *p, polling_obj_type type);
static void pollable_destroy(pollable *p); static void pollable_destroy(pollable_t *p);
/* ensure that p->epfd, p->wakeup are initialized; p->po.mu must be held */ /* ensure that p->epfd, p->wakeup are initialized; p->po.mu must be held */
static grpc_error *pollable_materialize(pollable *p); static grpc_error *pollable_materialize(pollable_t *p);
/******************************************************************************* /*******************************************************************************
* Fd Declarations * Fd Declarations
*/ */
struct grpc_fd { struct grpc_fd {
pollable pollable; pollable_t pollable;
int fd; int fd;
/* refst format: /* refst format:
bit 0 : 1=Active / 0=Orphaned bit 0 : 1=Active / 0=Orphaned
@ -193,15 +193,15 @@ struct grpc_pollset_worker {
pollset_worker_link links[POLLSET_WORKER_LINK_COUNT]; pollset_worker_link links[POLLSET_WORKER_LINK_COUNT];
gpr_cv cv; gpr_cv cv;
grpc_pollset *pollset; grpc_pollset *pollset;
pollable *pollable; pollable_t *pollable;
}; };
#define MAX_EPOLL_EVENTS 100 #define MAX_EPOLL_EVENTS 100
#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5 #define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5
struct grpc_pollset { struct grpc_pollset {
pollable pollable; pollable_t pollable;
pollable *current_pollable; pollable_t *current_pollable;
int kick_alls_pending; int kick_alls_pending;
bool kicked_without_poller; bool kicked_without_poller;
grpc_closure *shutdown_closure; grpc_closure *shutdown_closure;
@ -451,13 +451,13 @@ static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
* Pollable Definitions * Pollable Definitions
*/ */
static void pollable_init(pollable *p, polling_obj_type type) { static void pollable_init(pollable_t *p, polling_obj_type type) {
po_init(&p->po, type); po_init(&p->po, type);
p->root_worker = NULL; p->root_worker = NULL;
p->epfd = -1; p->epfd = -1;
} }
static void pollable_destroy(pollable *p) { static void pollable_destroy(pollable_t *p) {
po_destroy(&p->po); po_destroy(&p->po);
if (p->epfd != -1) { if (p->epfd != -1) {
close(p->epfd); close(p->epfd);
@ -466,7 +466,7 @@ static void pollable_destroy(pollable *p) {
} }
/* ensure that p->epfd, p->wakeup are initialized; p->po.mu must be held */ /* ensure that p->epfd, p->wakeup are initialized; p->po.mu must be held */
static grpc_error *pollable_materialize(pollable *p) { static grpc_error *pollable_materialize(pollable_t *p) {
if (p->epfd == -1) { if (p->epfd == -1) {
int new_epfd = epoll_create1(EPOLL_CLOEXEC); int new_epfd = epoll_create1(EPOLL_CLOEXEC);
if (new_epfd < 0) { if (new_epfd < 0) {
@ -492,7 +492,7 @@ static grpc_error *pollable_materialize(pollable *p) {
} }
/* pollable must be materialized */ /* pollable must be materialized */
static grpc_error *pollable_add_fd(pollable *p, grpc_fd *fd) { static grpc_error *pollable_add_fd(pollable_t *p, grpc_fd *fd) {
grpc_error *error = GRPC_ERROR_NONE; grpc_error *error = GRPC_ERROR_NONE;
static const char *err_desc = "pollable_add_fd"; static const char *err_desc = "pollable_add_fd";
const int epfd = p->epfd; const int epfd = p->epfd;
@ -599,7 +599,7 @@ static void pollset_kick_all(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
GRPC_ERROR_NONE); GRPC_ERROR_NONE);
} }
static grpc_error *pollset_kick_inner(grpc_pollset *pollset, pollable *p, static grpc_error *pollset_kick_inner(grpc_pollset *pollset, pollable_t *p,
grpc_pollset_worker *specific_worker) { grpc_pollset_worker *specific_worker) {
if (GRPC_TRACER_ON(grpc_polling_trace)) { if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, gpr_log(GPR_DEBUG,
@ -664,7 +664,7 @@ static grpc_error *pollset_kick_inner(grpc_pollset *pollset, pollable *p,
/* p->po.mu must be held before calling this function */ /* p->po.mu must be held before calling this function */
static grpc_error *pollset_kick(grpc_pollset *pollset, static grpc_error *pollset_kick(grpc_pollset *pollset,
grpc_pollset_worker *specific_worker) { grpc_pollset_worker *specific_worker) {
pollable *p = pollset->current_pollable; pollable_t *p = pollset->current_pollable;
if (p != &pollset->pollable) { if (p != &pollset->pollable) {
gpr_mu_lock(&p->po.mu); gpr_mu_lock(&p->po.mu);
} }
@ -744,7 +744,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollset_maybe_finish_shutdown(exec_ctx, pollset); pollset_maybe_finish_shutdown(exec_ctx, pollset);
} }
static bool pollset_is_pollable_fd(grpc_pollset *pollset, pollable *p) { static bool pollset_is_pollable_fd(grpc_pollset *pollset, pollable_t *p) {
return p != &g_empty_pollable && p != &pollset->pollable; return p != &g_empty_pollable && p != &pollset->pollable;
} }
@ -762,8 +762,9 @@ static grpc_error *pollset_process_events(grpc_exec_ctx *exec_ctx,
if (GRPC_TRACER_ON(grpc_polling_trace)) { if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr); gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr);
} }
append_error(&error, grpc_wakeup_fd_consume_wakeup( append_error(&error,
(void *)((~(intptr_t)1) & (intptr_t)data_ptr)), grpc_wakeup_fd_consume_wakeup(
(grpc_wakeup_fd *)((~(intptr_t)1) & (intptr_t)data_ptr)),
err_desc); err_desc);
} else { } else {
grpc_fd *fd = (grpc_fd *)data_ptr; grpc_fd *fd = (grpc_fd *)data_ptr;
@ -800,7 +801,7 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
} }
static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollable *p, gpr_timespec now, pollable_t *p, gpr_timespec now,
gpr_timespec deadline) { gpr_timespec deadline) {
int timeout = poll_deadline_to_millis_timeout(deadline, now); int timeout = poll_deadline_to_millis_timeout(deadline, now);
@ -1028,7 +1029,7 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
"PS:%p add fd %p; transition pollable from empty to fd", pollset, "PS:%p add fd %p; transition pollable from empty to fd", pollset,
fd); fd);
} }
/* empty pollable --> single fd pollable */ /* empty pollable --> single fd pollable_t */
pollset_kick_all(exec_ctx, pollset); pollset_kick_all(exec_ctx, pollset);
pollset->current_pollable = &fd->pollable; pollset->current_pollable = &fd->pollable;
if (!fd_locked) gpr_mu_lock(&fd->pollable.po.mu); if (!fd_locked) gpr_mu_lock(&fd->pollable.po.mu);

@ -22,6 +22,8 @@
#include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/pollset_set.h"
typedef enum pops_tag { POPS_NONE, POPS_POLLSET, POPS_POLLSET_SET } pops_tag;
/* A grpc_polling_entity is a pollset-or-pollset_set container. It allows /* A grpc_polling_entity is a pollset-or-pollset_set container. It allows
* functions that accept a pollset XOR a pollset_set to do so through an * functions that accept a pollset XOR a pollset_set to do so through an
* abstract interface. No ownership is taken. */ * abstract interface. No ownership is taken. */
@ -31,7 +33,7 @@ typedef struct grpc_polling_entity {
grpc_pollset *pollset; grpc_pollset *pollset;
grpc_pollset_set *pollset_set; grpc_pollset_set *pollset_set;
} pollent; } pollent;
enum pops_tag { POPS_NONE, POPS_POLLSET, POPS_POLLSET_SET } tag; pops_tag tag;
} grpc_polling_entity; } grpc_polling_entity;
grpc_polling_entity grpc_polling_entity_create_from_pollset_set( grpc_polling_entity grpc_polling_entity_create_from_pollset_set(

@ -656,7 +656,7 @@ grpc_resource_quota *grpc_resource_quota_from_channel_args(
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) { if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
if (channel_args->args[i].type == GRPC_ARG_POINTER) { if (channel_args->args[i].type == GRPC_ARG_POINTER) {
return grpc_resource_quota_ref_internal( return grpc_resource_quota_ref_internal(
channel_args->args[i].value.pointer.p); (grpc_resource_quota *)channel_args->args[i].value.pointer.p);
} else { } else {
gpr_log(GPR_DEBUG, GRPC_ARG_RESOURCE_QUOTA " should be a pointer"); gpr_log(GPR_DEBUG, GRPC_ARG_RESOURCE_QUOTA " should be a pointer");
} }
@ -666,12 +666,12 @@ grpc_resource_quota *grpc_resource_quota_from_channel_args(
} }
static void *rq_copy(void *rq) { static void *rq_copy(void *rq) {
grpc_resource_quota_ref(rq); grpc_resource_quota_ref((grpc_resource_quota *)rq);
return rq; return rq;
} }
static void rq_destroy(grpc_exec_ctx *exec_ctx, void *rq) { static void rq_destroy(grpc_exec_ctx *exec_ctx, void *rq) {
grpc_resource_quota_unref_internal(exec_ctx, rq); grpc_resource_quota_unref_internal(exec_ctx, (grpc_resource_quota *)rq);
} }
static int rq_cmp(void *a, void *b) { return GPR_ICMP(a, b); } static int rq_cmp(void *a, void *b) { return GPR_ICMP(a, b); }

@ -69,11 +69,11 @@ void grpc_socket_factory_unref(grpc_socket_factory *factory) {
} }
static void *socket_factory_arg_copy(void *p) { static void *socket_factory_arg_copy(void *p) {
return grpc_socket_factory_ref(p); return grpc_socket_factory_ref((grpc_socket_factory *)p);
} }
static void socket_factory_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) { static void socket_factory_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
grpc_socket_factory_unref(p); grpc_socket_factory_unref((grpc_socket_factory *)p);
} }
static int socket_factory_cmp(void *a, void *b) { static int socket_factory_cmp(void *a, void *b) {

@ -60,11 +60,11 @@ void grpc_socket_mutator_unref(grpc_socket_mutator *mutator) {
} }
static void *socket_mutator_arg_copy(void *p) { static void *socket_mutator_arg_copy(void *p) {
return grpc_socket_mutator_ref(p); return grpc_socket_mutator_ref((grpc_socket_mutator *)p);
} }
static void socket_mutator_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) { static void socket_mutator_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
grpc_socket_mutator_unref(p); grpc_socket_mutator_unref((grpc_socket_mutator *)p);
} }
static int socket_mutator_cmp(void *a, void *b) { static int socket_mutator_cmp(void *a, void *b) {

@ -276,7 +276,7 @@ static void timer_thread(void *completed_thread_ptr) {
GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL); GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
timer_main_loop(&exec_ctx); timer_main_loop(&exec_ctx);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
timer_thread_cleanup(completed_thread_ptr); timer_thread_cleanup((completed_thread *)completed_thread_ptr);
} }
static void start_threads(void) { static void start_threads(void) {

@ -118,7 +118,7 @@ static grpc_socket_factory *get_socket_factory(const grpc_channel_args *args) {
const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY); const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY);
if (arg) { if (arg) {
GPR_ASSERT(arg->type == GRPC_ARG_POINTER); GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
return arg->value.pointer.p; return (grpc_socket_factory *)arg->value.pointer.p;
} }
} }
return NULL; return NULL;

@ -174,8 +174,8 @@ static const grpc_slice_refcount_vtable new_with_len_vtable = {
grpc_slice grpc_slice_new_with_len(void *p, size_t len, grpc_slice grpc_slice_new_with_len(void *p, size_t len,
void (*destroy)(void *, size_t)) { void (*destroy)(void *, size_t)) {
grpc_slice slice; grpc_slice slice;
new_with_len_slice_refcount *rc = new_with_len_slice_refcount *rc = (new_with_len_slice_refcount *)gpr_malloc(
gpr_malloc(sizeof(new_with_len_slice_refcount)); sizeof(new_with_len_slice_refcount));
gpr_ref_init(&rc->refs, 1); gpr_ref_init(&rc->refs, 1);
rc->rc.vtable = &new_with_len_vtable; rc->rc.vtable = &new_with_len_vtable;
rc->rc.sub_refcount = &rc->rc; rc->rc.sub_refcount = &rc->rc;

@ -135,7 +135,7 @@ typedef struct batch_control {
typedef struct { typedef struct {
gpr_mu child_list_mu; gpr_mu child_list_mu;
grpc_call *first_child; grpc_call *first_child;
} parent_call; } parent_call_t;
typedef struct { typedef struct {
grpc_call *parent; grpc_call *parent;
@ -144,7 +144,7 @@ typedef struct {
parent->mu */ parent->mu */
grpc_call *sibling_next; grpc_call *sibling_next;
grpc_call *sibling_prev; grpc_call *sibling_prev;
} child_call; } child_call_t;
#define RECV_NONE ((gpr_atm)0) #define RECV_NONE ((gpr_atm)0)
#define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1) #define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1)
@ -157,8 +157,8 @@ struct grpc_call {
grpc_polling_entity pollent; grpc_polling_entity pollent;
grpc_channel *channel; grpc_channel *channel;
gpr_timespec start_time; gpr_timespec start_time;
/* parent_call* */ gpr_atm parent_call_atm; /* parent_call_t* */ gpr_atm parent_call_atm;
child_call *child_call; child_call_t *child_call;
/* client or server call */ /* client or server call */
bool is_client; bool is_client;
@ -293,32 +293,32 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx, batch_control *bctl);
static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl, static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl,
grpc_error *error, bool has_cancelled); grpc_error *error, bool has_cancelled);
static void add_init_error(grpc_error **composite, grpc_error *new) { static void add_init_error(grpc_error **composite, grpc_error *new_err) {
if (new == GRPC_ERROR_NONE) return; if (new_err == GRPC_ERROR_NONE) return;
if (*composite == GRPC_ERROR_NONE) if (*composite == GRPC_ERROR_NONE)
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed"); *composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed");
*composite = grpc_error_add_child(*composite, new); *composite = grpc_error_add_child(*composite, new_err);
} }
void *grpc_call_arena_alloc(grpc_call *call, size_t size) { void *grpc_call_arena_alloc(grpc_call *call, size_t size) {
return gpr_arena_alloc(call->arena, size); return gpr_arena_alloc(call->arena, size);
} }
static parent_call *get_or_create_parent_call(grpc_call *call) { static parent_call_t *get_or_create_parent_call(grpc_call *call) {
parent_call *p = (parent_call *)gpr_atm_acq_load(&call->parent_call_atm); parent_call_t *p = (parent_call_t *)gpr_atm_acq_load(&call->parent_call_atm);
if (p == NULL) { if (p == NULL) {
p = (parent_call *)gpr_arena_alloc(call->arena, sizeof(*p)); p = (parent_call_t *)gpr_arena_alloc(call->arena, sizeof(*p));
gpr_mu_init(&p->child_list_mu); gpr_mu_init(&p->child_list_mu);
if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm)NULL, (gpr_atm)p)) { if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm)NULL, (gpr_atm)p)) {
gpr_mu_destroy(&p->child_list_mu); gpr_mu_destroy(&p->child_list_mu);
p = (parent_call *)gpr_atm_acq_load(&call->parent_call_atm); p = (parent_call_t *)gpr_atm_acq_load(&call->parent_call_atm);
} }
} }
return p; return p;
} }
static parent_call *get_parent_call(grpc_call *call) { static parent_call_t *get_parent_call(grpc_call *call) {
return (parent_call *)gpr_atm_acq_load(&call->parent_call_atm); return (parent_call_t *)gpr_atm_acq_load(&call->parent_call_atm);
} }
grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx, grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
@ -378,15 +378,15 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
bool immediately_cancel = false; bool immediately_cancel = false;
if (args->parent_call != NULL) { if (args->parent_call != NULL) {
child_call *cc = call->child_call = child_call_t *cc = call->child_call =
gpr_arena_alloc(arena, sizeof(child_call)); (child_call_t *)gpr_arena_alloc(arena, sizeof(child_call_t));
call->child_call->parent = args->parent_call; call->child_call->parent = args->parent_call;
GRPC_CALL_INTERNAL_REF(args->parent_call, "child"); GRPC_CALL_INTERNAL_REF(args->parent_call, "child");
GPR_ASSERT(call->is_client); GPR_ASSERT(call->is_client);
GPR_ASSERT(!args->parent_call->is_client); GPR_ASSERT(!args->parent_call->is_client);
parent_call *pc = get_or_create_parent_call(args->parent_call); parent_call_t *pc = get_or_create_parent_call(args->parent_call);
gpr_mu_lock(&pc->child_list_mu); gpr_mu_lock(&pc->child_list_mu);
@ -533,7 +533,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
if (c->receiving_stream != NULL) { if (c->receiving_stream != NULL) {
grpc_byte_stream_destroy(exec_ctx, c->receiving_stream); grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
} }
parent_call *pc = get_parent_call(c); parent_call_t *pc = get_parent_call(c);
if (pc != NULL) { if (pc != NULL) {
gpr_mu_destroy(&pc->child_list_mu); gpr_mu_destroy(&pc->child_list_mu);
} }
@ -549,8 +549,8 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind"); GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind");
} }
get_final_status(call, set_status_value_directly, &c->final_info.final_status, get_final_status((grpc_call *)call, set_status_value_directly,
NULL); &c->final_info.final_status, NULL);
c->final_info.stats.latency = c->final_info.stats.latency =
gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time); gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time);
@ -570,14 +570,14 @@ void grpc_call_ref(grpc_call *c) { gpr_ref(&c->ext_ref); }
void grpc_call_unref(grpc_call *c) { void grpc_call_unref(grpc_call *c) {
if (!gpr_unref(&c->ext_ref)) return; if (!gpr_unref(&c->ext_ref)) return;
child_call *cc = c->child_call; child_call_t *cc = c->child_call;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_TIMER_BEGIN("grpc_call_unref", 0); GPR_TIMER_BEGIN("grpc_call_unref", 0);
GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c)); GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c));
if (cc) { if (cc) {
parent_call *pc = get_parent_call(cc->parent); parent_call_t *pc = get_parent_call(cc->parent);
gpr_mu_lock(&pc->child_list_mu); gpr_mu_lock(&pc->child_list_mu);
if (c == pc->first_child) { if (c == pc->first_child) {
pc->first_child = cc->sibling_next; pc->first_child = cc->sibling_next;
@ -1309,7 +1309,7 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
/* propagate cancellation to any interested children */ /* propagate cancellation to any interested children */
gpr_atm_rel_store(&call->received_final_op_atm, 1); gpr_atm_rel_store(&call->received_final_op_atm, 1);
parent_call *pc = get_parent_call(call); parent_call_t *pc = get_parent_call(call);
if (pc != NULL) { if (pc != NULL) {
grpc_call *child; grpc_call *child;
gpr_mu_lock(&pc->child_list_mu); gpr_mu_lock(&pc->child_list_mu);
@ -1345,7 +1345,8 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
if (bctl->completion_data.notify_tag.is_closure) { if (bctl->completion_data.notify_tag.is_closure) {
/* unrefs bctl->error */ /* unrefs bctl->error */
bctl->call = NULL; bctl->call = NULL;
GRPC_CLOSURE_RUN(exec_ctx, bctl->completion_data.notify_tag.tag, error); GRPC_CLOSURE_RUN(
exec_ctx, (grpc_closure *)bctl->completion_data.notify_tag.tag, error);
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion"); GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
} else { } else {
/* unrefs bctl->error */ /* unrefs bctl->error */
@ -1474,7 +1475,7 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
* acq_load is in receiving_initial_metadata_ready() */ * acq_load is in receiving_initial_metadata_ready() */
if (error != GRPC_ERROR_NONE || call->receiving_stream == NULL || if (error != GRPC_ERROR_NONE || call->receiving_stream == NULL ||
!gpr_atm_rel_cas(&call->recv_state, RECV_NONE, (gpr_atm)bctlp)) { !gpr_atm_rel_cas(&call->recv_state, RECV_NONE, (gpr_atm)bctlp)) {
process_data_after_md(exec_ctx, bctlp); process_data_after_md(exec_ctx, (batch_control *)bctlp);
} }
} }
@ -1679,11 +1680,12 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
if (nops == 0) { if (nops == 0) {
if (!is_notify_tag_closure) { if (!is_notify_tag_closure) {
GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag)); GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
grpc_cq_end_op(exec_ctx, call->cq, notify_tag, GRPC_ERROR_NONE, grpc_cq_end_op(
free_no_op_completion, NULL, exec_ctx, call->cq, notify_tag, GRPC_ERROR_NONE,
gpr_malloc(sizeof(grpc_cq_completion))); free_no_op_completion, NULL,
(grpc_cq_completion *)gpr_malloc(sizeof(grpc_cq_completion)));
} else { } else {
GRPC_CLOSURE_SCHED(exec_ctx, notify_tag, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure *)notify_tag, GRPC_ERROR_NONE);
} }
error = GRPC_CALL_OK; error = GRPC_CALL_OK;
goto done; goto done;

Loading…
Cancel
Save