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
@@ -39,7 +39,7 @@ static tracer *tracers;
39
39
  #endif
40
40
 
41
41
  void grpc_register_tracer(grpc_tracer_flag *flag) {
42
- tracer *t = gpr_malloc(sizeof(*t));
42
+ tracer *t = (tracer *)gpr_malloc(sizeof(*t));
43
43
  t->flag = flag;
44
44
  t->next = tracers;
45
45
  TRACER_SET(*flag, false);
@@ -53,10 +53,10 @@ static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
53
53
  size_t len;
54
54
  GPR_ASSERT(end >= beg);
55
55
  len = (size_t)(end - beg);
56
- s = gpr_malloc(len + 1);
56
+ s = (char *)gpr_malloc(len + 1);
57
57
  memcpy(s, beg, len);
58
58
  s[len] = 0;
59
- *ss = gpr_realloc(*ss, sizeof(char **) * np);
59
+ *ss = (char **)gpr_realloc(*ss, sizeof(char **) * np);
60
60
  (*ss)[n] = s;
61
61
  *ns = np;
62
62
  }
@@ -35,7 +35,7 @@ typedef struct {
35
35
  #else
36
36
  bool value;
37
37
  #endif
38
- char *name;
38
+ const char *name;
39
39
  } grpc_tracer_flag;
40
40
 
41
41
  #ifdef GRPC_THREADSAFE_TRACER
@@ -98,7 +98,7 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
98
98
  gpr_strvec_destroy(&out);
99
99
 
100
100
  if (body_bytes) {
101
- tmp = gpr_realloc(tmp, out_len + body_size);
101
+ tmp = (char *)gpr_realloc(tmp, out_len + body_size);
102
102
  memcpy(tmp + out_len, body_bytes, body_size);
103
103
  out_len += body_size;
104
104
  }
