diff options
author | Craig Tiller <ctiller@google.com> | 2015-05-04 14:53:51 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-05-04 14:53:51 -0700 |
commit | 64be9f7a30a4bcb9ce3647f11ba9e06994aa3bb7 (patch) | |
tree | 42a4af35a2fe0f3a79573ff37130fd6b74c55cb9 /test/core/fling | |
parent | c112d146a2dcc5e90d5f5cca10f55f212f9492c6 (diff) |
C Core API cleanup.
Simplify grpc_event into something that can be non-heap allocated.
Deprecate grpc_event_finish.
Remove grpc_op_error - use an int as this is more idiomatic C style.
Diffstat (limited to 'test/core/fling')
-rw-r--r-- | test/core/fling/client.c | 16 | ||||
-rw-r--r-- | test/core/fling/server.c | 12 |
2 files changed, 11 insertions, 17 deletions
diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 68164b1c5a..37d787c7c3 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -93,7 +93,7 @@ static void step_ping_pong_request(void) { "localhost", gpr_inf_future); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, op - ops, (void *)1)); - grpc_event_finish(grpc_completion_queue_next(cq, gpr_inf_future)); + grpc_completion_queue_next(cq, gpr_inf_future); grpc_call_destroy(call); grpc_byte_buffer_destroy(response_payload_recv); call = NULL; @@ -106,7 +106,7 @@ static void init_ping_pong_stream(void) { stream_init_op.data.send_initial_metadata.count = 0; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, &stream_init_op, 1, (void *)1)); - grpc_event_finish(grpc_completion_queue_next(cq, gpr_inf_future)); + grpc_completion_queue_next(cq, gpr_inf_future); grpc_metadata_array_init(&initial_metadata_recv); @@ -119,7 +119,7 @@ static void init_ping_pong_stream(void) { static void step_ping_pong_stream(void) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, stream_step_ops, 2, (void *)1)); - grpc_event_finish(grpc_completion_queue_next(cq, gpr_inf_future)); + grpc_completion_queue_next(cq, gpr_inf_future); grpc_byte_buffer_destroy(response_payload_recv); } @@ -147,7 +147,6 @@ int main(int argc, char **argv) { char *fake_argv[1]; int payload_size = 1; - int done; int secure = 0; char *target = "localhost:443"; gpr_cmdline *cl; @@ -209,12 +208,9 @@ int main(int argc, char **argv) { grpc_channel_destroy(channel); grpc_completion_queue_shutdown(cq); - done = 0; - while (!done) { - grpc_event *ev = grpc_completion_queue_next(cq, gpr_inf_future); - done = (ev->type == GRPC_QUEUE_SHUTDOWN); - grpc_event_finish(ev); - } + while (grpc_completion_queue_next(cq, gpr_inf_future).type != + GRPC_QUEUE_SHUTDOWN) + ; grpc_completion_queue_destroy(cq); grpc_byte_buffer_destroy(the_buffer); gpr_slice_unref(slice); diff --git a/test/core/fling/server.c b/test/core/fling/server.c index 63c7bd7f88..57e702eaad 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -169,7 +169,7 @@ static void start_send_status(void) { static void sigint_handler(int x) { _exit(0); } int main(int argc, char **argv) { - grpc_event *ev; + grpc_event ev; call_state *s; char *addr_buf = NULL; gpr_cmdline *cl; @@ -233,9 +233,8 @@ int main(int argc, char **argv) { } ev = grpc_completion_queue_next( cq, gpr_time_add(gpr_now(), gpr_time_from_micros(1000000))); - if (!ev) continue; - s = ev->tag; - switch (ev->type) { + s = ev.tag; + switch (ev.type) { case GRPC_OP_COMPLETE: switch ((gpr_intptr)s) { case FLING_SERVER_NEW_REQUEST: @@ -297,10 +296,9 @@ int main(int argc, char **argv) { GPR_ASSERT(shutdown_started); shutdown_finished = 1; break; - default: - GPR_ASSERT(0); + case GRPC_QUEUE_TIMEOUT: + break; } - grpc_event_finish(ev); } grpc_profiler_stop(); grpc_call_details_destroy(&call_details); |