grpc 1.6.7 → 1.7.0.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 (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +579 -77
  3. data/include/grpc/byte_buffer.h +1 -63
  4. data/include/grpc/compression.h +27 -5
  5. data/include/grpc/fork.h +24 -0
  6. data/include/grpc/grpc.h +12 -6
  7. data/include/grpc/grpc_security.h +28 -7
  8. data/include/grpc/impl/codegen/atm.h +1 -0
  9. data/include/grpc/impl/codegen/byte_buffer.h +86 -0
  10. data/include/grpc/impl/codegen/compression_types.h +63 -5
  11. data/include/grpc/impl/codegen/fork.h +48 -0
  12. data/include/grpc/impl/codegen/grpc_types.h +26 -9
  13. data/include/grpc/impl/codegen/port_platform.h +11 -4
  14. data/include/grpc/impl/codegen/slice.h +6 -1
  15. data/include/grpc/impl/codegen/sync.h +3 -1
  16. data/include/grpc/impl/codegen/sync_custom.h +36 -0
  17. data/include/grpc/module.modulemap +75 -3
  18. data/include/grpc/slice.h +1 -5
  19. data/include/grpc/support/sync_custom.h +24 -0
  20. data/src/core/ext/census/base_resources.c +14 -14
  21. data/src/core/ext/census/context.c +7 -5
  22. data/src/core/ext/census/grpc_filter.c +12 -14
  23. data/src/core/ext/census/mlog.c +2 -1
  24. data/src/core/ext/census/resource.c +13 -9
  25. data/src/core/ext/filters/client_channel/channel_connectivity.c +15 -8
  26. data/src/core/ext/filters/client_channel/client_channel.c +418 -439
  27. data/src/core/ext/filters/client_channel/client_channel_factory.c +4 -5
  28. data/src/core/ext/filters/client_channel/client_channel_plugin.c +2 -2
  29. data/src/core/ext/filters/client_channel/http_connect_handshaker.c +7 -5
  30. data/src/core/ext/filters/client_channel/http_proxy.c +17 -21
  31. data/src/core/ext/filters/client_channel/lb_policy.c +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +7 -7
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +371 -257
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +7 -5
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +25 -14
  36. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +16 -16
  37. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +33 -28
  38. data/src/core/ext/filters/client_channel/lb_policy_factory.c +10 -8
  39. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  40. data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +1 -1
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +7 -6
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +62 -28
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +29 -23
  44. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +25 -14
  45. data/src/core/ext/filters/client_channel/retry_throttle.c +9 -6
  46. data/src/core/ext/filters/client_channel/subchannel.c +30 -30
  47. data/src/core/ext/filters/client_channel/subchannel.h +1 -4
  48. data/src/core/ext/filters/client_channel/subchannel_index.c +31 -15
  49. data/src/core/ext/filters/client_channel/subchannel_index.h +7 -0
  50. data/src/core/ext/filters/client_channel/uri_parser.c +4 -3
  51. data/src/core/ext/filters/deadline/deadline_filter.c +78 -39
  52. data/src/core/ext/filters/deadline/deadline_filter.h +7 -1
  53. data/src/core/ext/filters/http/client/http_client_filter.c +14 -14
  54. data/src/core/ext/filters/http/http_filters_plugin.c +1 -1
  55. data/src/core/ext/filters/http/message_compress/message_compress_filter.c +240 -175
  56. data/src/core/ext/filters/http/server/http_server_filter.c +48 -36
  57. data/src/core/ext/filters/load_reporting/{load_reporting_filter.c → server_load_reporting_filter.c} +11 -12
  58. data/src/core/ext/filters/load_reporting/{load_reporting_filter.h → server_load_reporting_filter.h} +6 -5
  59. data/src/core/ext/filters/load_reporting/{load_reporting.c → server_load_reporting_plugin.c} +19 -13
  60. data/src/core/ext/filters/load_reporting/{load_reporting.h → server_load_reporting_plugin.h} +4 -3
  61. data/src/core/ext/filters/max_age/max_age_filter.c +2 -3
  62. data/src/core/ext/filters/message_size/message_size_filter.c +4 -2
  63. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +0 -1
  64. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +5 -5
  65. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  66. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +1 -1
  67. data/src/core/ext/transport/chttp2/server/chttp2_server.c +20 -18
  68. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +1 -0
  69. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +493 -210
  70. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
  71. data/src/core/ext/transport/chttp2/transport/flow_control.c +9 -8
  72. data/src/core/ext/transport/chttp2/transport/frame_data.c +2 -2
  73. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +2 -2
  74. data/src/core/ext/transport/chttp2/transport/frame_ping.c +5 -4
  75. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  76. data/src/core/ext/transport/chttp2/transport/frame_settings.c +10 -9
  77. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +9 -5
  78. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +62 -41
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +52 -8
  80. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  81. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +3 -2
  82. data/src/core/ext/transport/chttp2/transport/internal.h +60 -30
  83. data/src/core/ext/transport/chttp2/transport/parsing.c +16 -5
  84. data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -16
  85. data/src/core/ext/transport/chttp2/transport/stream_map.c +6 -4
  86. data/src/core/ext/transport/chttp2/transport/writing.c +133 -105
  87. data/src/core/ext/transport/inproc/inproc_transport.c +61 -65
  88. data/src/core/lib/channel/channel_args.c +112 -12
  89. data/src/core/lib/channel/channel_args.h +31 -0
  90. data/src/core/lib/channel/channel_stack.c +1 -15
  91. data/src/core/lib/channel/channel_stack.h +3 -10
  92. data/src/core/lib/channel/channel_stack_builder.c +41 -10
  93. data/src/core/lib/channel/channel_stack_builder.h +10 -0
  94. data/src/core/lib/channel/connected_channel.c +94 -23
  95. data/src/core/lib/channel/handshaker.c +8 -6
  96. data/src/core/lib/channel/handshaker_registry.c +1 -1
  97. data/src/core/lib/compression/algorithm_metadata.h +14 -0
  98. data/src/core/lib/compression/compression.c +101 -1
  99. data/src/core/lib/compression/stream_compression.c +32 -146
  100. data/src/core/lib/compression/stream_compression.h +28 -4
  101. data/src/core/lib/compression/stream_compression_gzip.c +228 -0
  102. data/src/core/lib/{iomgr/ev_epoll_thread_pool_linux.h → compression/stream_compression_gzip.h} +5 -7
  103. data/src/core/lib/compression/stream_compression_identity.c +94 -0
  104. data/src/core/lib/{iomgr/ev_epoll_limited_pollers_linux.h → compression/stream_compression_identity.h} +7 -8
  105. data/src/core/lib/debug/stats.c +174 -0
  106. data/src/core/lib/debug/stats.h +61 -0
  107. data/src/core/lib/debug/stats_data.c +687 -0
  108. data/src/core/lib/debug/stats_data.h +470 -0
  109. data/src/core/lib/debug/trace.c +3 -3
  110. data/src/core/lib/debug/trace.h +1 -1
  111. data/src/core/lib/http/format_request.c +1 -1
  112. data/src/core/lib/http/httpcli.c +8 -7
  113. data/src/core/lib/http/httpcli_security_connector.c +2 -1
  114. data/src/core/lib/http/parser.c +4 -3
  115. data/src/core/lib/iomgr/call_combiner.c +202 -0
  116. data/src/core/lib/iomgr/call_combiner.h +121 -0
  117. data/src/core/lib/iomgr/closure.c +18 -4
  118. data/src/core/lib/iomgr/combiner.c +11 -4
  119. data/src/core/lib/iomgr/error.c +26 -24
  120. data/src/core/lib/iomgr/ev_epoll1_linux.c +395 -212
  121. data/src/core/lib/iomgr/ev_epollex_linux.c +141 -128
  122. data/src/core/lib/iomgr/ev_epollsig_linux.c +44 -41
  123. data/src/core/lib/iomgr/ev_poll_posix.c +99 -75
  124. data/src/core/lib/iomgr/ev_posix.c +5 -9
  125. data/src/core/lib/iomgr/ev_posix.h +1 -1
  126. data/src/core/lib/iomgr/exec_ctx.h +6 -1
  127. data/src/core/lib/iomgr/executor.c +142 -36
  128. data/src/core/lib/iomgr/executor.h +6 -1
  129. data/src/core/lib/iomgr/fork_posix.c +88 -0
  130. data/src/core/lib/iomgr/fork_windows.c +39 -0
  131. data/src/core/lib/iomgr/iocp_windows.c +2 -0
  132. data/src/core/lib/iomgr/iomgr.c +2 -8
  133. data/src/core/lib/iomgr/is_epollexclusive_available.c +6 -6
  134. data/src/core/lib/iomgr/load_file.c +2 -1
  135. data/src/core/lib/iomgr/polling_entity.c +9 -9
  136. data/src/core/lib/iomgr/polling_entity.h +7 -1
  137. data/src/core/lib/iomgr/pollset.h +1 -1
  138. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  139. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  140. data/src/core/lib/iomgr/port.h +4 -0
  141. data/src/core/lib/iomgr/resolve_address_posix.c +8 -7
  142. data/src/core/lib/iomgr/resolve_address_windows.c +1 -1
  143. data/src/core/lib/iomgr/resource_quota.c +24 -19
  144. data/src/core/lib/iomgr/socket_factory_posix.c +4 -4
  145. data/src/core/lib/iomgr/socket_mutator.c +4 -4
  146. data/src/core/lib/iomgr/socket_utils_windows.c +0 -4
  147. data/src/core/lib/iomgr/tcp_client_posix.c +5 -4
  148. data/src/core/lib/iomgr/tcp_posix.c +181 -20
  149. data/src/core/lib/iomgr/tcp_server_posix.c +8 -7
  150. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +1 -1
  151. data/src/core/lib/iomgr/timer.h +4 -0
  152. data/src/core/lib/iomgr/timer_generic.c +138 -3
  153. data/src/core/lib/iomgr/timer_generic.h +3 -0
  154. data/src/core/lib/iomgr/timer_heap.c +4 -4
  155. data/src/core/lib/iomgr/timer_manager.c +2 -2
  156. data/src/core/lib/iomgr/timer_uv.c +2 -0
  157. data/src/core/lib/iomgr/udp_server.c +10 -8
  158. data/src/core/lib/iomgr/unix_sockets_posix.c +4 -2
  159. data/src/core/lib/iomgr/wakeup_fd_cv.c +9 -8
  160. data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -2
  161. data/src/core/lib/json/json.c +1 -1
  162. data/src/core/lib/json/json_string.c +13 -13
  163. data/src/core/lib/profiling/timers.h +18 -8
  164. data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -10
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +2 -1
  166. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +11 -6
  167. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +4 -4
  168. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +132 -50
  169. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  170. data/src/core/lib/security/transport/client_auth_filter.c +68 -135
  171. data/src/core/lib/security/transport/secure_endpoint.c +110 -90
  172. data/src/core/lib/security/transport/secure_endpoint.h +8 -3
  173. data/src/core/lib/security/transport/security_connector.c +10 -12
  174. data/src/core/lib/security/transport/security_handshaker.c +45 -24
  175. data/src/core/lib/security/transport/server_auth_filter.c +71 -20
  176. data/src/core/lib/slice/b64.c +2 -2
  177. data/src/core/lib/slice/slice.c +16 -14
  178. data/src/core/lib/slice/slice_buffer.c +5 -4
  179. data/src/core/lib/slice/slice_hash_table.c +3 -2
  180. data/src/core/lib/slice/slice_intern.c +8 -5
  181. data/src/core/lib/support/block_annotate.h +22 -0
  182. data/src/core/lib/support/fork.c +62 -0
  183. data/src/core/lib/support/fork.h +35 -0
  184. data/src/core/lib/support/log_linux.c +1 -1
  185. data/src/core/lib/support/string.c +15 -1
  186. data/src/core/lib/support/string.h +3 -0
  187. data/src/core/lib/support/thd_internal.h +6 -0
  188. data/src/core/lib/support/thd_posix.c +56 -0
  189. data/src/core/lib/support/thd_windows.c +2 -0
  190. data/src/core/lib/surface/alarm.c +22 -15
  191. data/src/core/lib/surface/byte_buffer.c +4 -2
  192. data/src/core/lib/surface/call.c +442 -141
  193. data/src/core/lib/surface/call.h +6 -6
  194. data/src/core/lib/surface/call_log_batch.c +1 -1
  195. data/src/core/lib/surface/call_test_only.h +12 -0
  196. data/src/core/lib/surface/channel.c +39 -4
  197. data/src/core/lib/surface/channel_init.c +6 -6
  198. data/src/core/lib/surface/channel_ping.c +2 -2
  199. data/src/core/lib/surface/completion_queue.c +56 -57
  200. data/src/core/lib/surface/init.c +17 -3
  201. data/src/core/lib/surface/init_secure.c +5 -1
  202. data/src/core/lib/surface/lame_client.cc +9 -10
  203. data/src/core/lib/surface/server.c +81 -72
  204. data/src/core/lib/surface/version.c +2 -2
  205. data/src/core/lib/transport/byte_stream.c +1 -0
  206. data/src/core/lib/transport/byte_stream.h +3 -1
  207. data/src/core/lib/transport/connectivity_state.c +2 -1
  208. data/src/core/lib/transport/metadata.c +7 -4
  209. data/src/core/lib/transport/metadata_batch.c +18 -16
  210. data/src/core/lib/transport/metadata_batch.h +1 -0
  211. data/src/core/lib/transport/service_config.c +5 -3
  212. data/src/core/lib/transport/static_metadata.c +395 -614
  213. data/src/core/lib/transport/static_metadata.h +165 -133
  214. data/src/core/lib/transport/status_conversion.c +1 -1
  215. data/src/core/lib/transport/transport.c +20 -20
  216. data/src/core/lib/transport/transport.h +8 -5
  217. data/src/core/lib/transport/transport_impl.h +0 -3
  218. data/src/core/lib/transport/transport_op_string.c +8 -1
  219. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -4
  220. data/src/core/tsi/fake_transport_security.c +133 -2
  221. data/src/core/tsi/fake_transport_security.h +5 -0
  222. data/src/core/tsi/ssl_transport_security.c +105 -8
  223. data/src/core/tsi/ssl_transport_security.h +30 -7
  224. data/src/core/tsi/transport_security.h +8 -2
  225. data/src/core/tsi/transport_security_grpc.c +20 -13
  226. data/src/core/tsi/transport_security_grpc.h +13 -9
  227. data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
  228. data/src/ruby/ext/grpc/rb_grpc.c +1 -1
  229. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
  230. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
  231. data/src/ruby/lib/grpc.rb +1 -0
  232. data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
  233. data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
  234. data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
  235. data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
  236. data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
  237. data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
  238. data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
  239. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
  240. data/src/ruby/lib/grpc/version.rb +1 -1
  241. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
  242. data/src/ruby/spec/channel_connection_spec.rb +1 -34
  243. data/src/ruby/spec/client_server_spec.rb +188 -82
  244. data/src/ruby/spec/generic/active_call_spec.rb +65 -11
  245. data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
  246. data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
  247. data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
  248. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
  249. data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
  250. data/src/ruby/spec/spec_helper.rb +4 -0
  251. data/src/ruby/spec/support/helpers.rb +73 -0
  252. data/src/ruby/spec/support/services.rb +147 -0
  253. data/third_party/cares/ares_build.h +21 -62
  254. data/third_party/cares/cares/ares.h +23 -1
  255. data/third_party/cares/cares/ares__close_sockets.c +2 -2
  256. data/third_party/cares/cares/ares_create_query.c +3 -3
  257. data/third_party/cares/cares/ares_expand_name.c +6 -2
  258. data/third_party/cares/cares/ares_expand_string.c +1 -1
  259. data/third_party/cares/cares/ares_getnameinfo.c +27 -7
  260. data/third_party/cares/cares/ares_init.c +407 -39
  261. data/third_party/cares/cares/ares_library_init.c +10 -0
  262. data/third_party/cares/cares/ares_library_init.h +2 -1
  263. data/third_party/cares/cares/ares_nowarn.c +6 -6
  264. data/third_party/cares/cares/ares_nowarn.h +2 -2
  265. data/third_party/cares/cares/ares_parse_naptr_reply.c +6 -1
  266. data/third_party/cares/cares/ares_private.h +11 -0
  267. data/third_party/cares/cares/ares_process.c +126 -37
  268. data/third_party/cares/cares/ares_version.h +2 -2
  269. data/third_party/cares/cares/ares_writev.c +2 -2
  270. data/third_party/cares/cares/config-win32.h +8 -34
  271. data/third_party/cares/cares/inet_net_pton.c +2 -2
  272. data/third_party/cares/cares/setup_once.h +5 -5
  273. data/third_party/cares/config_darwin/ares_config.h +98 -196
  274. data/third_party/cares/config_linux/ares_config.h +103 -203
  275. metadata +47 -20
  276. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +0 -1957
  277. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +0 -1182
@@ -37,7 +37,6 @@
37
37
  if (GRPC_TRACER_ON(grpc_inproc_trace)) gpr_log(__VA_ARGS__); \
38
38
  } while (0)