@@ -130,7 +130,7 @@ static void do_read(grpc_exec_ctx *exec_ctx, internal_request *req) {
130
130
 
131
131
  static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
132
132
  grpc_error *error) {
133
- internal_request *req = user_data;
133
+ internal_request *req = (internal_request *)user_data;
134
134
  size_t i;
135
135
 
136
136
  for (i = 0; i < req->incoming.count; i++) {
@@ -159,7 +159,7 @@ static void on_written(grpc_exec_ctx *exec_ctx, internal_request *req) {
159
159
  }
160
160
 
161
161
  static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
162
- internal_request *req = arg;
162
+ internal_request *req = (internal_request *)arg;
163
163
  if (error == GRPC_ERROR_NONE) {
164
164
  on_written(exec_ctx, req);
165
165
  } else {
@@ -175,7 +175,7 @@ static void start_write(grpc_exec_ctx *exec_ctx, internal_request *req) {
175
175
 
176
176
  static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
177
177
  grpc_endpoint *ep) {
178
- internal_request *req = arg;
178
+ internal_request *req = (internal_request *)arg;
179
179
 
180
180
  if (!ep) {
181
181
  next_address(exec_ctx, req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -189,7 +189,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
189
189
 
190
190
  static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
191
191
  grpc_error *error) {
192
- internal_request *req = arg;
192
+ internal_request *req = (internal_request *)arg;
193
193
 
194
194
  if (!req->ep) {
195
195
  next_address(exec_ctx, req, GRPC_ERROR_REF(error));
@@ -217,7 +217,7 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
217
217
  GRPC_CLOSURE_INIT(&req->connected, on_connected, req,
218
218
  grpc_schedule_on_exec_ctx);
219
219
  grpc_arg arg = grpc_channel_arg_pointer_create(
220
- GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
220
+ (char *)GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
221
221
  grpc_resource_quota_arg_vtable());
222
222
  grpc_channel_args args = {1, &arg};
223
223
  grpc_tcp_client_connect(exec_ctx, &req->connected, &req->ep,
@@ -226,7 +226,7 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
226
226
  }
227
227
 
228
228
  static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
229
- internal_request *req = arg;
229
+ internal_request *req = (internal_request *)arg;
230
230
  if (error != GRPC_ERROR_NONE) {
231
231
  finish(exec_ctx, req, GRPC_ERROR_REF(error));
232
232
  return;
@@ -243,7 +243,8 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx,
243
243
  gpr_timespec deadline, grpc_closure *on_done,
244
244
  grpc_httpcli_response *response,
245
245
  const char *name, grpc_slice request_text) {
246
- internal_request *req = gpr_malloc(sizeof(internal_request));
246
+ internal_request *req =
247
+ (internal_request *)gpr_malloc(sizeof(internal_request));
247
248
  memset(req, 0, sizeof(*req));
248
249
  req->request_text = request_text;
249
250
  grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);
@@ -43,7 +43,8 @@ static void httpcli_ssl_destroy(grpc_exec_ctx *exec_ctx,
43
43
  grpc_httpcli_ssl_channel_security_connector *c =
44
44
  (grpc_httpcli_ssl_channel_security_connector *)sc;
45
45
  if (c->handshaker_factory != NULL) {
46
- tsi_ssl_client_handshaker_factory_destroy(c->handshaker_factory);
46
+ tsi_ssl_client_handshaker_factory_unref(c->handshaker_factory);
47
+ c->handshaker_factory = NULL;
47
48
  }
48
49
  if (c->secure_peer_name != NULL) gpr_free(c->secure_peer_name);
49
50
  gpr_free(sc);
@@ -28,7 +28,7 @@
28
28
  grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false, "http1");
29
29
 
30
30
  static char *buf2str(void *buffer, size_t length) {
31
- char *out = gpr_malloc(length + 1);
31
+ char *out = (char *)gpr_malloc(length + 1);
32
32
  memcpy(out, buffer, length);
33
33
  out[length] = 0;
34
34
  return out;
@@ -197,7 +197,8 @@ static grpc_error *add_header(grpc_http_parser *parser) {
197
197
  if (*hdr_count == parser->hdr_capacity) {
198
198
  parser->hdr_capacity =
199
199
  GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
200
- *hdrs = gpr_realloc(*hdrs, parser->hdr_capacity * sizeof(**hdrs));
200
+ *hdrs = (grpc_http_header *)gpr_realloc(
201
+ *hdrs, parser->hdr_capacity * sizeof(**hdrs));
201
202
  }
202
203
  (*hdrs)[(*hdr_count)++] = hdr;
203
204
 
@@ -255,7 +256,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
255
256
 
256
257
  if (*body_length == parser->body_capacity) {
257
258
  parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
258
- *body = gpr_realloc((void *)*body, parser->body_capacity);
259
+ *body = (char *)gpr_realloc((void *)*body, parser->body_capacity);
259
260
  }
260
261
  (*body)[*body_length] = (char)byte;
261
262
  (*body_length)++;
@@ -0,0 +1,202 @@
1
+ /*
2
+ *
3
+ * Copyright 2017 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include "src/core/lib/iomgr/call_combiner.h"
20
+
21
+ #include <grpc/support/log.h>
22
+
23
+ grpc_tracer_flag grpc_call_combiner_trace =
24
+ GRPC_TRACER_INITIALIZER(false, "call_combiner");
25
+
26
+ static grpc_error* decode_cancel_state_error(gpr_atm cancel_state) {
27
+ if (cancel_state & 1) {
28
+ return (grpc_error*)(cancel_state & ~(gpr_atm)1);
29
+ }
30
+ return GRPC_ERROR_NONE;
31
+ }
32
+
33
+ static gpr_atm encode_cancel_state_error(grpc_error* error) {
34
+ return (gpr_atm)1 | (gpr_atm)error;
35
+ }
36
+
37
+ void grpc_call_combiner_init(grpc_call_combiner* call_combiner) {
38
+ gpr_mpscq_init(&call_combiner->queue);
39
+ }
40
+
41
+ void grpc_call_combiner_destroy(grpc_call_combiner* call_combiner) {
42
+ gpr_mpscq_destroy(&call_combiner->queue);
43
+ GRPC_ERROR_UNREF(decode_cancel_state_error(call_combiner->cancel_state));
44
+ }
45
+
46
+ #ifndef NDEBUG
47
+ #define DEBUG_ARGS , const char *file, int line
48
+ #define DEBUG_FMT_STR "%s:%d: "
49
+ #define DEBUG_FMT_ARGS , file, line
50
+ #else
51
+ #define DEBUG_ARGS
52
+ #define DEBUG_FMT_STR
53
+ #define DEBUG_FMT_ARGS
54
+ #endif
55
+
56
+ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
57
+ grpc_call_combiner* call_combiner,
58
+ grpc_closure* closure,
59
+ grpc_error* error DEBUG_ARGS,
60
+ const char* reason) {
61
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
62
+ gpr_log(GPR_DEBUG,
63
+ "==> grpc_call_combiner_start() [%p] closure=%p [" DEBUG_FMT_STR
64
+ "%s] error=%s",
65
+ call_combiner, closure DEBUG_FMT_ARGS, reason,
66
+ grpc_error_string(error));
67
+ }
68
+ size_t prev_size =
69
+ (size_t)gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)1);
70
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
71
+ gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
72
+ prev_size + 1);
73
+ }
74
+ if (prev_size == 0) {
75
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
76
+ gpr_log(GPR_DEBUG, " EXECUTING IMMEDIATELY");
77
+ }
78
+ // Queue was empty, so execute this closure immediately.
79
+ GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
80
+ } else {
81
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
82
+ gpr_log(GPR_INFO, " QUEUING");
83
+ }
84
+ // Queue was not empty, so add closure to queue.
85
+ closure->error_data.error = error;
86
+ gpr_mpscq_push(&call_combiner->queue, (gpr_mpscq_node*)closure);
87
+ }
88
+ }
89
+
90
+ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
91
+ grpc_call_combiner* call_combiner DEBUG_ARGS,
92
+ const char* reason) {
93
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
94
+ gpr_log(GPR_DEBUG,
95
+ "==> grpc_call_combiner_stop() [%p] [" DEBUG_FMT_STR "%s]",
96
+ call_combiner DEBUG_FMT_ARGS, reason);
97
+ }
98
+ size_t prev_size =
99
+ (size_t)gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)-1);
100
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
101
+ gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
102
+ prev_size - 1);
103
+ }
104
+ GPR_ASSERT(prev_size >= 1);
105
+ if (prev_size > 1) {
106
+ while (true) {
107
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
108
+ gpr_log(GPR_DEBUG, " checking queue");
109
+ }
110
+ bool empty;
111
+ grpc_closure* closure = (grpc_closure*)gpr_mpscq_pop_and_check_end(
112
+ &call_combiner->queue, &empty);
113
+ if (closure == NULL) {
114
+ // This can happen either due to a race condition within the mpscq
115
+ // code or because of a race with grpc_call_combiner_start().
116
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
117
+ gpr_log(GPR_DEBUG, " queue returned no result; checking again");
118
+ }
119
+ continue;
120
+ }
121
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
122
+ gpr_log(GPR_DEBUG, " EXECUTING FROM QUEUE: closure=%p error=%s",
123
+ closure, grpc_error_string(closure->error_data.error));
124
+ }
125
+ GRPC_CLOSURE_SCHED(exec_ctx, closure, closure->error_data.error);
126
+ break;
127
+ }
128
+ } else if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
129
+ gpr_log(GPR_DEBUG, " queue empty");
130
+ }
131
+ }
132
+
133
+ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
134
+ grpc_call_combiner* call_combiner,
135
+ grpc_closure* closure) {
136
+ while (true) {
137
+ // Decode original state.
138
+ gpr_atm original_state = gpr_atm_acq_load(&call_combiner->cancel_state);
139
+ grpc_error* original_error = decode_cancel_state_error(original_state);
140
+ // If error is set, invoke the cancellation closure immediately.
141
+ // Otherwise, store the new closure.
142
+ if (original_error != GRPC_ERROR_NONE) {
143
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
144
+ gpr_log(GPR_DEBUG,
145
+ "call_combiner=%p: scheduling notify_on_cancel callback=%p "
146
+ "for pre-existing cancellation",
147
+ call_combiner, closure);
148
+ }
149
+ GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_REF(original_error));
150
+ break;
151
+ } else {
152
+ if (gpr_atm_full_cas(&call_combiner->cancel_state, original_state,
153
+ (gpr_atm)closure)) {
154
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
155
+ gpr_log(GPR_DEBUG, "call_combiner=%p: setting notify_on_cancel=%p",
156
+ call_combiner, closure);
157
+ }
158
+ // If we replaced an earlier closure, invoke the original
159
+ // closure with GRPC_ERROR_NONE. This allows callers to clean
160
+ // up any resources they may be holding for the callback.
161
+ if (original_state != 0) {
162
+ closure = (grpc_closure*)original_state;
163
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
164
+ gpr_log(GPR_DEBUG,
165
+ "call_combiner=%p: scheduling old cancel callback=%p",
166
+ call_combiner, closure);
167
+ }
168
+ GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
169
+ }
170
+ break;
171
+ }
172
+ }
173
+ // cas failed, try again.
174
+ }
175
+ }
176
+
177
+ void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
178
+ grpc_call_combiner* call_combiner,
179
+ grpc_error* error) {
180
+ while (true) {
181
+ gpr_atm original_state = gpr_atm_acq_load(&call_combiner->cancel_state);
182
+ grpc_error* original_error = decode_cancel_state_error(original_state);
183
+ if (original_error != GRPC_ERROR_NONE) {
184
+ GRPC_ERROR_UNREF(error);
185
+ break;
186
+ }
187
+ if (gpr_atm_full_cas(&call_combiner->cancel_state, original_state,
188
+ encode_cancel_state_error(error))) {
189
+ if (original_state != 0) {
190
+ grpc_closure* notify_on_cancel = (grpc_closure*)original_state;
191
+ if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
192
+ gpr_log(GPR_DEBUG,
193
+ "call_combiner=%p: scheduling notify_on_cancel callback=%p",
194
+ call_combiner, notify_on_cancel);
195
+ }
196
+ GRPC_CLOSURE_SCHED(exec_ctx, notify_on_cancel, GRPC_ERROR_REF(error));
197
+ }
198
+ break;
199
+ }
200
+ // cas failed, try again.
201
+ }
202
+ }
@@ -0,0 +1,121 @@
1
+ /*
2
+ *
3
+ * Copyright 2017 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #ifndef GRPC_CORE_LIB_IOMGR_CALL_COMBINER_H
20
+ #define GRPC_CORE_LIB_IOMGR_CALL_COMBINER_H
21
+
22
+ #include <stddef.h>
23
+
24
+ #include <grpc/support/atm.h>
25
+
26
+ #include "src/core/lib/iomgr/closure.h"
27
+ #include "src/core/lib/iomgr/exec_ctx.h"
28
+ #include "src/core/lib/support/mpscq.h"
29
+
30
+ // A simple, lock-free mechanism for serializing activity related to a
31
+ // single call. This is similar to a combiner but is more lightweight.
32
+ //
33
+ // It requires the callback (or, in the common case where the callback
34
+ // actually kicks off a chain of callbacks, the last callback in that
35
+ // chain) to explicitly indicate (by calling GRPC_CALL_COMBINER_STOP())
36
+ // when it is done with the action that was kicked off by the original
37
+ // callback.
38
+
39
+ extern grpc_tracer_flag grpc_call_combiner_trace;
40
+
41
+ typedef struct {
42
+ gpr_atm size; // size_t, num closures in queue or currently executing
43
+ gpr_mpscq queue;
44
+ // Either 0 (if not cancelled and no cancellation closure set),
45
+ // a grpc_closure* (if the lowest bit is 0),
46
+ // or a grpc_error* (if the lowest bit is 1).
47
+ gpr_atm cancel_state;
48
+ } grpc_call_combiner;
49
+
50
+ // Assumes memory was initialized to zero.
51
+ void grpc_call_combiner_init(grpc_call_combiner* call_combiner);
52
+
53
+ void grpc_call_combiner_destroy(grpc_call_combiner* call_combiner);
54
+
55
+ #ifndef NDEBUG
56
+ #define GRPC_CALL_COMBINER_START(exec_ctx, call_combiner, closure, error, \
57
+ reason) \
58
+ grpc_call_combiner_start((exec_ctx), (call_combiner), (closure), (error), \
59
+ __FILE__, __LINE__, (reason))
60
+ #define GRPC_CALL_COMBINER_STOP(exec_ctx, call_combiner, reason) \
61
+ grpc_call_combiner_stop((exec_ctx), (call_combiner), __FILE__, __LINE__, \
62
+ (reason))
63
+ /// Starts processing \a closure on \a call_combiner.
64
+ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
65
+ grpc_call_combiner* call_combiner,
66
+ grpc_closure* closure, grpc_error* error,
67
+ const char* file, int line, const char* reason);
68
+ /// Yields the call combiner to the next closure in the queue, if any.
69
+ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
70
+ grpc_call_combiner* call_combiner,
71
+ const char* file, int line, const char* reason);
72
+ #else
73
+ #define GRPC_CALL_COMBINER_START(exec_ctx, call_combiner, closure, error, \
74
+ reason) \
75
+ grpc_call_combiner_start((exec_ctx), (call_combiner), (closure), (error), \
76
+ (reason))
77
+ #define GRPC_CALL_COMBINER_STOP(exec_ctx, call_combiner, reason) \
78
+ grpc_call_combiner_stop((exec_ctx), (call_combiner), (reason))
79
+ /// Starts processing \a closure on \a call_combiner.
80
+ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
81
+ grpc_call_combiner* call_combiner,
82
+ grpc_closure* closure, grpc_error* error,
83
+ const char* reason);
84
+ /// Yields the call combiner to the next closure in the queue, if any.
85
+ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
86
+ grpc_call_combiner* call_combiner,
87
+ const char* reason);
88
+ #endif
89
+
90
+ /// Registers \a closure to be invoked by \a call_combiner when
91
+ /// grpc_call_combiner_cancel() is called.
92
+ ///
93
+ /// Once a closure is registered, it will always be scheduled exactly
94
+ /// once; this allows the closure to hold references that will be freed
95
+ /// regardless of whether or not the call was cancelled. If a cancellation
96
+ /// does occur, the closure will be scheduled with the cancellation error;
97
+ /// otherwise, it will be scheduled with GRPC_ERROR_NONE.
98
+ ///
99
+ /// The closure will be scheduled in the following cases:
100
+ /// - If grpc_call_combiner_cancel() was called prior to registering the
101
+ /// closure, it will be scheduled immediately with the cancelation error.
102
+ /// - If grpc_call_combiner_cancel() is called after registering the
103
+ /// closure, the closure will be scheduled with the cancellation error.
104
+ /// - If grpc_call_combiner_set_notify_on_cancel() is called again to
105
+ /// register a new cancellation closure, the previous cancellation
106
+ /// closure will be scheduled with GRPC_ERROR_NONE.
107
+ ///
108
+ /// If \a closure is NULL, then no closure will be invoked on
109
+ /// cancellation; this effectively unregisters the previously set closure.
110
+ /// However, most filters will not need to explicitly unregister their
111
+ /// callbacks, as this is done automatically when the call is destroyed.
112
+ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
113
+ grpc_call_combiner* call_combiner,
114
+ grpc_closure* closure);
115
+
116
+ /// Indicates that the call has been cancelled.
117
+ void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
118
+ grpc_call_combiner* call_combiner,
119
+ grpc_error* error);
120
+
121
+ #endif /* GRPC_CORE_LIB_IOMGR_CALL_COMBINER_H */