grpc 0.13.0 → 0.13.1.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/Makefile +1114 -937
  4. data/include/grpc/census.h +71 -89
  5. data/include/grpc/compression.h +7 -7
  6. data/include/grpc/grpc.h +65 -68
  7. data/include/grpc/grpc_security.h +38 -38
  8. data/include/grpc/impl/codegen/alloc.h +7 -7
  9. data/include/grpc/impl/codegen/byte_buffer.h +13 -13
  10. data/include/grpc/impl/codegen/grpc_types.h +7 -2
  11. data/include/grpc/impl/codegen/log.h +5 -5
  12. data/include/grpc/impl/codegen/port_platform.h +14 -6
  13. data/include/grpc/impl/codegen/slice.h +15 -15
  14. data/include/grpc/impl/codegen/slice_buffer.h +17 -17
  15. data/include/grpc/impl/codegen/sync.h +26 -22
  16. data/include/grpc/impl/codegen/time.h +22 -24
  17. data/include/grpc/support/avl.h +9 -8
  18. data/include/grpc/support/cmdline.h +12 -12
  19. data/include/grpc/support/cpu.h +2 -2
  20. data/include/grpc/support/histogram.h +22 -22
  21. data/include/grpc/support/host_port.h +2 -2
  22. data/include/grpc/support/log_win32.h +1 -1
  23. data/include/grpc/support/string_util.h +2 -2
  24. data/include/grpc/support/subprocess.h +5 -5
  25. data/include/grpc/support/thd.h +9 -9
  26. data/include/grpc/support/useful.h +3 -1
  27. data/src/core/census/context.c +64 -85
  28. data/src/core/census/grpc_filter.c +2 -2
  29. data/src/core/census/mlog.c +600 -0
  30. data/src/core/census/mlog.h +95 -0
  31. data/src/core/channel/channel_args.c +67 -6
  32. data/src/core/channel/channel_args.h +7 -1
  33. data/src/core/channel/client_channel.c +26 -36
  34. data/src/core/channel/client_uchannel.c +1 -1
  35. data/src/core/channel/http_client_filter.c +2 -2
  36. data/src/core/channel/http_server_filter.c +2 -2
  37. data/src/core/channel/subchannel_call_holder.c +5 -7
  38. data/src/core/client_config/connector.c +3 -2
  39. data/src/core/client_config/connector.h +2 -2
  40. data/src/core/client_config/lb_policies/load_balancer_api.c +163 -0
  41. data/src/core/client_config/lb_policies/load_balancer_api.h +85 -0
  42. data/src/core/client_config/lb_policies/pick_first.c +10 -11
  43. data/src/core/client_config/lb_policies/round_robin.c +7 -8
  44. data/src/core/client_config/lb_policy.c +3 -3
  45. data/src/core/client_config/lb_policy.h +3 -2
  46. data/src/core/client_config/subchannel.c +51 -21
  47. data/src/core/client_config/subchannel.h +15 -6
  48. data/src/core/client_config/subchannel_index.c +261 -0
  49. data/src/core/client_config/subchannel_index.h +77 -0
  50. data/src/core/compression/{algorithm.c → compression_algorithm.c} +0 -0
  51. data/src/core/httpcli/httpcli.c +13 -11
  52. data/src/core/httpcli/httpcli.h +3 -2
  53. data/src/core/httpcli/httpcli_security_connector.c +7 -7
  54. data/src/core/iomgr/fd_posix.c +4 -2
  55. data/src/core/iomgr/iocp_windows.c +10 -6
  56. data/src/core/iomgr/iocp_windows.h +9 -2
  57. data/src/core/iomgr/iomgr.c +18 -2
  58. data/src/core/iomgr/iomgr_internal.h +5 -1
  59. data/src/core/iomgr/pollset.h +9 -10
  60. data/src/core/iomgr/pollset_multipoller_with_epoll.c +1 -0
  61. data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +10 -5
  62. data/src/core/iomgr/pollset_posix.c +30 -35
  63. data/src/core/iomgr/pollset_posix.h +10 -6
  64. data/src/core/iomgr/pollset_set.h +3 -9
  65. data/src/core/iomgr/pollset_set_posix.c +23 -3
  66. data/src/core/iomgr/pollset_set_posix.h +2 -18
  67. data/src/core/iomgr/pollset_set_windows.c +3 -3
  68. data/src/core/iomgr/pollset_set_windows.h +2 -2
  69. data/src/core/iomgr/pollset_windows.c +24 -21
  70. data/src/core/iomgr/pollset_windows.h +1 -5
  71. data/src/core/iomgr/tcp_client_posix.c +7 -5
  72. data/src/core/iomgr/tcp_posix.c +4 -2
  73. data/src/core/iomgr/tcp_server_windows.c +1 -2
  74. data/src/core/iomgr/timer.c +2 -3
  75. data/src/core/iomgr/timer.h +21 -1
  76. data/src/core/iomgr/timer_heap.c +10 -12
  77. data/src/core/iomgr/udp_server.c +5 -4
  78. data/src/core/iomgr/udp_server.h +1 -0
  79. data/src/core/iomgr/workqueue_posix.c +1 -0
  80. data/src/core/iomgr/workqueue_posix.h +3 -1
  81. data/src/core/proto/grpc/lb/v0/load_balancer.pb.c +119 -0
  82. data/src/core/proto/grpc/lb/v0/load_balancer.pb.h +182 -0
  83. data/src/core/security/{base64.c → b64.c} +1 -1
  84. data/src/core/security/{base64.h → b64.h} +1 -1
  85. data/src/core/security/client_auth_filter.c +0 -1
  86. data/src/core/security/credentials.c +12 -5
  87. data/src/core/security/credentials.h +3 -3
  88. data/src/core/security/google_default_credentials.c +24 -19
  89. data/src/core/security/handshake.c +15 -7
  90. data/src/core/security/handshake.h +2 -1
  91. data/src/core/security/json_token.c +1 -1
  92. data/src/core/security/jwt_verifier.c +1 -1
  93. data/src/core/security/security_connector.c +84 -64
  94. data/src/core/security/security_connector.h +42 -22
  95. data/src/core/security/security_context.c +8 -3
  96. data/src/core/security/server_auth_filter.c +2 -2
  97. data/src/core/security/server_secure_chttp2.c +7 -7
  98. data/src/core/support/avl.c +2 -2
  99. data/src/core/support/env_linux.c +17 -0
  100. data/src/core/support/{file.c → load_file.c} +2 -2
  101. data/src/core/support/{file.h → load_file.h} +4 -12
  102. data/src/core/support/sync.c +6 -1
  103. data/src/core/support/time_posix.c +1 -1
  104. data/src/core/{iomgr/timer_internal.h → support/tmpfile.h} +17 -23
  105. data/src/core/support/{file_posix.c → tmpfile_posix.c} +2 -2
  106. data/src/core/support/{file_win32.c → tmpfile_win32.c} +2 -2
  107. data/src/core/surface/alarm.c +3 -2
  108. data/src/core/surface/call.c +102 -52
  109. data/src/core/surface/channel_create.c +1 -1
  110. data/src/core/surface/completion_queue.c +73 -41
  111. data/src/core/surface/init.c +4 -0
  112. data/src/core/surface/lame_client.c +1 -2
  113. data/src/core/surface/secure_channel_create.c +6 -7
  114. data/src/core/surface/server.c +13 -5
  115. data/src/core/surface/validate_metadata.c +1 -1
  116. data/src/core/surface/version.c +1 -1
  117. data/src/core/transport/chttp2/internal.h +22 -10
  118. data/src/core/transport/chttp2/parsing.c +3 -3
  119. data/src/core/transport/chttp2/stream_lists.c +39 -21
  120. data/src/core/transport/chttp2/writing.c +19 -28
  121. data/src/core/transport/chttp2_transport.c +80 -37
  122. data/src/core/transport/metadata.c +8 -0
  123. data/src/core/transport/static_metadata.c +17 -17
  124. data/src/core/transport/static_metadata.h +3 -3
  125. data/src/core/transport/transport.c +2 -1
  126. data/src/core/transport/transport.h +12 -5
  127. data/src/ruby/ext/grpc/extconf.rb +1 -0
  128. data/src/ruby/ext/grpc/rb_call.c +6 -0
  129. data/src/ruby/ext/grpc/rb_call_credentials.c +12 -14
  130. data/src/ruby/ext/grpc/rb_channel.c +8 -14
  131. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -12
  132. data/src/ruby/ext/grpc/rb_grpc.c +19 -18
  133. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  134. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -2
  135. data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
  136. data/src/ruby/lib/grpc/errors.rb +2 -2
  137. data/src/ruby/lib/grpc/generic/rpc_server.rb +58 -39
  138. data/src/ruby/lib/grpc/version.rb +1 -1
  139. data/src/ruby/pb/README.md +2 -2
  140. data/src/ruby/pb/generate_proto_ruby.sh +2 -2
  141. data/src/ruby/pb/grpc/health/checker.rb +11 -11
  142. data/src/ruby/pb/grpc/health/v1/health.rb +28 -0
  143. data/src/ruby/pb/grpc/health/{v1alpha → v1}/health_services.rb +4 -4
  144. data/src/ruby/spec/client_server_spec.rb +2 -1
  145. data/src/ruby/spec/generic/rpc_server_spec.rb +3 -22
  146. data/src/ruby/spec/pb/health/checker_spec.rb +22 -36
  147. data/third_party/nanopb/pb.h +547 -0
  148. data/third_party/nanopb/pb_common.c +97 -0
  149. data/third_party/nanopb/pb_common.h +42 -0
  150. data/third_party/nanopb/pb_decode.c +1319 -0
  151. data/third_party/nanopb/pb_decode.h +149 -0
  152. data/third_party/nanopb/pb_encode.c +690 -0
  153. data/third_party/nanopb/pb_encode.h +154 -0
  154. metadata +32 -16
  155. data/src/ruby/pb/grpc/health/v1alpha/health.rb +0 -29
