@@ -120,6 +120,7 @@ typedef struct inproc_stream {
120120 struct inproc_stream * stream_list_next;
121121} inproc_stream;
122122
123+ static grpc_closure do_nothing_closure;
123124static bool cancel_stream_locked (inproc_stream* s, grpc_error* error);
124125static void op_state_machine (void * arg, grpc_error* error);
125126
@@ -372,10 +373,6 @@ static void complete_if_batch_end_locked(inproc_stream* s, grpc_error* error,
372373 const char * msg) {
373374 int is_sm = static_cast <int >(op == s->send_message_op );
374375 int is_stm = static_cast <int >(op == s->send_trailing_md_op );
375- // TODO(vjpai): We should not consider the recv ops here, since they
376- // have their own callbacks. We should invoke a batch's on_complete
377- // as soon as all of the batch's send ops are complete, even if there
378- // are still recv ops pending.
379376 int is_rim = static_cast <int >(op == s->recv_initial_md_op );
380377 int is_rm = static_cast <int >(op == s->recv_message_op );
381378 int is_rtm = static_cast <int >(op == s->recv_trailing_md_op );
@@ -499,11 +496,6 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) {
499496 s->send_trailing_md_op = nullptr ;
500497 }
501498 if (s->recv_trailing_md_op ) {
502- INPROC_LOG (GPR_INFO , " fail_helper %p scheduling trailing-metadata-ready %p" ,
503- s, error);
504- GRPC_CLOSURE_SCHED (s->recv_trailing_md_op ->payload ->recv_trailing_metadata
505- .recv_trailing_metadata_ready ,
506- GRPC_ERROR_REF (error));
507499 INPROC_LOG (GPR_INFO , " fail_helper %p scheduling trailing-md-on-complete %p" ,
508500 s, error);
509501 complete_if_batch_end_locked (
@@ -646,12 +638,6 @@ static void op_state_machine(void* arg, grpc_error* error) {
646638 }
647639 s->trailing_md_sent = true ;
648640 if (!s->t ->is_client && s->trailing_md_recvd && s->recv_trailing_md_op ) {
649- INPROC_LOG (GPR_INFO ,
650- " op_state_machine %p scheduling trailing-metadata-ready" , s);
651- GRPC_CLOSURE_SCHED (
652- s->recv_trailing_md_op ->payload ->recv_trailing_metadata
653- .recv_trailing_metadata_ready ,
654- GRPC_ERROR_NONE );
655641 INPROC_LOG (GPR_INFO ,
656642 " op_state_machine %p scheduling trailing-md-on-complete" , s);
657643 GRPC_CLOSURE_SCHED (s->recv_trailing_md_op ->on_complete ,
@@ -725,12 +711,6 @@ static void op_state_machine(void* arg, grpc_error* error) {
725711 }
726712 if (s->recv_trailing_md_op && s->t ->is_client && other &&
727713 other->send_message_op ) {
728- INPROC_LOG (GPR_INFO ,
729- " op_state_machine %p scheduling trailing-metadata-ready %p" , s,
730- GRPC_ERROR_NONE );
731- GRPC_CLOSURE_SCHED (s->recv_trailing_md_op ->payload ->recv_trailing_metadata
732- .recv_trailing_metadata_ready ,
733- GRPC_ERROR_NONE );
734714 maybe_schedule_op_closure_locked (other, GRPC_ERROR_NONE );
735715 }
736716 if (s->to_read_trailing_md_filled ) {
@@ -786,10 +766,6 @@ static void op_state_machine(void* arg, grpc_error* error) {
786766 INPROC_LOG (GPR_INFO ,
787767 " op_state_machine %p scheduling trailing-md-on-complete %p" ,
788768 s, new_err);
789- GRPC_CLOSURE_SCHED (
790- s->recv_trailing_md_op ->payload ->recv_trailing_metadata
791- .recv_trailing_metadata_ready ,
792- GRPC_ERROR_REF (new_err));
793769 GRPC_CLOSURE_SCHED (s->recv_trailing_md_op ->on_complete ,
794770 GRPC_ERROR_REF (new_err));
795771 s->recv_trailing_md_op = nullptr ;
@@ -883,9 +859,6 @@ static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) {
883859 // couldn't complete that because we hadn't yet sent out trailing
884860 // md, now's the chance
885861 if (!s->t ->is_client && s->trailing_md_recvd && s->recv_trailing_md_op ) {
886- GRPC_CLOSURE_SCHED (s->recv_trailing_md_op ->payload ->recv_trailing_metadata
887- .recv_trailing_metadata_ready ,
888- GRPC_ERROR_REF (s->cancel_self_error ));
889862 complete_if_batch_end_locked (
890863 s, s->cancel_self_error , s->recv_trailing_md_op ,
891864 " cancel_stream scheduling trailing-md-on-complete" );
@@ -900,8 +873,6 @@ static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) {
900873 return ret;
901874}
902875
903- static void do_nothing (void * arg, grpc_error* error) {}
904-
905876static void perform_stream_op (grpc_transport* gt, grpc_stream* gs,
906877 grpc_transport_stream_op_batch* op) {
907878 INPROC_LOG (GPR_INFO , " perform_stream_op %p %p %p" , gt, gs, op);
@@ -921,14 +892,8 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
921892 }
922893 grpc_error* error = GRPC_ERROR_NONE ;
923894 grpc_closure* on_complete = op->on_complete ;
924- // TODO(roth): This is a hack needed because we use data inside of the
925- // closure itself to do the barrier calculation (i.e., to ensure that
926- // we don't schedule the closure until all ops in the batch have been
927- // completed). This can go away once we move to a new C++ closure API
928- // that provides the ability to create a barrier closure.
929895 if (on_complete == nullptr ) {
930- on_complete = GRPC_CLOSURE_INIT (&op->handler_private .closure , do_nothing,
931- nullptr , grpc_schedule_on_exec_ctx);
896+ on_complete = &do_nothing_closure;
932897 }
933898
934899 if (op->cancel_stream ) {
@@ -1061,15 +1026,6 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
10611026 GRPC_CLOSURE_SCHED (op->payload ->recv_message .recv_message_ready ,
10621027 GRPC_ERROR_REF (error));
10631028 }
1064- if (op->recv_trailing_metadata ) {
1065- INPROC_LOG (
1066- GPR_INFO ,
1067- " perform_stream_op error %p scheduling trailing-metadata-ready %p" ,
1068- s, error);
1069- GRPC_CLOSURE_SCHED (
1070- op->payload ->recv_trailing_metadata .recv_trailing_metadata_ready ,
1071- GRPC_ERROR_REF (error));
1072- }
10731029 }
10741030 INPROC_LOG (GPR_INFO , " perform_stream_op %p scheduling on_complete %p" , s,
10751031 error);
@@ -1173,8 +1129,12 @@ static grpc_endpoint* get_endpoint(grpc_transport* t) { return nullptr; }
11731129/* ******************************************************************************
11741130 * GLOBAL INIT AND DESTROY
11751131 */
1132+ static void do_nothing (void * arg, grpc_error* error) {}
1133+
11761134void grpc_inproc_transport_init (void ) {
11771135 grpc_core::ExecCtx exec_ctx;
1136+ GRPC_CLOSURE_INIT (&do_nothing_closure, do_nothing, nullptr ,
1137+ grpc_schedule_on_exec_ctx);
11781138 g_empty_slice = grpc_slice_from_static_buffer (nullptr , 0 );
11791139
11801140 grpc_slice key_tmp = grpc_slice_from_static_string (" :path" );
0 commit comments