wearefair-grpc 1.3.1.pre.c → 1.4.0.fair

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +418 -126
  3. data/include/grpc/grpc.h +15 -69
  4. data/include/grpc/grpc_security.h +1 -1
  5. data/include/grpc/impl/codegen/compression_types.h +3 -4
  6. data/include/grpc/impl/codegen/gpr_types.h +0 -1
  7. data/include/grpc/impl/codegen/grpc_types.h +69 -3
  8. data/include/grpc/impl/codegen/port_platform.h +6 -0
  9. data/include/grpc/impl/codegen/slice.h +2 -1
  10. data/include/grpc/load_reporting.h +6 -6
  11. data/include/grpc/slice.h +25 -3
  12. data/include/grpc/slice_buffer.h +4 -0
  13. data/src/core/ext/census/context.c +1 -1
  14. data/src/core/ext/census/resource.c +3 -1
  15. data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
  16. data/src/core/ext/filters/client_channel/client_channel.c +158 -100
  17. data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
  18. data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
  19. data/src/core/ext/filters/client_channel/lb_policy.h +5 -6
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +344 -88
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
  25. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -5
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +6 -0
  27. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
  29. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
  30. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +13 -12
  31. data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
  32. data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
  33. data/src/core/ext/filters/client_channel/parse_address.c +37 -7
  34. data/src/core/ext/filters/client_channel/parse_address.h +11 -8
  35. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
  36. data/src/core/ext/filters/client_channel/subchannel.c +19 -16
  37. data/src/core/ext/filters/client_channel/subchannel.h +1 -0
  38. data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
  39. data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
  40. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
  41. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
  42. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
  43. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
  44. data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
  45. data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
  46. data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
  47. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
  48. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
  49. data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
  50. data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
  51. data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
  52. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
  53. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
  54. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  55. data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
  56. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
  57. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
  58. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +296 -172
  59. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
  60. data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
  61. data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
  62. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
  63. data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
  64. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  65. data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
  66. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
  67. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
  68. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
  69. data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
  70. data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
  71. data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
  72. data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
  73. data/src/core/lib/channel/channel_args.c +28 -9
  74. data/src/core/lib/channel/channel_args.h +5 -1
  75. data/src/core/lib/channel/channel_stack.c +1 -1
  76. data/src/core/lib/channel/channel_stack.h +2 -2
  77. data/src/core/lib/channel/channel_stack_builder.c +13 -1
  78. data/src/core/lib/channel/channel_stack_builder.h +5 -1
  79. data/src/core/lib/channel/connected_channel.c +3 -1
  80. data/src/core/lib/channel/context.h +2 -2
  81. data/src/core/lib/compression/message_compress.c +2 -2
  82. data/src/core/lib/debug/trace.c +13 -6
  83. data/src/core/lib/debug/trace.h +27 -1
  84. data/src/core/lib/http/httpcli.c +1 -1
  85. data/src/core/lib/http/httpcli_security_connector.c +6 -10
  86. data/src/core/lib/http/parser.c +2 -2
  87. data/src/core/lib/http/parser.h +2 -1
  88. data/src/core/lib/iomgr/combiner.c +6 -6
  89. data/src/core/lib/iomgr/combiner.h +2 -1
  90. data/src/core/lib/iomgr/error.c +12 -5
  91. data/src/core/lib/iomgr/error.h +13 -13
  92. data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
  93. data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
  94. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
  95. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
  96. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
  97. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
  98. data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
  99. data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
  100. data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +24 -31
  101. data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
  102. data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
  103. data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
  104. data/src/core/lib/iomgr/ev_posix.c +22 -8
  105. data/src/core/lib/iomgr/ev_posix.h +4 -3
  106. data/src/core/lib/iomgr/exec_ctx.c +5 -0
  107. data/src/core/lib/iomgr/exec_ctx.h +2 -0
  108. data/src/core/lib/iomgr/iomgr.c +4 -0
  109. data/src/core/lib/iomgr/iomgr.h +3 -0
  110. data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
  111. data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
  112. data/src/core/lib/iomgr/lockfree_event.c +16 -0
  113. data/src/core/lib/iomgr/pollset.h +2 -5
  114. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  115. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  116. data/src/core/lib/iomgr/resource_quota.c +9 -8
  117. data/src/core/lib/iomgr/resource_quota.h +2 -1
  118. data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
  119. data/src/core/lib/iomgr/socket_mutator.h +2 -0
  120. data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
  121. data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
  122. data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
  123. data/src/core/lib/iomgr/tcp_posix.c +7 -7
  124. data/src/core/lib/iomgr/tcp_posix.h +2 -1
  125. data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
  126. data/src/core/lib/iomgr/tcp_uv.c +6 -6
  127. data/src/core/lib/iomgr/tcp_uv.h +2 -1
  128. data/src/core/lib/iomgr/tcp_windows.c +1 -1
  129. data/src/core/lib/iomgr/timer_generic.c +24 -25
  130. data/src/core/lib/iomgr/timer_manager.c +276 -0
  131. data/src/core/lib/iomgr/timer_manager.h +52 -0
  132. data/src/core/lib/iomgr/timer_uv.c +6 -0
  133. data/src/core/lib/iomgr/udp_server.c +42 -9
  134. data/src/core/lib/iomgr/udp_server.h +3 -1
  135. data/src/core/lib/security/credentials/credentials.c +0 -1
  136. data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
  137. data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
  138. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
  139. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
  140. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
  141. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
  142. data/src/core/lib/security/transport/client_auth_filter.c +9 -3
  143. data/src/core/lib/security/transport/secure_endpoint.c +7 -7
  144. data/src/core/lib/security/transport/secure_endpoint.h +1 -1
  145. data/src/core/lib/security/transport/security_connector.c +32 -51
  146. data/src/core/lib/security/transport/security_connector.h +10 -14
  147. data/src/core/lib/slice/b64.c +1 -1
  148. data/src/core/lib/slice/percent_encoding.c +3 -3
  149. data/src/core/lib/slice/slice.c +66 -33
  150. data/src/core/lib/slice/slice_buffer.c +25 -6
  151. data/src/core/lib/slice/slice_hash_table.c +33 -35
  152. data/src/core/lib/slice/slice_hash_table.h +7 -12
  153. data/src/core/lib/support/atomic.h +45 -0
  154. data/src/core/lib/support/atomic_with_atm.h +70 -0
  155. data/src/core/lib/support/atomic_with_std.h +48 -0
  156. data/src/core/lib/support/avl.c +14 -14
  157. data/src/core/lib/support/memory.h +74 -0
  158. data/src/core/lib/support/mpscq.c +12 -1
  159. data/src/core/lib/support/mpscq.h +4 -0
  160. data/src/core/lib/support/stack_lockfree.c +3 -36
  161. data/src/core/lib/support/time_posix.c +8 -0
  162. data/src/core/lib/support/tmpfile_posix.c +10 -10
  163. data/src/core/lib/surface/alarm.c +3 -1
  164. data/src/core/lib/surface/api_trace.c +2 -1
  165. data/src/core/lib/surface/api_trace.h +2 -2
  166. data/src/core/lib/surface/byte_buffer_reader.c +1 -1
  167. data/src/core/lib/surface/call.c +65 -22
  168. data/src/core/lib/surface/call.h +4 -2
  169. data/src/core/lib/surface/channel_init.c +2 -19
  170. data/src/core/lib/surface/channel_stack_type.c +18 -0
  171. data/src/core/lib/surface/channel_stack_type.h +2 -0
  172. data/src/core/lib/surface/completion_queue.c +249 -83
  173. data/src/core/lib/surface/completion_queue.h +18 -13
  174. data/src/core/lib/surface/completion_queue_factory.c +24 -9
  175. data/src/core/lib/surface/init.c +1 -52
  176. data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
  177. data/src/core/lib/surface/server.c +50 -27
  178. data/src/core/lib/surface/server.h +2 -1
  179. data/src/core/lib/surface/version.c +2 -2
  180. data/src/core/lib/transport/bdp_estimator.c +20 -9
  181. data/src/core/lib/transport/bdp_estimator.h +5 -1
  182. data/src/core/lib/transport/byte_stream.c +23 -9
  183. data/src/core/lib/transport/byte_stream.h +15 -6
  184. data/src/core/lib/transport/connectivity_state.c +6 -6
  185. data/src/core/lib/transport/connectivity_state.h +2 -1
  186. data/src/core/lib/transport/service_config.c +6 -13
  187. data/src/core/lib/transport/service_config.h +2 -2
  188. data/src/core/lib/transport/static_metadata.c +403 -389
  189. data/src/core/lib/transport/static_metadata.h +127 -114
  190. data/src/core/plugin_registry/grpc_plugin_registry.c +12 -0
  191. data/src/core/tsi/fake_transport_security.c +5 -4
  192. data/src/core/tsi/ssl_transport_security.c +71 -82
  193. data/src/core/tsi/ssl_transport_security.h +39 -61
  194. data/src/core/tsi/transport_security.c +83 -2
  195. data/src/core/tsi/transport_security.h +27 -2
  196. data/src/core/tsi/transport_security_adapter.c +236 -0
  197. data/src/core/tsi/transport_security_adapter.h +62 -0
  198. data/src/core/tsi/transport_security_interface.h +179 -66
  199. data/src/ruby/ext/grpc/extconf.rb +2 -1
  200. data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
  201. data/src/ruby/ext/grpc/rb_call.c +56 -48
  202. data/src/ruby/ext/grpc/rb_call.h +3 -4
  203. data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
  204. data/src/ruby/ext/grpc/rb_channel.c +45 -29
  205. data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
  206. data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
  207. data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
  208. data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
  209. data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
  210. data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
  211. data/src/ruby/ext/grpc/rb_grpc.c +11 -15
  212. data/src/ruby/ext/grpc/rb_grpc.h +2 -2
  213. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +14 -6
  214. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +22 -10
  215. data/src/ruby/ext/grpc/rb_server.c +26 -28
  216. data/src/ruby/lib/grpc/version.rb +1 -1
  217. metadata +40 -18
  218. data/src/ruby/lib/grpc/grpc_c.bundle +0 -0
  219. data/src/ruby/lib/grpc/grpc_c.so +0 -0