@@ -142,7 +142,7 @@ static void incoming_byte_stream_update_flow_control(
142
142
  static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
143
143
  grpc_chttp2_stream_global *stream_global);
144
144
 
145
- /*
145
+ /*******************************************************************************
146
146
  * CONSTRUCTION/DESTRUCTION/REFCOUNTING
147
147
  */
148
148
 
@@ -432,6 +432,14 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
432
432
  if (t->ep) {
433
433
  allow_endpoint_shutdown_locked(exec_ctx, t);
434
434
  }
435
+
436
+ /* flush writable stream list to avoid dangling references */
437
+ grpc_chttp2_stream_global *stream_global;
438
+ grpc_chttp2_stream_writing *stream_writing;
439
+ while (grpc_chttp2_list_pop_writable_stream(
440
+ &t->global, &t->writing, &stream_global, &stream_writing)) {
441
+ GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "chttp2_writing");
442
+ }
435
443
  }
436
444
  }
437
445
 
@@ -521,7 +529,6 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
521
529
  s->global.id) == NULL);
522
530
  }
523
531
 
524
- grpc_chttp2_list_remove_writable_stream(&t->global, &s->global);
525
532
  grpc_chttp2_list_remove_unannounced_incoming_window_available(&t->global,
526
533
  &s->global);
