From 68f55a0804e956feb879beeaa95875295c74a582 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 30 Jan 2015 07:54:48 -0800 Subject: [PATCH] Free the messages --- src/core/surface/call.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/surface/call.c b/src/core/surface/call.c index b080e11e00c..ba461fee7db 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -872,6 +872,10 @@ void grpc_call_initial_metadata_complete(grpc_call_element *surface_element) { unlock(call); } +static void finish_read_event(void *p, grpc_op_error error) { + grpc_byte_buffer_destroy(p); +} + static void finish_read(grpc_call *call, grpc_op_error error, void *tag) { legacy_state *ls; lock(call); @@ -879,8 +883,8 @@ static void finish_read(grpc_call *call, grpc_op_error error, void *tag) { if (ls->msg_in.count == 0) { grpc_cq_end_read(call->cq, tag, call, do_nothing, NULL, NULL); } else { - grpc_cq_end_read(call->cq, tag, call, do_nothing, NULL, - ls->msg_in.buffers[ls->msg_in_read_idx++]); + grpc_byte_buffer *msg = ls->msg_in.buffers[ls->msg_in_read_idx++]; + grpc_cq_end_read(call->cq, tag, call, finish_read_event, msg, msg); maybe_finish_legacy(call); } unlock(call);