@@ -163,7 +163,7 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
163
163
  void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
164
164
  grpc_slice debug_data,
165
165
  grpc_slice_buffer *slice_buffer) {
166
- grpc_slice header = grpc_slice_malloc(9 + 4 + 4);
166
+ grpc_slice header = GRPC_SLICE_MALLOC(9 + 4 + 4);
167
167
  uint8_t *p = GRPC_SLICE_START_PTR(header);
168
168
  uint32_t frame_length;
169
169
  GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
@@ -43,7 +43,7 @@
43
43
  static bool g_disable_ping_ack = false;
44
44
 
45
45
  grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
46
- grpc_slice slice = grpc_slice_malloc(9 + 8);
46
+ grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8);
47
47
  uint8_t *p = GRPC_SLICE_START_PTR(slice);
48
48
 
49
49
  *p++ = 0;
@@ -44,7 +44,7 @@
44
44
  grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
45
45
  grpc_transport_one_way_stats *stats) {
46
46
  static const size_t frame_size = 13;
47
- grpc_slice slice = grpc_slice_malloc(frame_size);
47
+ grpc_slice slice = GRPC_SLICE_MALLOC(frame_size);
48
48
  stats->framing_bytes += frame_size;
49
49
  uint8_t *p = GRPC_SLICE_START_PTR(slice);
50
50
 
@@ -70,7 +70,7 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
70
70
  n += (new[i] != old[i] || (force_mask & (1u << i)) != 0);
71
71
  }