527
534
  grpc_chttp2_list_remove_stalled_by_transport(&t->global, &s->global);
@@ -544,7 +551,7 @@ static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
544
551
  GPR_ASSERT(s->global.send_initial_metadata_finished == NULL);
545
552
  GPR_ASSERT(s->global.send_message_finished == NULL);
546
553
  GPR_ASSERT(s->global.send_trailing_metadata_finished == NULL);
547
- GPR_ASSERT(s->global.recv_initial_metadata_finished == NULL);
554
+ GPR_ASSERT(s->global.recv_initial_metadata_ready == NULL);
548
555
  GPR_ASSERT(s->global.recv_message_ready == NULL);
549
556
  GPR_ASSERT(s->global.recv_trailing_metadata_finished == NULL);
550
557
  grpc_chttp2_data_parser_destroy(exec_ctx, &s->parsing.data_parser);
@@ -583,7 +590,7 @@ grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream(
583
590
  return &accepting->parsing;
584
591
  }
585
592
 
586
- /*
593
+ /*******************************************************************************
587
594
  * LOCK MANAGEMENT
588
595
  */
589
596
 
@@ -598,7 +605,7 @@ static void lock(grpc_chttp2_transport *t) { gpr_mu_lock(&t->mu); }
598
605
  static void unlock(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
599
606
  GPR_TIMER_BEGIN("unlock", 0);
600
607
  if (!t->writing_active && !t->closed &&
601
- grpc_chttp2_unlocking_check_writes(&t->global, &t->writing,
608
+ grpc_chttp2_unlocking_check_writes(exec_ctx, &t->global, &t->writing,
602
609
  t->parsing_active)) {
603
610
  t->writing_active = 1;
604
611
  REF_TRANSPORT(t, "writing");
@@ -611,10 +618,18 @@ static void unlock(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
611
618
  GPR_TIMER_END("unlock", 0);
612
619
  }
613
620
 
614
- /*
621
+ /*******************************************************************************
615
622
  * OUTPUT PROCESSING
616
623
  */
617
624
 
625
+ void grpc_chttp2_become_writable(grpc_chttp2_transport_global *transport_global,
626
+ grpc_chttp2_stream_global *stream_global) {
627
+ if (!TRANSPORT_FROM_GLOBAL(transport_global)->closed &&
628
+ grpc_chttp2_list_add_writable_stream(transport_global, stream_global)) {
629
+ GRPC_CHTTP2_STREAM_REF(stream_global, "chttp2_writing");
630
+ }
631
+ }
632
+
618
633
  static void push_setting(grpc_chttp2_transport *t, grpc_chttp2_setting_id id,
619
634
  uint32_t value) {
620
635
  const grpc_chttp2_setting_parameters *sp =
@@ -732,7 +747,7 @@ static void maybe_start_some_streams(
732
747
  stream_global->id, STREAM_FROM_GLOBAL(stream_global));
733
748
  stream_global->in_stream_map = 1;
734
749
  transport_global->concurrent_stream_count++;
735
- grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
750
+ grpc_chttp2_become_writable(transport_global, stream_global);
736
751
  }
737
752
  /* cancel out streams that will never be started */
738
753
  while (transport_global->next_stream_id >= MAX_CLIENT_STREAM_ID &&
@@ -821,7 +836,7 @@ static void perform_stream_op_locked(
821
836
  maybe_start_some_streams(exec_ctx, transport_global);
822
837
  } else {
823
838
  GPR_ASSERT(stream_global->id != 0);
824
- grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
839
+ grpc_chttp2_become_writable(transport_global, stream_global);
825
840
  }
826
841
  } else {
827
842
  grpc_chttp2_complete_closure_step(
@@ -838,7 +853,7 @@ static void perform_stream_op_locked(
838
853
  exec_ctx, &stream_global->send_message_finished, 0);
839
854
  } else if (stream_global->id != 0) {
840
855
  stream_global->send_message = op->send_message;
841
- grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
856
+ grpc_chttp2_become_writable(transport_global, stream_global);
842
857
  }
843
858
  }
844
859
 
@@ -858,14 +873,14 @@ static void perform_stream_op_locked(
858
873
  } else if (stream_global->id != 0) {
859
874
  /* TODO(ctiller): check if there's flow control for any outstanding
860
875
  bytes before going writable */
861
- grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
876
+ grpc_chttp2_become_writable(transport_global, stream_global);
862
877
  }
863
878
  }
864
879
 
865
880
  if (op->recv_initial_metadata != NULL) {
866
- GPR_ASSERT(stream_global->recv_initial_metadata_finished == NULL);
867
- stream_global->recv_initial_metadata_finished =
868
- add_closure_barrier(on_complete);
881
+ GPR_ASSERT(stream_global->recv_initial_metadata_ready == NULL);
882
+ stream_global->recv_initial_metadata_ready =
883
+ op->recv_initial_metadata_ready;
869
884
  stream_global->recv_initial_metadata = op->recv_initial_metadata;
870
885
  grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
871
886
  }
@@ -944,12 +959,10 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
944
959
  unlock(exec_ctx, t);
945
960
  }
946
961
 
947
- static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
948
- grpc_transport_op *op) {
949
- grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
950
- int close_transport = 0;
951
-
952
- lock(t);
962
+ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
963
+ grpc_chttp2_transport *t,
964
+ grpc_transport_op *op) {
965
+ bool close_transport = false;
953
966
 
954
967
  grpc_exec_ctx_enqueue(exec_ctx, op->on_consumed, true, NULL);
955
968
 
@@ -968,8 +981,8 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
968
981
  close_transport = !grpc_chttp2_has_streams(t);
969
982
  }