39
39
 
40
- static const grpc_transport_vtable inproc_vtable;
41
40
  static grpc_slice g_empty_slice;
42
41
  static grpc_slice g_fake_path_key;
43
42
  static grpc_slice g_fake_path_value;
@@ -120,7 +119,7 @@ static void slice_buffer_list_append_entry(slice_buffer_list *l,
120
119
  }
121
120
 
122
121
  static grpc_slice_buffer *slice_buffer_list_append(slice_buffer_list *l) {
123
- sb_list_entry *next = gpr_malloc(sizeof(*next));
122
+ sb_list_entry *next = (sb_list_entry *)gpr_malloc(sizeof(*next));
124
123
  grpc_slice_buffer_init(&next->sb);
125
124
  slice_buffer_list_append_entry(l, next);
126
125
  return &next->sb;
@@ -327,7 +326,8 @@ static grpc_error *fill_in_metadata(grpc_exec_ctx *exec_ctx, inproc_stream *s,
327
326
  grpc_error *error = GRPC_ERROR_NONE;
328
327
  for (grpc_linked_mdelem *elem = metadata->list.head;
329
328
  (elem != NULL) && (error == GRPC_ERROR_NONE); elem = elem->next) {
330
- grpc_linked_mdelem *nelem = gpr_arena_alloc(s->arena, sizeof(*nelem));
329
+ grpc_linked_mdelem *nelem =
330
+ (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*nelem));
331
331
  nelem->md = grpc_mdelem_from_slices(
332
332
  exec_ctx, grpc_slice_intern(GRPC_MDKEY(elem->md)),
333
333
  grpc_slice_intern(GRPC_MDVALUE(elem->md)));
@@ -531,12 +531,14 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
531
531
  // since it expects that as well as no error yet
532
532
  grpc_metadata_batch fake_md;
533
533
  grpc_metadata_batch_init(&fake_md);
534
- grpc_linked_mdelem *path_md = gpr_arena_alloc(s->arena, sizeof(*path_md));
534
+ grpc_linked_mdelem *path_md =
535
+ (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*path_md));
535
536
  path_md->md =
536
537
  grpc_mdelem_from_slices(exec_ctx, g_fake_path_key, g_fake_path_value);
537
538
  GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, path_md) ==
