diff options
author | Muxi Yan <mxyan@google.com> | 2016-10-03 09:53:38 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2016-10-03 09:53:38 -0700 |
commit | 92795c405c3961441182f29a9356cf589bb70190 (patch) | |
tree | 4d8ab17c99b57afb8208c89bcef44686e581865f /src/core | |
parent | 20f49619ad4fc1f7ca25e72f4ff5527971186e68 (diff) |
Update free_read_buffer with a function
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ext/transport/cronet/transport/cronet_transport.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 90f18e413d..b95aba14e9 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -57,14 +57,6 @@ if (grpc_cronet_trace) gpr_log(__VA_ARGS__); \ } while (0) -#define free_read_buffer(state_rs) \ - if ((state_rs).read_buffer && \ - (state_rs).read_buffer != (state_rs).grpc_header_bytes) { \ - gpr_free((state_rs).read_buffer); \ - (state_rs).read_buffer = NULL; \ - } - - /* TODO (makdharma): Hook up into the wider tracing mechanism */ int grpc_cronet_trace = 0; @@ -247,6 +239,14 @@ static const char *op_id_string(enum e_op_id i) { return "UNKNOWN"; } +static void free_read_buffer(stream_obj *s) { + if (s->state.rs.read_buffer && + s->state.rs.read_buffer != s->state.rs.grpc_header_bytes) { + gpr_free(s->state.rs.read_buffer); + s->state.rs.read_buffer = NULL; + } +} + /* Add a new stream op to op storage. */ @@ -349,7 +349,7 @@ static void on_failed(cronet_bidirectional_stream *stream, int net_error) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } - free_read_buffer(s->state.rs); + free_read_buffer(s); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -372,7 +372,7 @@ static void on_canceled(cronet_bidirectional_stream *stream) { gpr_free(s->state.ws.write_buffer); s->state.ws.write_buffer = NULL; } - free_read_buffer(s->state.rs); + free_read_buffer(s); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -387,7 +387,7 @@ static void on_succeeded(cronet_bidirectional_stream *stream) { cronet_bidirectional_stream_destroy(s->cbs); s->state.state_callback_received[OP_SUCCEEDED] = true; s->cbs = NULL; - free_read_buffer(s->state.rs); + free_read_buffer(s); gpr_mu_unlock(&s->mu); execute_from_storage(s); } @@ -912,7 +912,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice); memcpy(dst_p, stream_state->rs.read_buffer, (size_t)stream_state->rs.length_field); - free_read_buffer(stream_state->rs); + free_read_buffer(s); gpr_slice_buffer_init(&stream_state->rs.read_slice_buffer); gpr_slice_buffer_add(&stream_state->rs.read_slice_buffer, read_data_slice); |