970
983
 
971
- if (op->set_accept_stream != NULL) {
972
- t->channel_callback.accept_stream = op->set_accept_stream;
984
+ if (op->set_accept_stream) {
985
+ t->channel_callback.accept_stream = op->set_accept_stream_fn;
973
986
  t->channel_callback.accept_stream_user_data =
974
987
  op->set_accept_stream_user_data;
975
988
  }
@@ -990,16 +1003,31 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
990
1003
  close_transport_locked(exec_ctx, t);
991
1004
  }
992
1005
 
993
- unlock(exec_ctx, t);
994
-
995
1006
  if (close_transport) {
996
- lock(t);
997
1007
  close_transport_locked(exec_ctx, t);
998
- unlock(exec_ctx, t);
999
1008
  }
1000
1009
  }
1001
1010
 
1002
- /*
1011
+ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
1012
+ grpc_transport_op *op) {
1013
+ grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
1014
+
1015
+ lock(t);
1016
+
1017
+ /* If there's a set_accept_stream ensure that we're not parsing
1018
+ to avoid changing things out from underneath */
1019
+ if (t->parsing_active && op->set_accept_stream) {
1020
+ GPR_ASSERT(t->post_parsing_op == NULL);
1021
+ t->post_parsing_op = gpr_malloc(sizeof(*op));
1022
+ memcpy(t->post_parsing_op, op, sizeof(*op));
1023
+ } else {
1024
+ perform_transport_op_locked(exec_ctx, t, op);
1025
+ }
1026
+
1027
+ unlock(exec_ctx, t);
1028
+ }
1029
+
1030
+ /*******************************************************************************
1003
1031
  * INPUT PROCESSING
1004
1032
  */
