|
|
@ -41,16 +41,16 @@ struct call_data { |
|
|
|
grpc_transport_stream_op_batch* recv_initial_metadata_batch; |
|
|
|
grpc_transport_stream_op_batch* recv_initial_metadata_batch; |
|
|
|
grpc_closure* original_recv_initial_metadata_ready; |
|
|
|
grpc_closure* original_recv_initial_metadata_ready; |
|
|
|
grpc_closure recv_initial_metadata_ready; |
|
|
|
grpc_closure recv_initial_metadata_ready; |
|
|
|
grpc_error* error; |
|
|
|
grpc_error* recv_initial_metadata_error; |
|
|
|
grpc_closure recv_trailing_metadata_ready; |
|
|
|
grpc_closure recv_trailing_metadata_ready; |
|
|
|
grpc_closure* original_recv_trailing_metadata_ready; |
|
|
|
grpc_closure* original_recv_trailing_metadata_ready; |
|
|
|
|
|
|
|
grpc_error* recv_trailing_metadata_error; |
|
|
|
|
|
|
|
bool seen_recv_trailing_ready; |
|
|
|
grpc_metadata_array md; |
|
|
|
grpc_metadata_array md; |
|
|
|
const grpc_metadata* consumed_md; |
|
|
|
const grpc_metadata* consumed_md; |
|
|
|
size_t num_consumed_md; |
|
|
|
size_t num_consumed_md; |
|
|
|
grpc_closure cancel_closure; |
|
|
|
grpc_closure cancel_closure; |
|
|
|
gpr_atm state; // async_state
|
|
|
|
gpr_atm state; // async_state
|
|
|
|
grpc_error* recv_trailing_metadata_error; |
|
|
|
|
|
|
|
bool seen_recv_trailing_ready; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct channel_data { |
|
|
|
struct channel_data { |
|
|
@ -116,13 +116,14 @@ static void on_md_processing_done_inner(grpc_call_element* elem, |
|
|
|
batch->payload->recv_initial_metadata.recv_initial_metadata, |
|
|
|
batch->payload->recv_initial_metadata.recv_initial_metadata, |
|
|
|
remove_consumed_md, elem, "Response metadata filtering error"); |
|
|
|
remove_consumed_md, elem, "Response metadata filtering error"); |
|
|
|
} |
|
|
|
} |
|
|
|
calld->error = GRPC_ERROR_REF(error); |
|
|
|
calld->recv_initial_metadata_error = GRPC_ERROR_REF(error); |
|
|
|
grpc_closure* closure = calld->original_recv_initial_metadata_ready; |
|
|
|
grpc_closure* closure = calld->original_recv_initial_metadata_ready; |
|
|
|
calld->original_recv_initial_metadata_ready = nullptr; |
|
|
|
calld->original_recv_initial_metadata_ready = nullptr; |
|
|
|
if (calld->seen_recv_trailing_ready) { |
|
|
|
if (calld->seen_recv_trailing_ready) { |
|
|
|
GRPC_CALL_COMBINER_START( |
|
|
|
GRPC_CALL_COMBINER_START(calld->call_combiner, |
|
|
|
calld->call_combiner, &calld->recv_trailing_metadata_ready, |
|
|
|
&calld->recv_trailing_metadata_ready, |
|
|
|
calld->recv_trailing_metadata_error, "continue recv trailing metadata"); |
|
|
|
calld->recv_trailing_metadata_error, |
|
|
|
|
|
|
|
"continue recv_trailing_metadata_ready"); |
|
|
|
} |
|
|
|
} |
|
|
|
GRPC_CLOSURE_SCHED(closure, error); |
|
|
|
GRPC_CLOSURE_SCHED(closure, error); |
|
|
|
} |
|
|
|
} |
|
|
@ -196,9 +197,10 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { |
|
|
|
grpc_closure* closure = calld->original_recv_initial_metadata_ready; |
|
|
|
grpc_closure* closure = calld->original_recv_initial_metadata_ready; |
|
|
|
calld->original_recv_initial_metadata_ready = nullptr; |
|
|
|
calld->original_recv_initial_metadata_ready = nullptr; |
|
|
|
if (calld->seen_recv_trailing_ready) { |
|
|
|
if (calld->seen_recv_trailing_ready) { |
|
|
|
GRPC_CALL_COMBINER_START( |
|
|
|
GRPC_CALL_COMBINER_START(calld->call_combiner, |
|
|
|
calld->call_combiner, &calld->recv_trailing_metadata_ready, |
|
|
|
&calld->recv_trailing_metadata_ready, |
|
|
|
calld->recv_trailing_metadata_error, "continue recv trailing metadata"); |
|
|
|
calld->recv_trailing_metadata_error, |
|
|
|
|
|
|
|
"continue recv_trailing_metadata_ready"); |
|
|
|
} |
|
|
|
} |
|
|
|
GRPC_CLOSURE_RUN(closure, GRPC_ERROR_REF(error)); |
|
|
|
GRPC_CLOSURE_RUN(closure, GRPC_ERROR_REF(error)); |
|
|
|
} |
|
|
|
} |
|
|
@ -206,15 +208,18 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) { |
|
|
|
static void recv_trailing_metadata_ready(void* user_data, grpc_error* err) { |
|
|
|
static void recv_trailing_metadata_ready(void* user_data, grpc_error* err) { |
|
|
|
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data); |
|
|
|
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data); |
|
|
|
call_data* calld = static_cast<call_data*>(elem->call_data); |
|
|
|
call_data* calld = static_cast<call_data*>(elem->call_data); |
|
|
|
if (calld->original_recv_initial_metadata_ready) { |
|
|
|
if (calld->original_recv_initial_metadata_ready != nullptr) { |
|
|
|
calld->recv_trailing_metadata_error = GRPC_ERROR_REF(err); |
|
|
|
calld->recv_trailing_metadata_error = GRPC_ERROR_REF(err); |
|
|
|
calld->seen_recv_trailing_ready = true; |
|
|
|
calld->seen_recv_trailing_ready = true; |
|
|
|
GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready, |
|
|
|
GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready, |
|
|
|
recv_trailing_metadata_ready, elem, |
|
|
|
recv_trailing_metadata_ready, elem, |
|
|
|
grpc_schedule_on_exec_ctx); |
|
|
|
grpc_schedule_on_exec_ctx); |
|
|
|
GRPC_CALL_COMBINER_STOP(calld->call_combiner, "wait for initial metadata"); |
|
|
|
GRPC_CALL_COMBINER_STOP(calld->call_combiner, |
|
|
|
|
|
|
|
"deferring recv_trailing_metadata_ready until " |
|
|
|
|
|
|
|
"after recv_initial_metadata_ready"); |
|
|
|
} |
|
|
|
} |
|
|
|
err = grpc_error_add_child(GRPC_ERROR_REF(err), GRPC_ERROR_REF(calld->error)); |
|
|
|
err = grpc_error_add_child( |
|
|
|
|
|
|
|
GRPC_ERROR_REF(err), GRPC_ERROR_REF(calld->recv_initial_metadata_error)); |
|
|
|
GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready, err); |
|
|
|
GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_ready, err); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -251,7 +256,6 @@ static grpc_error* init_call_elem(grpc_call_element* elem, |
|
|
|
GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready, |
|
|
|
GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready, |
|
|
|
recv_trailing_metadata_ready, elem, |
|
|
|
recv_trailing_metadata_ready, elem, |
|
|
|
grpc_schedule_on_exec_ctx); |
|
|
|
grpc_schedule_on_exec_ctx); |
|
|
|
calld->seen_recv_trailing_ready = false; |
|
|
|
|
|
|
|
// Create server security context. Set its auth context from channel
|
|
|
|
// Create server security context. Set its auth context from channel
|
|
|
|
// data and save it in the call context.
|
|
|
|
// data and save it in the call context.
|
|
|
|
grpc_server_security_context* server_ctx = |
|
|
|
grpc_server_security_context* server_ctx = |
|
|
@ -273,7 +277,7 @@ 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_ERROR_UNREF(calld->error); |
|
|
|
GRPC_ERROR_UNREF(calld->recv_initial_metadata_error); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Constructor for channel_data */ |
|
|
|
/* Constructor for channel_data */ |
|
|
|