Merge pull request #8875 from dgquintas/fixit_race_httpclient

Fixed http_client race
pull/8889/head
David G. Quintas 8 years ago committed by GitHub
commit f9ed9d98cf
  1. 9
      src/core/lib/channel/http_client_filter.c

@ -245,12 +245,15 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
message, and the payload is below the size threshold, and all the data message, and the payload is below the size threshold, and all the data
for this request is immediately available. */ for this request is immediately available. */
grpc_mdelem *method = GRPC_MDELEM_METHOD_POST; grpc_mdelem *method = GRPC_MDELEM_METHOD_POST;
calld->send_message_blocked = false;
if ((op->send_initial_metadata_flags & if ((op->send_initial_metadata_flags &
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) && GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) &&
op->send_message != NULL && op->send_message != NULL &&
op->send_message->length < channeld->max_payload_size_for_get) { op->send_message->length < channeld->max_payload_size_for_get) {
method = GRPC_MDELEM_METHOD_GET; method = GRPC_MDELEM_METHOD_GET;
/* The following write to calld->send_message_blocked isn't racy with
reads in hc_start_transport_op (which deals with SEND_MESSAGE ops) because
being here means ops->send_message is not NULL, which is primarily
guarding the read there. */
calld->send_message_blocked = true; calld->send_message_blocked = true;
} else if (op->send_initial_metadata_flags & } else if (op->send_initial_metadata_flags &
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) {
@ -331,8 +334,7 @@ static void hc_start_transport_op(grpc_exec_ctx *exec_ctx,
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
if (op->send_message != NULL && calld->send_message_blocked) { if (op->send_message != NULL && calld->send_message_blocked) {
/* Don't forward the op. send_message contains slices that aren't ready /* Don't forward the op. send_message contains slices that aren't ready
yet. The call will be forwarded by the op_complete of slice read call. yet. The call will be forwarded by the op_complete of slice read call. */
*/
} else { } else {
grpc_call_next_op(exec_ctx, elem, op); grpc_call_next_op(exec_ctx, elem, op);
} }
@ -347,6 +349,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
calld->on_done_recv_trailing_metadata = NULL; calld->on_done_recv_trailing_metadata = NULL;
calld->on_complete = NULL; calld->on_complete = NULL;
calld->payload_bytes = NULL; calld->payload_bytes = NULL;
calld->send_message_blocked = false;
grpc_slice_buffer_init(&calld->slices); grpc_slice_buffer_init(&calld->slices);
grpc_closure_init(&calld->hc_on_recv_initial_metadata, grpc_closure_init(&calld->hc_on_recv_initial_metadata,
hc_on_recv_initial_metadata, elem); hc_on_recv_initial_metadata, elem);

Loading…
Cancel
Save