1005
1033
 
@@ -1009,15 +1037,21 @@ static void check_read_ops(grpc_exec_ctx *exec_ctx,
1009
1037
  grpc_byte_stream *bs;
1010
1038
  while (
1011
1039
  grpc_chttp2_list_pop_check_read_ops(transport_global, &stream_global)) {
1012
- if (stream_global->recv_initial_metadata_finished != NULL &&
1040
+ if (stream_global->recv_initial_metadata_ready != NULL &&
1013
1041
  stream_global->published_initial_metadata) {
1014
1042
  grpc_chttp2_incoming_metadata_buffer_publish(
1015
1043
  &stream_global->received_initial_metadata,
1016
1044
  stream_global->recv_initial_metadata);
1017
- grpc_chttp2_complete_closure_step(
1018
- exec_ctx, &stream_global->recv_initial_metadata_finished, 1);
1045
+ grpc_exec_ctx_enqueue(
1046
+ exec_ctx, stream_global->recv_initial_metadata_ready, true, NULL);
1047
+ stream_global->recv_initial_metadata_ready = NULL;
1019
1048
  }
1020
1049
  if (stream_global->recv_message_ready != NULL) {
1050
+ while (stream_global->seen_error &&
1051
+ (bs = grpc_chttp2_incoming_frame_queue_pop(
1052
+ &stream_global->incoming_frames)) != NULL) {
1053
+ grpc_byte_stream_destroy(exec_ctx, bs);
1054
+ }
1021
1055
  if (stream_global->incoming_frames.head != NULL) {
1022
1056
  *stream_global->recv_message = grpc_chttp2_incoming_frame_queue_pop(
1023
1057
  &stream_global->incoming_frames);
@@ -1058,7 +1092,6 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
1058
1092
  if (!s) {
1059
1093
  s = grpc_chttp2_stream_map_delete(&t->new_stream_map, id);
1060
1094
  }
1061
- grpc_chttp2_list_remove_writable_stream(&t->global, &s->global);
1062
1095
  GPR_ASSERT(s);
1063
1096
  s->global.in_stream_map = 0;
1064
1097
  if (t->parsing.incoming_stream == &s->parsing) {
@@ -1074,6 +1107,9 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
1074
1107
  if (grpc_chttp2_unregister_stream(t, s) && t->global.sent_goaway) {
1075
1108
  close_transport_locked(exec_ctx, t);
1076
1109
  }
1110
+ if (grpc_chttp2_list_remove_writable_stream(&t->global, &s->global)) {
1111
+ GRPC_CHTTP2_STREAM_UNREF(exec_ctx, &s->global, "chttp2_writing");
1112
+ }
1077
1113
 
1078
1114
  new_stream_count = grpc_chttp2_stream_map_size(&t->parsing_stream_map) +
1079
1115
  grpc_chttp2_stream_map_size(&t->new_stream_map);
@@ -1325,7 +1361,7 @@ static void update_global_window(void *args, uint32_t id, void *stream) {
1325
1361
  is_zero = stream_global->outgoing_window <= 0;
1326
1362
 
1327
1363
  if (was_zero && !is_zero) {
1328
- grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
1364
+ grpc_chttp2_become_writable(transport_global, stream_global);
1329
1365
  }
1330
1366
  }
1331
1367
 
@@ -1386,6 +1422,13 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, bool success) {
1386
1422
  /* handle higher level things */
1387
1423
  grpc_chttp2_publish_reads(exec_ctx, transport_global, transport_parsing);
1388
1424
  t->parsing_active = 0;
1425
+ /* handle delayed transport ops (if there is one) */
1426
+ if (t->post_parsing_op) {
1427
+ grpc_transport_op *op = t->post_parsing_op;
1428
+ t->post_parsing_op = NULL;
1429
+ perform_transport_op_locked(exec_ctx, t, op);
1430
+ gpr_free(op);
1431
+ }
1389
1432
  /* if a stream is in the stream map, and gets cancelled, we need to ensure
1390
1433
  * we are not parsing before continuing the cancellation to keep things in
1391
1434
  * a sane state */
@@ -1420,7 +1463,7 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, bool success) {
1420
1463
  GPR_TIMER_END("recv_data", 0);
1421
1464
  }
1422
1465
 
1423
- /*
1466
+ /*******************************************************************************
1424
1467
  * CALLBACK LOOP
1425
1468
  */
1426
1469
 
@@ -1434,7 +1477,7 @@ static void connectivity_state_set(
1434
1477
  state, reason);
1435
1478
  }
1436
1479
 
1437
- /*
1480
+ /*******************************************************************************
1438
1481
  * POLLSET STUFF
1439
1482
  */
1440
1483
 
@@ -1462,7 +1505,7 @@ static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
1462
1505
  unlock(exec_ctx, t);
1463
1506
  }
1464
1507
 
1465
- /*
1508
+ /*******************************************************************************
1466
1509
  * BYTE STREAM
1467
1510
  */
1468
1511
 
@@ -1502,7 +1545,7 @@ static void incoming_byte_stream_update_flow_control(
1502
1545
  add_max_recv_bytes);
1503
1546
  grpc_chttp2_list_add_unannounced_incoming_window_available(transport_global,
1504
1547
  stream_global);
1505
- grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
1548
+ grpc_chttp2_become_writable(transport_global, stream_global);
1506
1549
  }
1507
1550
  }
1508
1551
 
@@ -1617,7 +1660,7 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
1617
1660
  return incoming_byte_stream;
1618
1661
  }