72
72
 
73
- output = grpc_slice_malloc(9 + 6 * n);
73
+ output = GRPC_SLICE_MALLOC(9 + 6 * n);
74
74
  p = fill_header(GRPC_SLICE_START_PTR(output), 6 * n, 0);
75
75
 
76
76
  for (i = 0; i < count; i++) {
@@ -91,7 +91,7 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
91
91
  }
92
92
 
93
93
  grpc_slice grpc_chttp2_settings_ack_create(void) {
94
- grpc_slice output = grpc_slice_malloc(9);
94
+ grpc_slice output = GRPC_SLICE_MALLOC(9);
95
95
  fill_header(GRPC_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK);
96
96
  return output;
97
97
  }
@@ -218,18 +218,18 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
218
218
  parser->incoming_settings[id] != parser->value) {
219
219
  t->initial_window_update +=
220
220
  (int64_t)parser->value - parser->incoming_settings[id];
221
- if (grpc_http_trace) {
221
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
222
222
  gpr_log(GPR_DEBUG, "adding %d for initial_window change",
223
223
  (int)t->initial_window_update);
224
224
  }
225
225
  }
226
226
  parser->incoming_settings[id] = parser->value;
227
- if (grpc_http_trace) {
227
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
228
228
  gpr_log(GPR_DEBUG, "CHTTP2:%s:%s: got setting %s = %d",
229
229
  t->is_client ? "CLI" : "SVR", t->peer_string, sp->name,
230
230
  parser->value);
231
231
  }
