Skip to content

Commit

Permalink
fixes for asan leak, and proxy test
Browse files Browse the repository at this point in the history
freeing up payload_bytes.
returning GET response only once.
  • Loading branch information
Makarand Dharmapurikar committed Aug 29, 2016
1 parent d322d4b commit f44946b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/core/lib/channel/http_client_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void hc_mutate_op(grpc_call_element *elem,

/* Decide which HTTP VERB to use */
grpc_mdelem *method = GRPC_MDELEM_METHOD_POST;
if ((op->send_initial_metadata_flags &
if (op->send_initial_metadata != NULL && (op->send_initial_metadata_flags &
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) &&
op->send_message != NULL &&
op->send_message->length < channeld->max_payload_size_for_get) {
Expand Down Expand Up @@ -189,6 +189,8 @@ static void hc_mutate_op(grpc_call_element *elem,
break;
}
}
calld->on_complete = op->on_complete;
op->on_complete = &calld->hc_on_complete;
op->send_message = NULL;
}

Expand Down Expand Up @@ -216,11 +218,6 @@ static void hc_mutate_op(grpc_call_element *elem,
calld->on_done_recv = op->recv_initial_metadata_ready;
op->recv_initial_metadata_ready = &calld->hc_on_recv;
}

if (op->on_complete != NULL && op->send_message != NULL) {
calld->on_complete = op->on_complete;
op->on_complete = &calld->hc_on_complete;
}
}

static void hc_start_transport_op(grpc_exec_ctx *exec_ctx,
Expand Down
8 changes: 7 additions & 1 deletion src/core/lib/channel/http_server_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ typedef struct call_data {
grpc_linked_mdelem status;
grpc_linked_mdelem content_type;

/* flag to ensure payload_bin is delivered only once */
uint8_t payload_bin_delivered;

grpc_metadata_batch *recv_initial_metadata;
bool *recv_idempotent_request;
bool *recv_cacheable_request;
Expand Down Expand Up @@ -221,10 +224,13 @@ static void hs_on_complete(grpc_exec_ctx *exec_ctx, void *user_data,
call_data *calld = elem->call_data;
/* Call recv_message_ready if we got the payload via the header field */
if (calld->seen_payload_bin && calld->recv_message_ready != NULL) {
*calld->pp_recv_message = (grpc_byte_stream *)&calld->read_stream;
*calld->pp_recv_message = calld->payload_bin_delivered
? NULL
: (grpc_byte_stream *)&calld->read_stream;
calld->recv_message_ready->cb(exec_ctx, calld->recv_message_ready->cb_arg,
err);
calld->recv_message_ready = NULL;
calld->payload_bin_delivered = true;
}
calld->on_complete->cb(exec_ctx, calld->on_complete->cb_arg, err);
}
Expand Down

0 comments on commit f44946b

Please sign in to comment.