1619
1662
 
1620
- /*
1663
+ /*******************************************************************************
1621
1664
  * TRACING
1622
1665
  */
1623
1666
 
@@ -1703,7 +1746,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase,
1703
1746
  gpr_free(prefix);
1704
1747
  }
1705
1748
 
1706
- /*
1749
+ /*******************************************************************************
1707
1750
  * INTEGRATION GLUE
1708
1751
  */
1709
1752
 
@@ -43,11 +43,13 @@
43
43
  #include <grpc/support/log.h>
44
44
  #include <grpc/support/string_util.h>
45
45
  #include <grpc/support/time.h>
46
+
46
47
  #include "src/core/profiling/timers.h"
47
48
  #include "src/core/support/murmur_hash.h"
48
49
  #include "src/core/support/string.h"
49
50
  #include "src/core/transport/chttp2/bin_encoder.h"
50
51
  #include "src/core/transport/static_metadata.h"
52
+ #include "src/core/iomgr/iomgr_internal.h"
51
53
 
52
54
  /* There are two kinds of mdelem and mdstr instances.
53
55
  * Static instances are declared in static_metadata.{h,c} and
@@ -227,6 +229,9 @@ void grpc_mdctx_global_shutdown(void) {
227
229
  if (shard->count != 0) {
228
230
  gpr_log(GPR_DEBUG, "WARNING: %d metadata elements were leaked",
229
231
  shard->count);
232
+ if (grpc_iomgr_abort_on_leaks()) {
233
+ abort();
234
+ }
230
235
  }
231
236
  gpr_free(shard->elems);
232
237
  }
@@ -237,6 +242,9 @@ void grpc_mdctx_global_shutdown(void) {
237
242
  if (shard->count != 0) {
238
243
  gpr_log(GPR_DEBUG, "WARNING: %d metadata strings were leaked",
239
244
  shard->count);
245
+ if (grpc_iomgr_abort_on_leaks()) {
246
+ abort();
247
+ }
240
248
  }
241
249
  gpr_free(shard->strs);
242
250
  }
@@ -35,11 +35,11 @@
35
35
  * WARNING: Auto-generated code.
36
36
  *
37
37
  * To make changes to this file, change
38
- *tools/codegen/core/gen_static_metadata.py,
38
+ * tools/codegen/core/gen_static_metadata.py,
39
39
  * and then re-run it.
40
40
  *
41
41
  * See metadata.h for an explanation of the interface here, and metadata.c for
42
- *an
42
+ * an
43
43
  * explanation of what's going on.
44
44
  */