538
539
  GRPC_ERROR_NONE);
539
- grpc_linked_mdelem *auth_md = gpr_arena_alloc(s->arena, sizeof(*auth_md));
540
+ grpc_linked_mdelem *auth_md =
541
+ (grpc_linked_mdelem *)gpr_arena_alloc(s->arena, sizeof(*auth_md));
540
542
  auth_md->md =
541
543
  grpc_mdelem_from_slices(exec_ctx, g_fake_auth_key, g_fake_auth_value);
542
544
  GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, auth_md) ==
@@ -1163,6 +1165,55 @@ static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
1163
1165
  unref_transport(exec_ctx, t);
1164
1166
  }
1165
1167
 
1168
+ /*******************************************************************************
1169
+ * INTEGRATION GLUE
1170
+ */
1171
+
1172
+ static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
1173
+ grpc_stream *gs, grpc_pollset *pollset) {
1174
+ // Nothing to do here
1175
+ }
1176
+
1177
+ static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
1178
+ grpc_stream *gs, grpc_pollset_set *pollset_set) {
1179
+ // Nothing to do here
1180
+ }
1181
+
1182
+ static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
1183
+ return NULL;
1184
+ }
1185
+
1186
+ /*******************************************************************************
1187
+ * GLOBAL INIT AND DESTROY
1188
+ */
1189
+ static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
1190
+
1191
+ void grpc_inproc_transport_init(void) {
1192
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1193
+ GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL,
1194
+ grpc_schedule_on_exec_ctx);
1195
+ g_empty_slice = grpc_slice_from_static_buffer(NULL, 0);
1196
+
1197
+ grpc_slice key_tmp = grpc_slice_from_static_string(":path");
1198
+ g_fake_path_key = grpc_slice_intern(key_tmp);
1199
+ grpc_slice_unref_internal(&exec_ctx, key_tmp);
1200
+
1201
+ g_fake_path_value = grpc_slice_from_static_string("/");
1202
+
1203
+ grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
1204
+ g_fake_auth_key = grpc_slice_intern(auth_tmp);
1205
+ grpc_slice_unref_internal(&exec_ctx, auth_tmp);
1206
+
1207
+ g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
1208
+ grpc_exec_ctx_finish(&exec_ctx);
1209
+ }
1210
+
1211
+ static const grpc_transport_vtable inproc_vtable = {
1212
+ sizeof(inproc_stream), "inproc", init_stream,
1213
+ set_pollset, set_pollset_set, perform_stream_op,
1214
+ perform_transport_op, destroy_stream, destroy_transport,
1215
+ get_endpoint};
1216
+
1166
1217
  /*******************************************************************************
1167
1218
  * Main inproc transport functions
1168
1219
  */
