Fix http_server filter to destroy its byte stream if it isn't returned.

reviewable/pr10684/r22^2
Mark D. Roth 7 years ago
parent ef58813f0a
commit e010dc932a
  1. 14
      src/core/ext/filters/http/server/http_server_filter.cc

@ -52,7 +52,6 @@ struct call_data {
grpc_closure* recv_message_ready; grpc_closure* recv_message_ready;
grpc_closure* on_complete; grpc_closure* on_complete;
grpc_byte_stream** pp_recv_message; grpc_byte_stream** pp_recv_message;
grpc_slice_buffer read_slice_buffer;
grpc_slice_buffer_stream read_stream; grpc_slice_buffer_stream read_stream;
/** Receive closures are chained: we inject this closure as the on_done_recv /** Receive closures are chained: we inject this closure as the on_done_recv
@ -224,13 +223,15 @@ static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
/* decode payload from query and add to the slice buffer to be returned */ /* decode payload from query and add to the slice buffer to be returned */
const int k_url_safe = 1; const int k_url_safe = 1;
grpc_slice_buffer read_slice_buffer;
grpc_slice_buffer_init(&read_slice_buffer);
grpc_slice_buffer_add( grpc_slice_buffer_add(
&calld->read_slice_buffer, &read_slice_buffer,
grpc_base64_decode_with_len( grpc_base64_decode_with_len(
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(query_slice), reinterpret_cast<const char*> GRPC_SLICE_START_PTR(query_slice),
GRPC_SLICE_LENGTH(query_slice), k_url_safe)); GRPC_SLICE_LENGTH(query_slice), k_url_safe));
grpc_slice_buffer_stream_init(&calld->read_stream, grpc_slice_buffer_stream_init(&calld->read_stream, &read_slice_buffer, 0);
&calld->read_slice_buffer, 0); grpc_slice_buffer_destroy_internal(&read_slice_buffer);
calld->seen_path_with_query = true; calld->seen_path_with_query = true;
grpc_slice_unref_internal(query_slice); grpc_slice_unref_internal(query_slice);
} else { } else {
@ -393,7 +394,6 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&calld->hs_recv_message_ready, hs_recv_message_ready, elem, GRPC_CLOSURE_INIT(&calld->hs_recv_message_ready, hs_recv_message_ready, elem,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&calld->read_slice_buffer);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -402,7 +402,9 @@ static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info, const grpc_call_final_info* final_info,
grpc_closure* ignored) { grpc_closure* ignored) {
call_data* calld = static_cast<call_data*>(elem->call_data); call_data* calld = static_cast<call_data*>(elem->call_data);
grpc_slice_buffer_destroy_internal(&calld->read_slice_buffer); if (calld->seen_path_with_query && !calld->payload_bin_delivered) {
grpc_byte_stream_destroy(&calld->read_stream.base);
}
} }
/* Constructor for channel_data */ /* Constructor for channel_data */

Loading…
Cancel
Save