45
45
 
@@ -69,21 +69,21 @@ const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
69
69
  "0", "1", "2", "200", "204", "206", "304", "400", "404", "500", "accept",
70
70
  "accept-charset", "accept-encoding", "accept-language", "accept-ranges",
71
71
  "access-control-allow-origin", "age", "allow", "application/grpc",
72
- ":authority", "authorization", "cache-control", "census", "census-bin",
73
- "content-disposition", "content-encoding", "content-language",
74
- "content-length", "content-location", "content-range", "content-type",
75
- "cookie", "date", "deflate", "deflate,gzip", "", "etag", "expect",
76
- "expires", "from", "GET", "grpc", "grpc-accept-encoding", "grpc-encoding",
77
- "grpc-internal-encoding-request", "grpc-message", "grpc-status",
78
- "grpc-timeout", "gzip", "gzip, deflate", "host", "http", "https",
79
- "identity", "identity,deflate", "identity,deflate,gzip", "identity,gzip",
80
- "if-match", "if-modified-since", "if-none-match", "if-range",
81
- "if-unmodified-since", "last-modified", "link", "location", "max-forwards",
82
- ":method", ":path", "POST", "proxy-authenticate", "proxy-authorization",
83
- "range", "referer", "refresh", "retry-after", ":scheme", "server",
84
- "set-cookie", "/", "/index.html", ":status", "strict-transport-security",
85
- "te", "trailers", "transfer-encoding", "user-agent", "vary", "via",
86
- "www-authenticate"};
72
+ ":authority", "authorization", "cache-control", "census-bin",
73
+ "census-binary-bin", "content-disposition", "content-encoding",
74
+ "content-language", "content-length", "content-location", "content-range",
75
+ "content-type", "cookie", "date", "deflate", "deflate,gzip", "", "etag",
76
+ "expect", "expires", "from", "GET", "grpc", "grpc-accept-encoding",
77
+ "grpc-encoding", "grpc-internal-encoding-request", "grpc-message",
78
+ "grpc-status", "grpc-timeout", "gzip", "gzip, deflate", "host", "http",
79
+ "https", "identity", "identity,deflate", "identity,deflate,gzip",
80
+ "identity,gzip", "if-match", "if-modified-since", "if-none-match",
81
+ "if-range", "if-unmodified-since", "last-modified", "link", "location",
82
+ "max-forwards", ":method", ":path", "POST", "proxy-authenticate",
83
+ "proxy-authorization", "range", "referer", "refresh", "retry-after",
84
+ ":scheme", "server", "set-cookie", "/", "/index.html", ":status",
85
+ "strict-transport-security", "te", "trailers", "transfer-encoding",
86
+ "user-agent", "vary", "via", "www-authenticate"};
87
87
 
88
88
  const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 29, 26, 30,
89
89
  28, 32, 27, 31};
@@ -94,10 +94,10 @@ extern grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
94
94
  #define GRPC_MDSTR_AUTHORIZATION (&grpc_static_mdstr_table[20])
95
95
  /* "cache-control" */
96
96
  #define GRPC_MDSTR_CACHE_CONTROL (&grpc_static_mdstr_table[21])
97
- /* "census" */
98
- #define GRPC_MDSTR_CENSUS (&grpc_static_mdstr_table[22])
99
97
  /* "census-bin" */