@@ -1172,10 +1223,10 @@ static void inproc_transports_create(grpc_exec_ctx *exec_ctx,
1172
1223
  grpc_transport **client_transport,
1173
1224
  const grpc_channel_args *client_args) {
1174
1225
  INPROC_LOG(GPR_DEBUG, "inproc_transports_create");
1175
- inproc_transport *st = gpr_zalloc(sizeof(*st));
1176
- inproc_transport *ct = gpr_zalloc(sizeof(*ct));
1226
+ inproc_transport *st = (inproc_transport *)gpr_zalloc(sizeof(*st));
1227
+ inproc_transport *ct = (inproc_transport *)gpr_zalloc(sizeof(*ct));
1177
1228
  // Share one lock between both sides since both sides get affected
1178
- st->mu = ct->mu = gpr_malloc(sizeof(*st->mu));
1229
+ st->mu = ct->mu = (shared_mu *)gpr_malloc(sizeof(*st->mu));
1179
1230
  gpr_mu_init(&st->mu->mu);
1180
1231
  gpr_ref_init(&st->mu->refs, 2);
1181
1232
  st->base.vtable = &inproc_vtable;
@@ -1212,8 +1263,8 @@ grpc_channel *grpc_inproc_channel_create(grpc_server *server,
1212
1263
 
1213
1264
  grpc_arg default_authority_arg;
1214
1265
  default_authority_arg.type = GRPC_ARG_STRING;
1215
- default_authority_arg.key = GRPC_ARG_DEFAULT_AUTHORITY;
1216
- default_authority_arg.value.string = "inproc.authority";
1266
+ default_authority_arg.key = (char *)GRPC_ARG_DEFAULT_AUTHORITY;
1267
+ default_authority_arg.value.string = (char *)"inproc.authority";
1217
1268
  grpc_channel_args *client_args =
1218
1269
  grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
1219
1270
 
@@ -1237,61 +1288,6 @@ grpc_channel *grpc_inproc_channel_create(grpc_server *server,
1237
1288
  return channel;
1238
1289
  }
1239
1290
 
1240
- /*******************************************************************************
1241
- * INTEGRATION GLUE
1242
- */
1243
-
1244
- static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
1245
- grpc_stream *gs, grpc_pollset *pollset) {
1246
- // Nothing to do here
1247
- }
1248
-
1249
- static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
1250
- grpc_stream *gs, grpc_pollset_set *pollset_set) {
1251
- // Nothing to do here
1252
- }
1253
-
1254
- static char *get_peer(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
1255
- return gpr_strdup("inproc");
1256
- }
1257
-
1258
- static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
1259
- return NULL;
1260
- }
1261
-
1262
- static const grpc_transport_vtable inproc_vtable = {
1263
- sizeof(inproc_stream), "inproc",
1264
- init_stream, set_pollset,
1265
- set_pollset_set, perform_stream_op,
1266
- perform_transport_op, destroy_stream,
1267
- destroy_transport, get_peer,
1268
- get_endpoint};
1269
-
1270
- /*******************************************************************************
1271
- * GLOBAL INIT AND DESTROY
1272
- */
1273
- static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
1274
-
1275
- void grpc_inproc_transport_init(void) {
1276
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1277
- GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL,
1278
- grpc_schedule_on_exec_ctx);
1279
- g_empty_slice = grpc_slice_from_static_buffer(NULL, 0);
1280
-
1281
- grpc_slice key_tmp = grpc_slice_from_static_string(":path");
1282
- g_fake_path_key = grpc_slice_intern(key_tmp);
1283
- grpc_slice_unref_internal(&exec_ctx, key_tmp);
1284
-
1285
- g_fake_path_value = grpc_slice_from_static_string("/");
1286
-
1287
- grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
1288
- g_fake_auth_key = grpc_slice_intern(auth_tmp);
1289
- grpc_slice_unref_internal(&exec_ctx, auth_tmp);
1290
-
1291
- g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
1292
- grpc_exec_ctx_finish(&exec_ctx);
1293
- }
1294
-
1295
1291
  void grpc_inproc_transport_shutdown(void) {
1296
1292
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1297
1293
  grpc_slice_unref_internal(&exec_ctx, g_empty_slice);
@@ -86,13 +86,14 @@ grpc_channel_args *grpc_channel_args_copy_and_add_and_remove(
86
86
  }
87
87
  }