232
- } else if (grpc_http_trace) {
232
+ } else if (GRPC_TRACER_ON(grpc_http_trace)) {
233
233
  gpr_log(GPR_ERROR, "CHTTP2: Ignoring unknown setting %d (value %d)",
234
234
  parser->id, parser->value);
235
235
  }
@@ -41,7 +41,7 @@
41
41
  grpc_slice grpc_chttp2_window_update_create(
42
42
  uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) {
43
43
  static const size_t frame_size = 13;
44
- grpc_slice slice = grpc_slice_malloc(frame_size);
44
+ grpc_slice slice = GRPC_SLICE_MALLOC(frame_size);
45
45
  stats->header_bytes += frame_size;
46
46
  uint8_t *p = GRPC_SLICE_START_PTR(slice);
47
47
 
@@ -69,7 +69,7 @@ static grpc_slice_refcount terminal_slice_refcount = {NULL, NULL};
69
69
  static const grpc_slice terminal_slice = {&terminal_slice_refcount,
70
70
  .data.refcounted = {0, 0}};
71
71
 
72
- extern int grpc_http_trace;
72
+ extern grpc_tracer_flag grpc_http_trace;
73
73
 
74
74
  typedef struct {
75
75
  int is_first_frame;
@@ -123,7 +123,7 @@ static void finish_frame(framer_state *st, int is_header_boundary,
123
123
  output before beginning */
124
124
  static void begin_frame(framer_state *st) {
125
125
  st->header_idx =
126
- grpc_slice_buffer_add_indexed(st->output, grpc_slice_malloc(9));
126
+ grpc_slice_buffer_add_indexed(st->output, GRPC_SLICE_MALLOC(9));
127
127
  st->output_length_at_start_of_frame = st->output->length;
128
128
  }
129
129
 
@@ -425,7 +425,7 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
425
425
  "Reserved header (colon-prefixed) happening after regular ones.");
426
426
  }
427
427
 
428
- if (grpc_http_trace && !GRPC_MDELEM_IS_INTERNED(elem)) {
428
+ if (GRPC_TRACER_ON(grpc_http_trace) && !GRPC_MDELEM_IS_INTERNED(elem)) {
429
429
  char *k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
430
430
  char *v = grpc_slice_to_c_string(GRPC_MDVALUE(elem));
431
431
  gpr_log(
@@ -616,7 +616,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
616
616
  }
617
617
  }
618
618
  c->advertise_table_size_change = 1;
619
- if (grpc_http_trace) {
619
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
620
620
  gpr_log(GPR_DEBUG, "set max table size from encoder to %d", max_table_size);
621
621
  }
622
622
  }
@@ -50,8 +50,6 @@
50
50
  #include "src/core/lib/support/string.h"
51
51
  #include "src/core/lib/transport/http2_errors.h"
52
52
 
53
- extern int grpc_http_trace;
54
-
55
53
  typedef enum {
56
54
  NOT_BINARY,
57
55
  BINARY_BEGIN,
@@ -666,7 +664,7 @@ static const uint8_t inverse_base64[256] = {
666
664
  /* emission helpers */
667
665
  static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
668
666
  grpc_mdelem md, int add_to_table) {
669
- if (grpc_http_trace && !GRPC_MDELEM_IS_INTERNED(md)) {
667
+ if (GRPC_TRACER_ON(grpc_http_trace) && !GRPC_MDELEM_IS_INTERNED(md)) {
670
668
  char *k = grpc_slice_to_c_string(GRPC_MDKEY(md));
671
669
  char *v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
672
670
  gpr_log(
@@ -1052,7 +1050,7 @@ static grpc_error *parse_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
1052
1050
  static grpc_error *finish_max_tbl_size(grpc_exec_ctx *exec_ctx,
1053
1051
  grpc_chttp2_hpack_parser *p,
1054
1052
  const uint8_t *cur, const uint8_t *end) {
1055
- if (grpc_http_trace) {
1053
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
1056
1054
  gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
1057
1055
  }
1058
1056
  grpc_error *err =
@@ -40,9 +40,10 @@
40
40
  #include <grpc/support/log.h>
41
41
  #include <grpc/support/string_util.h>
42
42
 
43
+ #include "src/core/lib/debug/trace.h"
43
44
  #include "src/core/lib/support/murmur_hash.h"
44
45
 
45
- extern int grpc_http_trace;
46
+ extern grpc_tracer_flag grpc_http_trace;
46
47
 
47
48
  static struct {
48
49
  const char *key;
@@ -260,7 +261,7 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx *exec_ctx,
260
261
  if (tbl->max_bytes == max_bytes) {
261
262
  return;
262
263
  }
263
- if (grpc_http_trace) {
264
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
264
265
  gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes);
265
266
  }
266
267
  while (tbl->mem_used > max_bytes) {
@@ -284,7 +285,7 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
284
285
  gpr_free(msg);
285
286
  return err;
286
287
  }
287
- if (grpc_http_trace) {
288
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
288
289
  gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
289
290
  }
290
291
  while (tbl->mem_used > bytes) {
@@ -195,22 +195,20 @@ typedef struct grpc_chttp2_write_cb {
195
195
  struct grpc_chttp2_incoming_byte_stream {
196
196
  grpc_byte_stream base;
197
197
  gpr_refcount refs;
198
- struct grpc_chttp2_incoming_byte_stream *next_message;
199
- grpc_error *error;
200
198
 
201
- grpc_chttp2_transport *transport;
202
- grpc_chttp2_stream *stream;
203
- bool is_tail;
199
+ grpc_chttp2_transport *transport; /* immutable */
200
+ grpc_chttp2_stream *stream; /* immutable */
204
201
 
205
- gpr_mu slice_mu; // protects slices, on_next
206
- grpc_slice_buffer slices;
207
- grpc_closure *on_next;
208
- grpc_slice *next;
202
+ /* Accessed only by transport thread when stream->pending_byte_stream == false
203
+ * Accessed only by application thread when stream->pending_byte_stream ==
204
+ * true */
209
205
  uint32_t remaining_bytes;
210
206
 
207
+ /* Accessed only by transport thread when stream->pending_byte_stream == false
208
+ * Accessed only by application thread when stream->pending_byte_stream ==
209
+ * true */
211
210
  struct {
212
211
  grpc_closure closure;
213
- grpc_slice *slice;
214
212
  size_t max_size_hint;
215
213
  grpc_closure *on_complete;
216
214
  } next_action;
@@ -222,6 +220,7 @@ typedef enum {
222
220
  GRPC_CHTTP2_KEEPALIVE_STATE_WAITING,
223
221
  GRPC_CHTTP2_KEEPALIVE_STATE_PINGING,
224
222
  GRPC_CHTTP2_KEEPALIVE_STATE_DYING,
223
+ GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED,
225
224
  } grpc_chttp2_keepalive_state;
226
225
 
227
226
  struct grpc_chttp2_transport {
@@ -445,8 +444,8 @@ struct grpc_chttp2_stream {
445
444
  uint32_t id;
446
445
 
447
446
  /** window available for us to send to peer, over or under the initial window
448
- * size of the transport... ie:
449
- * outgoing_window = outgoing_window_delta + transport.initial_window_size */
447
+ * size of the transport... ie:
448
+ * outgoing_window = outgoing_window_delta + transport.initial_window_size */
450
449
  int64_t outgoing_window_delta;
451
450
  /** things the upper layers would like to send */
452
451
  grpc_metadata_batch *send_initial_metadata;
@@ -473,9 +472,6 @@ struct grpc_chttp2_stream {
473
472
  grpc_transport_stream_stats *collecting_stats;
474
473
  grpc_transport_stream_stats stats;
475
474
 
476
- /** number of streams that are currently being read */
477
- gpr_refcount active_streams;
478
-
479
475
  /** Is this stream closed for writing. */
480
476
  bool write_closed;
481
477
  /** Is this stream reading half-closed. */
@@ -499,7 +495,17 @@ struct grpc_chttp2_stream {
499
495
 
500
496
  grpc_chttp2_incoming_metadata_buffer metadata_buffer[2];
501
497
 
502
- grpc_chttp2_incoming_frame_queue incoming_frames;
498
+ grpc_slice_buffer frame_storage; /* protected by t combiner */
499
+
500
+ /* Accessed only by transport thread when stream->pending_byte_stream == false
501
+ * Accessed only by application thread when stream->pending_byte_stream ==
502
+ * true */
503
+ grpc_slice_buffer unprocessed_incoming_frames_buffer;
504
+ grpc_closure *on_next; /* protected by t combiner */
505
+ bool pending_byte_stream; /* protected by t combiner */
506
+ grpc_closure reset_byte_stream;
507
+ grpc_error *byte_stream_error; /* protected by t combiner */
508
+ bool received_last_frame; /* protected by t combiner */
503
509
 
504
510
  gpr_timespec deadline;
505
511
 
@@ -512,6 +518,9 @@ struct grpc_chttp2_stream {
512
518
  * incoming_window = incoming_window_delta + transport.initial_window_size */
513
519
  int64_t incoming_window_delta;
514
520
  /** parsing state for data frames */
521
+ /* Accessed only by transport thread when stream->pending_byte_stream == false
522
+ * Accessed only by application thread when stream->pending_byte_stream ==
523
+ * true */
515
524
  grpc_chttp2_data_parser data_parser;
516
525
  /** number of bytes received - reset at end of parse thread execution */
517
526
  int64_t received_bytes;
@@ -543,9 +552,14 @@ void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
543
552
  grpc_chttp2_transport *t,
544
553
  bool covered_by_poller, const char *reason);
545
554
 
546
- /** Someone is unlocking the transport mutex: check to see if writes
547
- are required, and frame them if so */
548
- bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t);
555
+ typedef enum {
556
+ GRPC_CHTTP2_NOTHING_TO_WRITE,
557
+ GRPC_CHTTP2_PARTIAL_WRITE,
558
+ GRPC_CHTTP2_FULL_WRITE,
559
+ } grpc_chttp2_begin_write_result;
560
+
561
+ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
562
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t);
549
563
  void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
550
564
  grpc_error *error);
551
565
 
@@ -620,13 +634,13 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
620
634
  #define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \
621
635
  (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1)
622
636
 
623
- extern int grpc_http_trace;
624
- extern int grpc_flowctl_trace;
637
+ extern grpc_tracer_flag grpc_http_trace;
638
+ extern grpc_tracer_flag grpc_flowctl_trace;
625
639
 
626
- #define GRPC_CHTTP2_IF_TRACING(stmt) \
627
- if (!(grpc_http_trace)) \
628
- ; \
629
- else \
640
+ #define GRPC_CHTTP2_IF_TRACING(stmt) \
641
+ if (!(GRPC_TRACER_ON(grpc_http_trace))) \
642
+ ; \
643
+ else \
630
644
  stmt
631
645
 
632
646
  typedef enum {
@@ -639,7 +653,7 @@ typedef enum {
639
653
  dst_var, src_context, src_var) \
640
654
  do { \
641
655
  assert(id1 == id2); \
642
- if (grpc_flowctl_trace) { \
656
+ if (GRPC_TRACER_ON(grpc_flowctl_trace)) { \
643
657
  grpc_chttp2_flowctl_trace( \
644
658
  __FILE__, __LINE__, phase, GRPC_CHTTP2_FLOWCTL_MOVE, #dst_context, \
645
659
  #dst_var, #src_context, #src_var, transport->is_client, id1, \
@@ -662,7 +676,7 @@ typedef enum {
662
676
  #define GRPC_CHTTP2_FLOW_CREDIT_COMMON(phase, transport, id, dst_context, \
663
677
  dst_var, amount) \
664
678
  do { \
665
- if (grpc_flowctl_trace) { \
679
+ if (GRPC_TRACER_ON(grpc_flowctl_trace)) { \
666
680
  grpc_chttp2_flowctl_trace(__FILE__, __LINE__, phase, \
667
681
  GRPC_CHTTP2_FLOWCTL_CREDIT, #dst_context, \
668
682
  #dst_var, NULL, #amount, transport->is_client, \
@@ -720,7 +734,7 @@ typedef enum {
720
734
  #define GRPC_CHTTP2_FLOW_DEBIT_COMMON(phase, transport, id, dst_context, \
721
735
  dst_var, amount) \
722
736
  do { \
723
- if (grpc_flowctl_trace) { \
737
+ if (GRPC_TRACER_ON(grpc_flowctl_trace)) { \
724
738
  grpc_chttp2_flowctl_trace(__FILE__, __LINE__, phase, \
725
739
  GRPC_CHTTP2_FLOWCTL_DEBIT, #dst_context, \
726
740
  #dst_var, NULL, #amount, transport->is_client, \
@@ -790,10 +804,13 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport *t);
790
804
  grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
791
805
  grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s,
792
806
  uint32_t frame_size, uint32_t flags);
793
- void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx,
794
- grpc_chttp2_incoming_byte_stream *bs,
795
- grpc_slice slice);
796
- void grpc_chttp2_incoming_byte_stream_finished(
807
+ grpc_error *grpc_chttp2_incoming_byte_stream_push(
808
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
809
+ grpc_slice slice, grpc_slice *slice_out);
810
+ grpc_error *grpc_chttp2_incoming_byte_stream_finished(
811
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
812
+ grpc_error *error, bool reset_on_error);
813
+ void grpc_chttp2_incoming_byte_stream_notify(
797
814
  grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
798
815
  grpc_error *error);
799
816
 
@@ -803,7 +820,7 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
803
820
  /** Add a new ping strike to ping_recv_state.ping_strikes. If
804
821
  ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY
805
822
  with error code ENHANCE_YOUR_CALM and additional debug data resembling
806
- too_many_pings followed by immediately closing the connection. */
823
+ "too_many_pings" followed by immediately closing the connection. */
807
824
  void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
808
825
  grpc_chttp2_transport *t);
809
826
 
@@ -324,7 +324,7 @@ static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx,
324
324
  case GRPC_CHTTP2_FRAME_GOAWAY:
325
325
  return init_goaway_parser(exec_ctx, t);
326
326
  default:
327
- if (grpc_http_trace) {
327
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
328
328
  gpr_log(GPR_ERROR, "Unknown frame type %02x", t->incoming_frame_type);
329
329
  }
330
330
  return init_skip_frame_parser(exec_ctx, t, 0);
@@ -418,11 +418,9 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx,
418
418
 
419
419
  GRPC_CHTTP2_FLOW_DEBIT_STREAM_INCOMING_WINDOW_DELTA("parse", t, s,
420
420
  incoming_frame_size);
421
- if ((int64_t)t->settings[GRPC_SENT_SETTINGS]
422
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] +
423
- (int64_t)s->incoming_window_delta - (int64_t)s->announce_window <=
424
- (int64_t)t->settings[GRPC_SENT_SETTINGS]
425
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] /
421
+ if ((int64_t)s->incoming_window_delta - (int64_t)s->announce_window <=
422
+ -(int64_t)t->settings[GRPC_SENT_SETTINGS]
423
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] /
426
424
  2) {
427
425
  grpc_chttp2_become_writable(exec_ctx, t, s,
428
426
  GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED,
@@ -458,12 +456,13 @@ static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx,
458
456
  return init_skip_frame_parser(exec_ctx, t, 0);
459
457
  }
460
458
  if (err == GRPC_ERROR_NONE) {
461
- err = grpc_chttp2_data_parser_begin_frame(&s->data_parser,
462
- t->incoming_frame_flags, s->id);
459
+ err = grpc_chttp2_data_parser_begin_frame(
460
+ &s->data_parser, t->incoming_frame_flags, s->id, s);
463
461
  }
464
462
  error_handler:
465
463
  if (err == GRPC_ERROR_NONE) {
466
464
  t->incoming_stream = s;
465
+ /* t->parser = grpc_chttp2_data_parser_parse;*/
467
466
  t->parser = grpc_chttp2_data_parser_parse;
468
467
  t->parser_data = &s->data_parser;
469
468
  return GRPC_ERROR_NONE;
@@ -493,7 +492,7 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
493
492
 
494
493
  GPR_ASSERT(s != NULL);
495
494
 
496
- if (grpc_http_trace) {
495
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
497
496
  char *key = grpc_slice_to_c_string(GRPC_MDKEY(md));
498
497
  char *value =
499
498
  grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -573,7 +572,7 @@ static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
573
572
 
574
573
  GPR_ASSERT(s != NULL);
575
574
 
576
- if (grpc_http_trace) {
575
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
577
576
  char *key = grpc_slice_to_c_string(GRPC_MDKEY(md));
578
577
  char *value =
579
578
  grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -806,7 +805,7 @@ static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx,
806
805
  if (err == GRPC_ERROR_NONE) {
807
806
  return err;
808
807
  } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
809
- if (grpc_http_trace) {
808
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
810
809
  const char *msg = grpc_error_string(err);
811
810
  gpr_log(GPR_ERROR, "%s", msg);
812
811
  }
@@ -74,7 +74,8 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
74
74
  }
75
75
  if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) {
76
76
  /* ping already in-flight: wait */
77
- if (grpc_http_trace || grpc_bdp_estimator_trace) {
77
+ if (GRPC_TRACER_ON(grpc_http_trace) ||
78
+ GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
78
79
  gpr_log(GPR_DEBUG, "Ping delayed [%p]: already pinging", t->peer_string);
79
80
  }
80
81
  return;
@@ -82,7 +83,8 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
82
83
  if (t->ping_state.pings_before_data_required == 0 &&
83
84
  t->ping_policy.max_pings_without_data != 0) {
84
85
  /* need to send something of substance before sending a ping again */
85
- if (grpc_http_trace || grpc_bdp_estimator_trace) {
86
+ if (GRPC_TRACER_ON(grpc_http_trace) ||
87
+ GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
86
88
  gpr_log(GPR_DEBUG, "Ping delayed [%p]: too many recent pings: %d/%d",
87
89
  t->peer_string, t->ping_state.pings_before_data_required,
88
90
  t->ping_policy.max_pings_without_data);
@@ -96,7 +98,8 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
96
98
  (int)t->ping_policy.min_time_between_pings.tv_nsec);*/
97
99
  if (gpr_time_cmp(elapsed, t->ping_policy.min_time_between_pings) < 0) {
98
100
  /* not enough elapsed time between successive pings */
99
- if (grpc_http_trace || grpc_bdp_estimator_trace) {
101
+ if (GRPC_TRACER_ON(grpc_http_trace) ||
102
+ GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
100
103
  gpr_log(GPR_DEBUG,
101
104
  "Ping delayed [%p]: not enough time elapsed since last ping",
102
105
  t->peer_string);
@@ -160,19 +163,22 @@ static bool stream_ref_if_not_destroyed(gpr_refcount *r) {
160
163
  return true;
161
164
  }
162
165
 
166
+ /* How many bytes of incoming flow control would we like to advertise */
163
167
  uint32_t grpc_chttp2_target_incoming_window(grpc_chttp2_transport *t) {
164
- return (uint32_t)GPR_MAX(
168
+ return (uint32_t)GPR_MIN(
165
169
  (int64_t)((1u << 31) - 1),
166
170
  t->stream_total_over_incoming_window +
167
- (int64_t)GPR_MAX(
168
- t->settings[GRPC_SENT_SETTINGS]
169
- [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] -
170
- t->stream_total_under_incoming_window,
171
- 0));
171
+ t->settings[GRPC_SENT_SETTINGS]
172
+ [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
172
173
  }
173
174
 
174
- bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
175
- grpc_chttp2_transport *t) {
175
+ /* How many bytes would we like to put on the wire during a single syscall */
176
+ static uint32_t target_write_size(grpc_chttp2_transport *t) {
177
+ return 1024 * 1024;
178
+ }
179
+
180
+ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
181
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
176
182
  grpc_chttp2_stream *s;
177
183
 
178
184
  GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0);
@@ -206,9 +212,20 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
206
212
  }
207
213
  }
208
214
 
215
+ bool partial_write = false;
216
+
209
217
  /* for each grpc_chttp2_stream that's become writable, frame it's data
210
218
  (according to available window sizes) and add to the output buffer */
211
- while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
219
+ while (true) {
220
+ if (t->outbuf.length > target_write_size(t)) {
221
+ partial_write = true;
222
+ break;
223
+ }
224
+
225
+ if (!grpc_chttp2_list_pop_writable_stream(t, &s)) {
226
+ break;
227
+ }
228
+
212
229
  bool sent_initial_metadata = s->sent_initial_metadata;
213
230
  bool now_writing = false;
214
231
 
@@ -395,7 +412,9 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx,
395
412
 
396
413
  GPR_TIMER_END("grpc_chttp2_begin_write", 0);
397
414
 
398
- return t->outbuf.count > 0;
415
+ return t->outbuf.count > 0 ? (partial_write ? GRPC_CHTTP2_PARTIAL_WRITE
416
+ : GRPC_CHTTP2_FULL_WRITE)
417
+ : GRPC_CHTTP2_NOTHING_TO_WRITE;
399
418
  }
400
419
 
401
420
  void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,