100
- #define GRPC_MDSTR_CENSUS_BIN (&grpc_static_mdstr_table[23])
98
+ #define GRPC_MDSTR_CENSUS_BIN (&grpc_static_mdstr_table[22])
99
+ /* "census-binary-bin" */
100
+ #define GRPC_MDSTR_CENSUS_BINARY_BIN (&grpc_static_mdstr_table[23])
101
101
  /* "content-disposition" */
102
102
  #define GRPC_MDSTR_CONTENT_DISPOSITION (&grpc_static_mdstr_table[24])
103
103
  /* "content-encoding" */
@@ -45,7 +45,7 @@ void grpc_stream_ref(grpc_stream_refcount *refcount, const char *reason) {
45
45
  #else
46
46
  void grpc_stream_ref(grpc_stream_refcount *refcount) {
47
47
  #endif
48
- gpr_ref(&refcount->refs);
48
+ gpr_ref_non_zero(&refcount->refs);
49
49
  }
50
50
 
51
51
  #ifdef GRPC_STREAM_REFCOUNT_DEBUG
@@ -126,6 +126,7 @@ char *grpc_transport_get_peer(grpc_exec_ctx *exec_ctx,
126
126
  void grpc_transport_stream_op_finish_with_failure(
127
127
  grpc_exec_ctx *exec_ctx, grpc_transport_stream_op *op) {
128
128
  grpc_exec_ctx_enqueue(exec_ctx, op->recv_message_ready, false, NULL);
129
+ grpc_exec_ctx_enqueue(exec_ctx, op->recv_initial_metadata_ready, false, NULL);
129
130
  grpc_exec_ctx_enqueue(exec_ctx, op->on_complete, false, NULL);
130
131
  }
131
132
 
@@ -92,6 +92,8 @@ typedef struct grpc_transport_stream_op {
92
92
 
93
93
  /** Receive initial metadata from the stream, into provided metadata batch. */
94
94
  grpc_metadata_batch *recv_initial_metadata;
95
+ /** Should be enqueued when initial metadata is ready to be processed. */
96
+ grpc_closure *recv_initial_metadata_ready;
95
97
 
96
98
  /** Receive message data from the stream, into provided byte stream. */
97
99
  grpc_byte_stream **recv_message;
@@ -103,7 +105,8 @@ typedef struct grpc_transport_stream_op {
103
105
  grpc_metadata_batch *recv_trailing_metadata;
104
106
 
105
107
  /** Should be enqueued when all requested operations (excluding recv_message
106
- which has its own closure) in a given batch have been completed. */
108
+ and recv_initial_metadata which have their own closures) in a given batch
109
+ have been completed. */
107
110
  grpc_closure *on_complete;
108
111
 
109
112
  /** If != GRPC_STATUS_OK, cancel this stream */
@@ -120,7 +123,7 @@ typedef struct grpc_transport_stream_op {
120
123
 
121
124
  /** Transport op: a set of operations to perform on a transport as a whole */
122
125
  typedef struct grpc_transport_op {
123
- /** called when processing of this op is done */
126
+ /** Called when processing of this op is done. */
124
127
  grpc_closure *on_consumed;
125
128
  /** connectivity monitoring - set connectivity_state to NULL to unsubscribe */
126
129
  grpc_closure *on_connectivity_state_change;
@@ -135,9 +138,13 @@ typedef struct grpc_transport_op {
135
138
  grpc_status_code goaway_status;
136
139
  gpr_slice *goaway_message;
137
140
  /** set the callback for accepting new streams;
138
- this is a permanent callback, unlike the other one-shot closures */
139
- void (*set_accept_stream)(grpc_exec_ctx *exec_ctx, void *user_data,
140
- grpc_transport *transport, const void *server_data);
141
+ this is a permanent callback, unlike the other one-shot closures.
142
+ If true, the callback is set to set_accept_stream_fn, with its
143
+ user_data argument set to set_accept_stream_user_data */
144
+ bool set_accept_stream;
145
+ void (*set_accept_stream_fn)(grpc_exec_ctx *exec_ctx, void *user_data,
146
+ grpc_transport *transport,
147
+ const void *server_data);
141
148
  void *set_accept_stream_user_data;
142
149
  /** add this transport to a pollset */
143
150
  grpc_pollset *bind_pollset;