88
88
  // Create result.
89
- grpc_channel_args *dst = gpr_malloc(sizeof(grpc_channel_args));
89
+ grpc_channel_args *dst =
90
+ (grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
90
91
  dst->num_args = num_args_to_copy + num_to_add;
91
92
  if (dst->num_args == 0) {
92
93
  dst->args = NULL;
93
94
  return dst;
94
95
  }
95
- dst->args = gpr_malloc(sizeof(grpc_arg) * dst->num_args);
96
+ dst->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * dst->num_args);
96
97
  // Copy args from src that are not being removed.
97
98
  size_t dst_idx = 0;
98
99
  if (src != NULL) {
@@ -117,7 +118,7 @@ grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src) {
117
118
  grpc_channel_args *grpc_channel_args_union(const grpc_channel_args *a,
118
119
  const grpc_channel_args *b) {
119
120
  const size_t max_out = (a->num_args + b->num_args);
120
- grpc_arg *uniques = gpr_malloc(sizeof(*uniques) * max_out);
121
+ grpc_arg *uniques = (grpc_arg *)gpr_malloc(sizeof(*uniques) * max_out);
121
122
  for (size_t i = 0; i < a->num_args; ++i) uniques[i] = a->args[i];
122
123
 
123
124
  size_t uniques_idx = a->num_args;
@@ -160,24 +161,25 @@ static int cmp_arg(const grpc_arg *a, const grpc_arg *b) {
160
161
  /* stabilizing comparison function: since channel_args ordering matters for
161
162
  * keys with the same name, we need to preserve that ordering */
162
163
  static int cmp_key_stable(const void *ap, const void *bp) {
163
- const grpc_arg *const *a = ap;
164
- const grpc_arg *const *b = bp;
164
+ const grpc_arg *const *a = (const grpc_arg *const *)ap;
165
+ const grpc_arg *const *b = (const grpc_arg *const *)bp;
165
166
  int c = strcmp((*a)->key, (*b)->key);
166
167
  if (c == 0) c = GPR_ICMP(*a, *b);
167
168
  return c;
168
169
  }
169
170
 
170
171
  grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a) {
171
- grpc_arg **args = gpr_malloc(sizeof(grpc_arg *) * a->num_args);
172
+ grpc_arg **args = (grpc_arg **)gpr_malloc(sizeof(grpc_arg *) * a->num_args);
172
173
  for (size_t i = 0; i < a->num_args; i++) {
173
174
  args[i] = &a->args[i];
174
175
  }
175
176
  if (a->num_args > 1)
176
177
  qsort(args, a->num_args, sizeof(grpc_arg *), cmp_key_stable);
177
178
 
178
- grpc_channel_args *b = gpr_malloc(sizeof(grpc_channel_args));
179
+ grpc_channel_args *b =
180
+ (grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
179
181
  b->num_args = a->num_args;
180
- b->args = gpr_malloc(sizeof(grpc_arg) * b->num_args);
182
+ b->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * b->num_args);
181
183
  for (size_t i = 0; i < a->num_args; i++) {
182
184
  b->args[i] = copy_arg(args[i]);
183
185
  }
@@ -210,7 +212,7 @@ void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a) {
210
212
  grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
211
213
  const grpc_channel_args *a) {
212
214
  size_t i;
213
- if (a == NULL) return 0;
215
+ if (a == NULL) return GRPC_COMPRESS_NONE;
214
216
  for (i = 0; i < a->num_args; ++i) {
215
217
  if (a->args[i].type == GRPC_ARG_INTEGER &&
216
218
  !strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
@@ -221,12 +223,37 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
221
223
  return GRPC_COMPRESS_NONE;
222
224
  }
223
225
 
226
+ grpc_stream_compression_algorithm
227
+ grpc_channel_args_get_stream_compression_algorithm(const grpc_channel_args *a) {
228
+ size_t i;
229
+ if (a == NULL) return GRPC_STREAM_COMPRESS_NONE;
230
+ for (i = 0; i < a->num_args; ++i) {
231
+ if (a->args[i].type == GRPC_ARG_INTEGER &&
232
+ !strcmp(GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM,
233
+ a->args[i].key)) {
234
+ return (grpc_stream_compression_algorithm)a->args[i].value.integer;
235
+ break;
236
+ }
237
+ }
238
+ return GRPC_STREAM_COMPRESS_NONE;
239
+ }
240
+
224
241
  grpc_channel_args *grpc_channel_args_set_compression_algorithm(
225
242
  grpc_channel_args *a, grpc_compression_algorithm algorithm) {
226
243
  GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT);
227
244
  grpc_arg tmp;
228
245
  tmp.type = GRPC_ARG_INTEGER;
229
- tmp.key = GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
246
+ tmp.key = (char *)GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
247
+ tmp.value.integer = algorithm;
248
+ return grpc_channel_args_copy_and_add(a, &tmp, 1);
249
+ }
250
+
251
+ grpc_channel_args *grpc_channel_args_set_stream_compression_algorithm(
252
+ grpc_channel_args *a, grpc_stream_compression_algorithm algorithm) {
253
+ GPR_ASSERT(algorithm < GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT);
254
+ grpc_arg tmp;
255
+ tmp.type = GRPC_ARG_INTEGER;
256
+ tmp.key = (char *)GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
230
257
  tmp.value.integer = algorithm;
231
258
  return grpc_channel_args_copy_and_add(a, &tmp, 1);
232
259
  }
@@ -251,6 +278,26 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args *a,
251
278
  return 0; /* GPR_FALSE */
252
279
  }
253
280
 
281
+ /** Returns 1 if the argument for compression algorithm's enabled states bitset
282
+ * was found in \a a, returning the arg's value in \a states. Otherwise, returns
283
+ * 0. */
284
+ static int find_stream_compression_algorithm_states_bitset(
285
+ const grpc_channel_args *a, int **states_arg) {
286
+ if (a != NULL) {
287
+ size_t i;
288
+ for (i = 0; i < a->num_args; ++i) {
289
+ if (a->args[i].type == GRPC_ARG_INTEGER &&
290
+ !strcmp(GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
291
+ a->args[i].key)) {
292
+ *states_arg = &a->args[i].value.integer;
293
+ **states_arg |= 0x1; /* forcefully enable support for no compression */
294
+ return 1;
295
+ }
296
+ }
297
+ }
298
+ return 0; /* GPR_FALSE */
299
+ }
300
+
254
301
  grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
255
302
  grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
256
303
  grpc_compression_algorithm algorithm, int state) {
@@ -261,7 +308,7 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
261
308
 
262
309
  if (grpc_channel_args_get_compression_algorithm(*a) == algorithm &&
263
310
  state == 0) {
264
- char *algo_name = NULL;
311
+ const char *algo_name = NULL;
265
312
  GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0);
266
313
  gpr_log(GPR_ERROR,
267
314
  "Tried to disable default compression algorithm '%s'. The "
@@ -277,7 +324,7 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
277
324
  /* create a new arg */
278
325
  grpc_arg tmp;
279
326
  tmp.type = GRPC_ARG_INTEGER;
280
- tmp.key = GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
327
+ tmp.key = (char *)GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
281
328
  /* all enabled by default */
282
329
  tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
283
330
  if (state != 0) {
@@ -292,6 +339,48 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
292
339
  return result;
293
340
  }
294
341
 
342
+ grpc_channel_args *grpc_channel_args_stream_compression_algorithm_set_state(
343
+ grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
344
+ grpc_stream_compression_algorithm algorithm, int state) {
345
+ int *states_arg = NULL;
346
+ grpc_channel_args *result = *a;
347
+ const int states_arg_found =
348
+ find_stream_compression_algorithm_states_bitset(*a, &states_arg);
349
+
350
+ if (grpc_channel_args_get_stream_compression_algorithm(*a) == algorithm &&
351
+ state == 0) {
352
+ const char *algo_name = NULL;
353
+ GPR_ASSERT(grpc_stream_compression_algorithm_name(algorithm, &algo_name) !=
354
+ 0);
355
+ gpr_log(GPR_ERROR,
356
+ "Tried to disable default stream compression algorithm '%s'. The "
357
+ "operation has been ignored.",
358
+ algo_name);
359
+ } else if (states_arg_found) {
360
+ if (state != 0) {
361
+ GPR_BITSET((unsigned *)states_arg, algorithm);
362
+ } else if (algorithm != GRPC_STREAM_COMPRESS_NONE) {
363
+ GPR_BITCLEAR((unsigned *)states_arg, algorithm);
364
+ }
365
+ } else {
366
+ /* create a new arg */
367
+ grpc_arg tmp;
368
+ tmp.type = GRPC_ARG_INTEGER;
369
+ tmp.key = (char *)GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
370
+ /* all enabled by default */
371
+ tmp.value.integer = (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1;
372
+ if (state != 0) {
373
+ GPR_BITSET((unsigned *)&tmp.value.integer, algorithm);
374
+ } else if (algorithm != GRPC_STREAM_COMPRESS_NONE) {
375
+ GPR_BITCLEAR((unsigned *)&tmp.value.integer, algorithm);
376
+ }
377
+ result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
378
+ grpc_channel_args_destroy(exec_ctx, *a);
379
+ *a = result;
380
+ }
381
+ return result;
382
+ }
383
+
295
384
  uint32_t grpc_channel_args_compression_algorithm_get_states(
296
385
  const grpc_channel_args *a) {
297
386
  int *states_arg;
@@ -302,6 +391,17 @@ uint32_t grpc_channel_args_compression_algorithm_get_states(
302
391
  }
303
392
  }
304
393
 
394
+ uint32_t grpc_channel_args_stream_compression_algorithm_get_states(
395
+ const grpc_channel_args *a) {
396
+ int *states_arg;
397
+ if (find_stream_compression_algorithm_states_bitset(a, &states_arg)) {
398
+ return (uint32_t)*states_arg;
399
+ } else {
400
+ return (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) -
401
+ 1; /* All algs. enabled */
402
+ }
403
+ }
404
+
305
405
  grpc_channel_args *grpc_channel_args_set_socket_mutator(
306
406
  grpc_channel_args *a, grpc_socket_mutator *mutator) {
307
407
  grpc_arg tmp = grpc_socket_mutator_to_arg(mutator);
@@ -59,12 +59,24 @@ void grpc_channel_args_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_args *a);
59
59
  grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
60
60
  const grpc_channel_args *a);
61
61
 
62
+ /** Returns the stream compression algorithm set in \a a. */
63
+ grpc_stream_compression_algorithm
64
+ grpc_channel_args_get_stream_compression_algorithm(const grpc_channel_args *a);
65
+
62
66
  /** Returns a channel arg instance with compression enabled. If \a a is
63
67
  * non-NULL, its args are copied. N.B. GRPC_COMPRESS_NONE disables compression
64
68
  * for the channel. */
65
69
  grpc_channel_args *grpc_channel_args_set_compression_algorithm(
66
70
  grpc_channel_args *a, grpc_compression_algorithm algorithm);
67
71
 
72
+ /** Returns a channel arg instance with stream compression enabled. If \a a is
73
+ * non-NULL, its args are copied. N.B. GRPC_STREAM_COMPRESS_NONE disables
74
+ * stream compression for the channel. If a value other than
75
+ * GRPC_STREAM_COMPRESS_NONE is set, it takes precedence over message-wise
76
+ * compression algorithms. */
77
+ grpc_channel_args *grpc_channel_args_set_stream_compression_algorithm(
78
+ grpc_channel_args *a, grpc_stream_compression_algorithm algorithm);
79
+
68
80
  /** Sets the support for the given compression algorithm. By default, all
69
81
  * compression algorithms are enabled. It's an error to disable an algorithm set
70
82
  * by grpc_channel_args_set_compression_algorithm.
@@ -76,6 +88,17 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
76
88
  grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
77
89
  grpc_compression_algorithm algorithm, int enabled);
78
90
 
91
+ /** Sets the support for the given stream compression algorithm. By default, all
92
+ * stream compression algorithms are enabled. It's an error to disable an
93
+ * algorithm set by grpc_channel_args_set_stream_compression_algorithm.
94
+ *
95
+ * Returns an instance with the updated algorithm states. The \a a pointer is
96
+ * modified to point to the returned instance (which may be different from the
97
+ * input value of \a a). */
98
+ grpc_channel_args *grpc_channel_args_stream_compression_algorithm_set_state(
99
+ grpc_exec_ctx *exec_ctx, grpc_channel_args **a,
100
+ grpc_stream_compression_algorithm algorithm, int enabled);
101
+
79
102
  /** Returns the bitset representing the support state (true for enabled, false
80
103
  * for disabled) for compression algorithms.
81
104
  *
@@ -84,6 +107,14 @@ grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
84
107
  uint32_t grpc_channel_args_compression_algorithm_get_states(
85
108
  const grpc_channel_args *a);
86
109
 
110
+ /** Returns the bitset representing the support state (true for enabled, false
111
+ * for disabled) for stream compression algorithms.
112
+ *
113
+ * The i-th bit of the returned bitset corresponds to the i-th entry in the
114
+ * grpc_stream_compression_algorithm enum. */
115
+ uint32_t grpc_channel_args_stream_compression_algorithm_get_states(
116
+ const grpc_channel_args *a);
117
+
87
118
  int grpc_channel_args_compare(const grpc_channel_args *a,
88
119
  const grpc_channel_args *b);
89
120