grpc 1.3.4 → 1.4.0

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 (286) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +581 -450
  3. data/include/grpc/census.h +49 -49
  4. data/include/grpc/grpc.h +16 -70
  5. data/include/grpc/grpc_security.h +59 -59
  6. data/include/grpc/grpc_security_constants.h +9 -9
  7. data/include/grpc/impl/codegen/atm.h +1 -1
  8. data/include/grpc/impl/codegen/atm_windows.h +4 -4
  9. data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
  10. data/include/grpc/impl/codegen/compression_types.h +4 -5
  11. data/include/grpc/impl/codegen/gpr_slice.h +5 -5
  12. data/include/grpc/impl/codegen/gpr_types.h +6 -7
  13. data/include/grpc/impl/codegen/grpc_types.h +128 -59
  14. data/include/grpc/impl/codegen/port_platform.h +6 -0
  15. data/include/grpc/impl/codegen/propagation_bits.h +2 -2
  16. data/include/grpc/impl/codegen/slice.h +13 -12
  17. data/include/grpc/impl/codegen/status.h +23 -18
  18. data/include/grpc/impl/codegen/sync.h +1 -1
  19. data/include/grpc/load_reporting.h +6 -6
  20. data/include/grpc/slice.h +47 -25
  21. data/include/grpc/slice_buffer.h +18 -14
  22. data/include/grpc/support/alloc.h +7 -7
  23. data/include/grpc/support/cmdline.h +10 -10
  24. data/include/grpc/support/cpu.h +3 -3
  25. data/include/grpc/support/histogram.h +1 -1
  26. data/include/grpc/support/host_port.h +2 -2
  27. data/include/grpc/support/log.h +9 -9
  28. data/include/grpc/support/log_windows.h +1 -1
  29. data/include/grpc/support/string_util.h +3 -3
  30. data/include/grpc/support/subprocess.h +3 -3
  31. data/include/grpc/support/sync.h +31 -31
  32. data/include/grpc/support/thd.h +11 -11
  33. data/include/grpc/support/time.h +12 -12
  34. data/include/grpc/support/tls.h +1 -1
  35. data/include/grpc/support/tls_gcc.h +2 -2
  36. data/include/grpc/support/tls_msvc.h +1 -1
  37. data/include/grpc/support/tls_pthread.h +1 -1
  38. data/include/grpc/support/useful.h +2 -2
  39. data/include/grpc/support/workaround_list.h +46 -0
  40. data/src/core/ext/census/context.c +1 -1
  41. data/src/core/ext/census/intrusive_hash_map.c +319 -0
  42. data/src/core/ext/census/intrusive_hash_map.h +167 -0
  43. data/src/core/ext/census/intrusive_hash_map_internal.h +63 -0
  44. data/src/core/ext/census/resource.c +3 -1
  45. data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
  46. data/src/core/ext/filters/client_channel/client_channel.c +173 -103
  47. data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
  48. data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
  49. data/src/core/ext/filters/client_channel/lb_policy.h +8 -7
  50. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
  51. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
  52. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +405 -102
  53. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
  54. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
  55. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +90 -51
  56. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +7 -1
  57. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
  58. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
  59. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
  60. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +188 -294
  61. data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
  62. data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
  63. data/src/core/ext/filters/client_channel/parse_address.c +90 -59
  64. data/src/core/ext/filters/client_channel/parse_address.h +17 -8
  65. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +11 -7
  66. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +59 -14
  67. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +6 -0
  68. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
  69. data/src/core/ext/filters/client_channel/subchannel.c +20 -17
  70. data/src/core/ext/filters/client_channel/subchannel.h +1 -0
  71. data/src/core/ext/filters/client_channel/subchannel_index.c +11 -1
  72. data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
  73. data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
  74. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
  75. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
  76. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
  77. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
  78. data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
  79. data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
  80. data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
  81. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
  82. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
  83. data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
  84. data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
  85. data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
  86. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
  87. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
  88. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +223 -0
  89. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +40 -0
  90. data/src/core/ext/filters/workarounds/workaround_utils.c +65 -0
  91. data/src/core/ext/filters/workarounds/workaround_utils.h +52 -0
  92. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  93. data/src/core/ext/transport/chttp2/server/chttp2_server.c +3 -2
  94. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
  95. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
  96. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +319 -175
  97. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
  98. data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
  99. data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
  100. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
  101. data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
  102. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  103. data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
  104. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
  105. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
  106. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
  107. data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
  108. data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
  109. data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
  110. data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
  111. data/src/core/lib/channel/channel_args.c +30 -9
  112. data/src/core/lib/channel/channel_args.h +5 -1
  113. data/src/core/lib/channel/channel_stack.c +1 -1
  114. data/src/core/lib/channel/channel_stack.h +2 -2
  115. data/src/core/lib/channel/channel_stack_builder.c +13 -1
  116. data/src/core/lib/channel/channel_stack_builder.h +5 -1
  117. data/src/core/lib/channel/connected_channel.c +3 -1
  118. data/src/core/lib/channel/context.h +2 -2
  119. data/src/core/lib/compression/message_compress.c +2 -2
  120. data/src/core/lib/debug/trace.c +13 -6
  121. data/src/core/lib/debug/trace.h +27 -1
  122. data/src/core/lib/http/httpcli.c +1 -1
  123. data/src/core/lib/http/httpcli_security_connector.c +9 -11
  124. data/src/core/lib/http/parser.c +2 -2
  125. data/src/core/lib/http/parser.h +2 -1
  126. data/src/core/lib/iomgr/combiner.c +6 -6
  127. data/src/core/lib/iomgr/combiner.h +2 -1
  128. data/src/core/lib/iomgr/error.c +12 -5
  129. data/src/core/lib/iomgr/error.h +13 -13
  130. data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
  131. data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
  132. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
  133. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
  134. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
  135. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
  136. data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
  137. data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
  138. data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +41 -33
  139. data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
  140. data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
  141. data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
  142. data/src/core/lib/iomgr/ev_posix.c +22 -8
  143. data/src/core/lib/iomgr/ev_posix.h +4 -3
  144. data/src/core/lib/iomgr/ev_windows.c +43 -0
  145. data/src/core/lib/iomgr/exec_ctx.c +5 -0
  146. data/src/core/lib/iomgr/exec_ctx.h +2 -0
  147. data/src/core/lib/iomgr/iomgr.c +4 -0
  148. data/src/core/lib/iomgr/iomgr.h +3 -0
  149. data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
  150. data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
  151. data/src/core/lib/iomgr/lockfree_event.c +16 -0
  152. data/src/core/lib/iomgr/pollset.h +2 -5
  153. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  154. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  155. data/src/core/lib/iomgr/resource_quota.c +9 -8
  156. data/src/core/lib/iomgr/resource_quota.h +2 -1
  157. data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
  158. data/src/core/lib/iomgr/socket_mutator.h +2 -0
  159. data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
  160. data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
  161. data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
  162. data/src/core/lib/iomgr/tcp_posix.c +7 -7
  163. data/src/core/lib/iomgr/tcp_posix.h +2 -1
  164. data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
  165. data/src/core/lib/iomgr/tcp_uv.c +6 -6
  166. data/src/core/lib/iomgr/tcp_uv.h +2 -1
  167. data/src/core/lib/iomgr/tcp_windows.c +1 -1
  168. data/src/core/lib/iomgr/timer_generic.c +24 -25
  169. data/src/core/lib/iomgr/timer_manager.c +276 -0
  170. data/src/core/lib/iomgr/timer_manager.h +52 -0
  171. data/src/core/lib/iomgr/timer_uv.c +6 -0
  172. data/src/core/lib/iomgr/udp_server.c +42 -9
  173. data/src/core/lib/iomgr/udp_server.h +3 -1
  174. data/src/core/lib/security/credentials/credentials.c +0 -1
  175. data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
  176. data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
  177. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
  178. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
  179. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
  180. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
  181. data/src/core/lib/security/transport/client_auth_filter.c +9 -3
  182. data/src/core/lib/security/transport/secure_endpoint.c +7 -7
  183. data/src/core/lib/security/transport/secure_endpoint.h +1 -1
  184. data/src/core/lib/security/transport/security_connector.c +45 -57
  185. data/src/core/lib/security/transport/security_connector.h +10 -14
  186. data/src/core/lib/security/transport/security_handshaker.c +123 -97
  187. data/src/core/lib/slice/b64.c +1 -1
  188. data/src/core/lib/slice/percent_encoding.c +3 -3
  189. data/src/core/lib/slice/slice.c +66 -33
  190. data/src/core/lib/slice/slice_buffer.c +25 -6
  191. data/src/core/lib/slice/slice_hash_table.c +33 -35
  192. data/src/core/lib/slice/slice_hash_table.h +7 -12
  193. data/src/core/lib/support/atomic.h +45 -0
  194. data/src/core/lib/support/atomic_with_atm.h +70 -0
  195. data/src/core/lib/support/atomic_with_std.h +48 -0
  196. data/src/core/lib/support/avl.c +14 -14
  197. data/src/core/lib/support/cmdline.c +3 -3
  198. data/src/core/lib/support/histogram.c +2 -2
  199. data/src/core/lib/support/host_port.c +1 -1
  200. data/src/core/lib/support/memory.h +74 -0
  201. data/src/core/lib/support/mpscq.c +36 -2
  202. data/src/core/lib/support/mpscq.h +28 -1
  203. data/src/core/lib/support/stack_lockfree.c +3 -36
  204. data/src/core/lib/support/string.c +12 -12
  205. data/src/core/lib/support/string_posix.c +1 -1
  206. data/src/core/lib/support/subprocess_posix.c +2 -2
  207. data/src/core/lib/support/thd_posix.c +1 -1
  208. data/src/core/lib/support/time_posix.c +8 -0
  209. data/src/core/lib/support/tmpfile_posix.c +10 -10
  210. data/src/core/lib/surface/alarm.c +3 -1
  211. data/src/core/lib/surface/api_trace.c +2 -1
  212. data/src/core/lib/surface/api_trace.h +2 -2
  213. data/src/core/lib/surface/byte_buffer_reader.c +1 -1
  214. data/src/core/lib/surface/call.c +65 -22
  215. data/src/core/lib/surface/call.h +4 -2
  216. data/src/core/lib/surface/channel_init.c +2 -19
  217. data/src/core/lib/surface/channel_stack_type.c +18 -0
  218. data/src/core/lib/surface/channel_stack_type.h +2 -0
  219. data/src/core/lib/surface/completion_queue.c +694 -247
  220. data/src/core/lib/surface/completion_queue.h +30 -13
  221. data/src/core/lib/surface/completion_queue_factory.c +24 -9
  222. data/src/core/lib/surface/init.c +1 -52
  223. data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
  224. data/src/core/lib/surface/server.c +79 -110
  225. data/src/core/lib/surface/server.h +2 -1
  226. data/src/core/lib/surface/version.c +2 -2
  227. data/src/core/lib/transport/bdp_estimator.c +25 -9
  228. data/src/core/lib/transport/bdp_estimator.h +7 -1
  229. data/src/core/lib/transport/byte_stream.c +23 -9
  230. data/src/core/lib/transport/byte_stream.h +15 -6
  231. data/src/core/lib/transport/connectivity_state.c +6 -6
  232. data/src/core/lib/transport/connectivity_state.h +2 -1
  233. data/src/core/lib/transport/service_config.c +6 -13
  234. data/src/core/lib/transport/service_config.h +2 -2
  235. data/src/core/lib/transport/static_metadata.c +403 -389
  236. data/src/core/lib/transport/static_metadata.h +127 -114
  237. data/src/core/plugin_registry/grpc_plugin_registry.c +16 -0
  238. data/src/core/tsi/fake_transport_security.c +5 -4
  239. data/src/core/tsi/ssl_transport_security.c +71 -82
  240. data/src/core/tsi/ssl_transport_security.h +39 -61
  241. data/src/core/tsi/transport_security.c +83 -2
  242. data/src/core/tsi/transport_security.h +27 -2
  243. data/src/core/tsi/transport_security_adapter.c +236 -0
  244. data/src/core/tsi/transport_security_adapter.h +62 -0
  245. data/src/core/tsi/transport_security_interface.h +179 -66
  246. data/src/ruby/ext/grpc/extconf.rb +2 -1
  247. data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
  248. data/src/ruby/ext/grpc/rb_call.c +56 -48
  249. data/src/ruby/ext/grpc/rb_call.h +3 -4
  250. data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
  251. data/src/ruby/ext/grpc/rb_channel.c +2 -3
  252. data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
  253. data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
  254. data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
  255. data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
  256. data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
  257. data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
  258. data/src/ruby/ext/grpc/rb_grpc.c +11 -15
  259. data/src/ruby/ext/grpc/rb_grpc.h +2 -2
  260. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -6
  261. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +25 -10
  262. data/src/ruby/ext/grpc/rb_server.c +26 -28
  263. data/src/ruby/lib/grpc/grpc.rb +1 -1
  264. data/src/ruby/lib/grpc/version.rb +1 -1
  265. data/third_party/cares/config_linux/ares_config.h +36 -2
  266. data/third_party/zlib/adler32.c +14 -7
  267. data/third_party/zlib/compress.c +24 -18
  268. data/third_party/zlib/crc32.c +29 -12
  269. data/third_party/zlib/deflate.c +499 -303
  270. data/third_party/zlib/deflate.h +19 -16
  271. data/third_party/zlib/gzguts.h +16 -7
  272. data/third_party/zlib/gzlib.c +17 -14
  273. data/third_party/zlib/gzread.c +108 -48
  274. data/third_party/zlib/gzwrite.c +210 -122
  275. data/third_party/zlib/infback.c +2 -2
  276. data/third_party/zlib/inffast.c +34 -51
  277. data/third_party/zlib/inflate.c +86 -37
  278. data/third_party/zlib/inflate.h +7 -4
  279. data/third_party/zlib/inftrees.c +12 -14
  280. data/third_party/zlib/trees.c +38 -61
  281. data/third_party/zlib/uncompr.c +66 -32
  282. data/third_party/zlib/zconf.h +32 -9
  283. data/third_party/zlib/zlib.h +298 -154
  284. data/third_party/zlib/zutil.c +25 -24
  285. data/third_party/zlib/zutil.h +35 -17
  286. metadata +63 -30
@@ -43,11 +43,11 @@
43
43
  extern "C" {
44
44
  #endif
45
45
 
46
- /* Time constants. */
46
+ /** Time constants. */
47
47
  GPRAPI gpr_timespec
48
- gpr_time_0(gpr_clock_type type); /* The zero time interval. */
49
- GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type); /* The far future */
50
- GPRAPI gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */
48
+ gpr_time_0(gpr_clock_type type); /** The zero time interval. */
49
+ GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type); /** The far future */
50
+ GPRAPI gpr_timespec gpr_inf_past(gpr_clock_type type); /** The far past. */
51
51
 
52
52
  #define GPR_MS_PER_SEC 1000
53
53
  #define GPR_US_PER_SEC 1000000
@@ -56,28 +56,28 @@ GPRAPI gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */
56
56
  #define GPR_NS_PER_US 1000
57
57
  #define GPR_US_PER_MS 1000
58
58
 
59
- /* initialize time subsystem */
59
+ /** initialize time subsystem */
60
60
  GPRAPI void gpr_time_init(void);
61
61
 
62
- /* Return the current time measured from the given clocks epoch. */
62
+ /** Return the current time measured from the given clocks epoch. */
63
63
  GPRAPI gpr_timespec gpr_now(gpr_clock_type clock);
64
64
 
65
- /* Convert a timespec from one clock to another */
65
+ /** Convert a timespec from one clock to another */
66
66
  GPRAPI gpr_timespec gpr_convert_clock_type(gpr_timespec t,
67
67
  gpr_clock_type target_clock);
68
68
 
69
- /* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
69
+ /** Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
70
70
  respectively. */
71
71
  GPRAPI int gpr_time_cmp(gpr_timespec a, gpr_timespec b);
72
72
 
73
73
  GPRAPI gpr_timespec gpr_time_max(gpr_timespec a, gpr_timespec b);
74
74
  GPRAPI gpr_timespec gpr_time_min(gpr_timespec a, gpr_timespec b);
75
75
 
76
- /* Add and subtract times. Calculations saturate at infinities. */
76
+ /** Add and subtract times. Calculations saturate at infinities. */
77
77
  GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b);
78
78
  GPRAPI gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b);
79
79
 
80
- /* Return a timespec representing a given number of time units. INT64_MIN is
80
+ /** Return a timespec representing a given number of time units. INT64_MIN is
81
81
  interpreted as gpr_inf_past, and INT64_MAX as gpr_inf_future. */
82
82
  GPRAPI gpr_timespec gpr_time_from_micros(int64_t x, gpr_clock_type clock_type);
83
83
  GPRAPI gpr_timespec gpr_time_from_nanos(int64_t x, gpr_clock_type clock_type);
@@ -88,12 +88,12 @@ GPRAPI gpr_timespec gpr_time_from_hours(int64_t x, gpr_clock_type clock_type);
88
88
 
89
89
  GPRAPI int32_t gpr_time_to_millis(gpr_timespec timespec);
90
90
 
91
- /* Return 1 if two times are equal or within threshold of each other,
91
+ /** Return 1 if two times are equal or within threshold of each other,
92
92
  0 otherwise */
93
93
  GPRAPI int gpr_time_similar(gpr_timespec a, gpr_timespec b,
94
94
  gpr_timespec threshold);
95
95
 
96
- /* Sleep until at least 'until' - an absolute timeout */
96
+ /** Sleep until at least 'until' - an absolute timeout */
97
97
  GPRAPI void gpr_sleep_until(gpr_timespec until);
98
98
 
99
99
  GPRAPI double gpr_timespec_to_micros(gpr_timespec t);
@@ -36,7 +36,7 @@
36
36
 
37
37
  #include <grpc/support/port_platform.h>
38
38
 
39
- /* Thread local storage.
39
+ /** Thread local storage.
40
40
 
41
41
  A minimal wrapper that should be implementable across many compilers,
42
42
  and implementable efficiently across most modern compilers.
@@ -38,7 +38,7 @@
38
38
 
39
39
  #include <grpc/support/log.h>
40
40
 
41
- /* Thread local storage based on gcc compiler primitives.
41
+ /** Thread local storage based on gcc compiler primitives.
42
42
  #include tls.h to use this - and see that file for documentation */
43
43
 
44
44
  #ifndef NDEBUG
@@ -58,7 +58,7 @@ struct gpr_gcc_thread_local {
58
58
  *((tls)->inited) = true; \
59
59
  } while (0)
60
60
 
61
- /* It is allowed to call gpr_tls_init after gpr_tls_destroy is called. */
61
+ /** It is allowed to call gpr_tls_init after gpr_tls_destroy is called. */
62
62
  #define gpr_tls_destroy(tls) \
63
63
  do { \
64
64
  GPR_ASSERT(*((tls)->inited)); \
@@ -34,7 +34,7 @@
34
34
  #ifndef GRPC_SUPPORT_TLS_MSVC_H
35
35
  #define GRPC_SUPPORT_TLS_MSVC_H
36
36
 
37
- /* Thread local storage based on ms visual c compiler primitives.
37
+ /** Thread local storage based on ms visual c compiler primitives.
38
38
  #include tls.h to use this - and see that file for documentation */
39
39
 
40
40
  struct gpr_msvc_thread_local {
@@ -37,7 +37,7 @@
37
37
  #include <grpc/support/log.h> /* for GPR_ASSERT */
38
38
  #include <pthread.h>
39
39
 
40
- /* Thread local storage based on pthread library calls.
40
+ /** Thread local storage based on pthread library calls.
41
41
  #include tls.h to use this - and see that file for documentation */
42
42
 
43
43
  struct gpr_pthread_thread_local {
@@ -34,12 +34,12 @@
34
34
  #ifndef GRPC_SUPPORT_USEFUL_H
35
35
  #define GRPC_SUPPORT_USEFUL_H
36
36
 
37
- /* useful macros that don't belong anywhere else */
37
+ /** useful macros that don't belong anywhere else */
38
38
 
39
39
  #define GPR_MIN(a, b) ((a) < (b) ? (a) : (b))
40
40
  #define GPR_MAX(a, b) ((a) > (b) ? (a) : (b))
41
41
  #define GPR_CLAMP(a, min, max) ((a) < (min) ? (min) : (a) > (max) ? (max) : (a))
42
- /* rotl, rotr assume x is unsigned */
42
+ /** rotl, rotr assume x is unsigned */
43
43
  #define GPR_ROTL(x, n) (((x) << (n)) | ((x) >> (sizeof(x) * 8 - (n))))
44
44
  #define GPR_ROTR(x, n) (((x) >> (n)) | ((x) << (sizeof(x) * 8 - (n))))
45
45
 
@@ -0,0 +1,46 @@
1
+ /*
2
+ *
3
+ * Copyright 2015, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_SUPPORT_WORKAROUND_LIST_H
35
+ #define GRPC_SUPPORT_WORKAROUND_LIST_H
36
+
37
+ /* The list of IDs of server workarounds currently maintained by gRPC. For
38
+ * explanation and detailed descriptions of workarounds, see
39
+ * /doc/workarounds.md
40
+ */
41
+ typedef enum {
42
+ GRPC_WORKAROUND_ID_CRONET_COMPRESSION = 0,
43
+ GRPC_MAX_WORKAROUND_ID
44
+ } grpc_workaround_list;
45
+
46
+ #endif
@@ -200,7 +200,7 @@ static bool tag_set_add_tag(struct tag_set *tags, const census_tag *tag,
200
200
  // allocate new memory if needed
201
201
  tags->kvm_size += 2 * CENSUS_MAX_TAG_KV_LEN + TAG_HEADER_SIZE;
202
202
  char *new_kvm = gpr_malloc(tags->kvm_size);
203
- memcpy(new_kvm, tags->kvm, tags->kvm_used);
203
+ if (tags->kvm_used > 0) memcpy(new_kvm, tags->kvm, tags->kvm_used);
204
204
  gpr_free(tags->kvm);
205
205
  tags->kvm = new_kvm;
206
206
  }
@@ -0,0 +1,319 @@
1
+ /*
2
+ *
3
+ * Copyright 2017, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #include "src/core/ext/census/intrusive_hash_map.h"
35
+ #include <string.h>
36
+
37
+ extern bool hm_index_compare(const hm_index *A, const hm_index *B);
38
+
39
+ /* Simple hashing function that takes lower 32 bits. */
40
+ static inline uint32_t chunked_vector_hasher(uint64_t key) {
41
+ return (uint32_t)key;
42
+ }
43
+
44
+ /* Vector chunks are 1MiB divided by pointer size. */
45
+ static const size_t VECTOR_CHUNK_SIZE = (1 << 20) / sizeof(void *);
46
+
47
+ /* Helper functions which return buckets from the chunked vector. */
48
+ static inline void **get_mutable_bucket(const chunked_vector *buckets,
49
+ uint32_t index) {
50
+ if (index < VECTOR_CHUNK_SIZE) {
51
+ return &buckets->first_[index];
52
+ }
53
+ size_t rest_index = (index - VECTOR_CHUNK_SIZE) / VECTOR_CHUNK_SIZE;
54
+ return &buckets->rest_[rest_index][index % VECTOR_CHUNK_SIZE];
55
+ }
56
+
57
+ static inline void *get_bucket(const chunked_vector *buckets, uint32_t index) {
58
+ if (index < VECTOR_CHUNK_SIZE) {
59
+ return buckets->first_[index];
60
+ }
61
+ size_t rest_index = (index - VECTOR_CHUNK_SIZE) / VECTOR_CHUNK_SIZE;
62
+ return buckets->rest_[rest_index][index % VECTOR_CHUNK_SIZE];
63
+ }
64
+
65
+ /* Helper function. */
66
+ static inline size_t RestSize(const chunked_vector *vec) {
67
+ return (vec->size_ <= VECTOR_CHUNK_SIZE)
68
+ ? 0
69
+ : (vec->size_ - VECTOR_CHUNK_SIZE - 1) / VECTOR_CHUNK_SIZE + 1;
70
+ }
71
+
72
+ /* Initialize chunked vector to size of 0. */
73
+ static void chunked_vector_init(chunked_vector *vec) {
74
+ vec->size_ = 0;
75
+ vec->first_ = NULL;
76
+ vec->rest_ = NULL;
77
+ }
78
+
79
+ /* Clear chunked vector and free all memory that has been allocated then
80
+ initialize chunked vector. */
81
+ static void chunked_vector_clear(chunked_vector *vec) {
82
+ if (vec->first_ != NULL) {
83
+ gpr_free(vec->first_);
84
+ }
85
+ if (vec->rest_ != NULL) {
86
+ size_t rest_size = RestSize(vec);
87
+ for (size_t i = 0; i < rest_size; ++i) {
88
+ if (vec->rest_[i] != NULL) {
89
+ gpr_free(vec->rest_[i]);
90
+ }
91
+ }
92
+ gpr_free(vec->rest_);
93
+ }
94
+ chunked_vector_init(vec);
95
+ }
96
+
97
+ /* Clear chunked vector and then resize it to n entries. Allow the first 1MB to
98
+ be read w/o an extra cache miss. The rest of the elements are stored in an
99
+ array of arrays to avoid large mallocs. */
100
+ static void chunked_vector_reset(chunked_vector *vec, size_t n) {
101
+ chunked_vector_clear(vec);
102
+ vec->size_ = n;
103
+ if (n <= VECTOR_CHUNK_SIZE) {
104
+ vec->first_ = (void **)gpr_malloc(sizeof(void *) * n);
105
+ memset(vec->first_, 0, sizeof(void *) * n);
106
+ } else {
107
+ vec->first_ = (void **)gpr_malloc(sizeof(void *) * VECTOR_CHUNK_SIZE);
108
+ memset(vec->first_, 0, sizeof(void *) * VECTOR_CHUNK_SIZE);
109
+ size_t rest_size = RestSize(vec);
110
+ vec->rest_ = (void ***)gpr_malloc(sizeof(void **) * rest_size);
111
+ memset(vec->rest_, 0, sizeof(void **) * rest_size);
112
+ int i = 0;
113
+ n -= VECTOR_CHUNK_SIZE;
114
+ while (n > 0) {
115
+ size_t this_size = GPR_MIN(n, VECTOR_CHUNK_SIZE);
116
+ vec->rest_[i] = (void **)gpr_malloc(sizeof(void *) * this_size);
117
+ memset(vec->rest_[i], 0, sizeof(void *) * this_size);
118
+ n -= this_size;
119
+ ++i;
120
+ }
121
+ }
122
+ }
123
+
124
+ void intrusive_hash_map_init(intrusive_hash_map *hash_map,
125
+ uint32_t initial_log2_table_size) {
126
+ hash_map->log2_num_buckets = initial_log2_table_size;
127
+ hash_map->num_items = 0;
128
+ uint32_t num_buckets = (uint32_t)1 << hash_map->log2_num_buckets;
129
+ hash_map->extend_threshold = num_buckets >> 1;
130
+ chunked_vector_init(&hash_map->buckets);
131
+ chunked_vector_reset(&hash_map->buckets, num_buckets);
132
+ hash_map->hash_mask = num_buckets - 1;
133
+ }
134
+
135
+ bool intrusive_hash_map_empty(const intrusive_hash_map *hash_map) {
136
+ return hash_map->num_items == 0;
137
+ }
138
+
139
+ size_t intrusive_hash_map_size(const intrusive_hash_map *hash_map) {
140
+ return hash_map->num_items;
141
+ }
142
+
143
+ void intrusive_hash_map_end(const intrusive_hash_map *hash_map, hm_index *idx) {
144
+ idx->bucket_index = (uint32_t)hash_map->buckets.size_;
145
+ GPR_ASSERT(idx->bucket_index <= UINT32_MAX);
146
+ idx->item = NULL;
147
+ }
148
+
149
+ void intrusive_hash_map_next(const intrusive_hash_map *hash_map,
150
+ hm_index *idx) {
151
+ idx->item = idx->item->hash_link;
152
+ while (idx->item == NULL) {
153
+ idx->bucket_index++;
154
+ if (idx->bucket_index >= hash_map->buckets.size_) {
155
+ /* Reached end of table. */
156
+ idx->item = NULL;
157
+ return;
158
+ }
159
+ idx->item = (hm_item *)get_bucket(&hash_map->buckets, idx->bucket_index);
160
+ }
161
+ }
162
+
163
+ void intrusive_hash_map_begin(const intrusive_hash_map *hash_map,
164
+ hm_index *idx) {
165
+ for (uint32_t i = 0; i < hash_map->buckets.size_; ++i) {
166
+ if (get_bucket(&hash_map->buckets, i) != NULL) {
167
+ idx->bucket_index = i;
168
+ idx->item = (hm_item *)get_bucket(&hash_map->buckets, i);
169
+ return;
170
+ }
171
+ }
172
+ intrusive_hash_map_end(hash_map, idx);
173
+ }
174
+
175
+ hm_item *intrusive_hash_map_find(const intrusive_hash_map *hash_map,
176
+ uint64_t key) {
177
+ uint32_t index = chunked_vector_hasher(key) & hash_map->hash_mask;
178
+
179
+ hm_item *p = (hm_item *)get_bucket(&hash_map->buckets, index);
180
+ while (p != NULL) {
181
+ if (key == p->key) {
182
+ return p;
183
+ }
184
+ p = p->hash_link;
185
+ }
186
+ return NULL;
187
+ }
188
+
189
+ hm_item *intrusive_hash_map_erase(intrusive_hash_map *hash_map, uint64_t key) {
190
+ uint32_t index = chunked_vector_hasher(key) & hash_map->hash_mask;
191
+
192
+ hm_item **slot = (hm_item **)get_mutable_bucket(&hash_map->buckets, index);
193
+ hm_item *p = *slot;
194
+ if (p == NULL) {
195
+ return NULL;
196
+ }
197
+
198
+ if (key == p->key) {
199
+ *slot = p->hash_link;
200
+ p->hash_link = NULL;
201
+ hash_map->num_items--;
202
+ return p;
203
+ }
204
+
205
+ hm_item *prev = p;
206
+ p = p->hash_link;
207
+
208
+ while (p) {
209
+ if (key == p->key) {
210
+ prev->hash_link = p->hash_link;
211
+ p->hash_link = NULL;
212
+ hash_map->num_items--;
213
+ return p;
214
+ }
215
+ prev = p;
216
+ p = p->hash_link;
217
+ }
218
+ return NULL;
219
+ }
220
+
221
+ /* Insert an hm_item* into the underlying chunked vector. hash_mask is
222
+ * array_size-1. Returns true if it is a new hm_item and false if the hm_item
223
+ * already existed.
224
+ */
225
+ static inline bool intrusive_hash_map_internal_insert(chunked_vector *buckets,
226
+ uint32_t hash_mask,
227
+ hm_item *item) {
228
+ const uint64_t key = item->key;
229
+ uint32_t index = chunked_vector_hasher(key) & hash_mask;
230
+ hm_item **slot = (hm_item **)get_mutable_bucket(buckets, index);
231
+ hm_item *p = *slot;
232
+ item->hash_link = p;
233
+
234
+ /* Check to see if key already exists. */
235
+ while (p) {
236
+ if (p->key == key) {
237
+ return false;
238
+ }
239
+ p = p->hash_link;
240
+ }
241
+
242
+ /* Otherwise add new entry. */
243
+ *slot = item;
244
+ return true;
245
+ }
246
+
247
+ /* Extend the allocated number of elements in the hash map by a factor of 2. */
248
+ void intrusive_hash_map_extend(intrusive_hash_map *hash_map) {
249
+ uint32_t new_log2_num_buckets = 1 + hash_map->log2_num_buckets;
250
+ uint32_t new_num_buckets = (uint32_t)1 << new_log2_num_buckets;
251
+ GPR_ASSERT(new_num_buckets <= UINT32_MAX && new_num_buckets > 0);
252
+ chunked_vector new_buckets;
253
+ chunked_vector_init(&new_buckets);
254
+ chunked_vector_reset(&new_buckets, new_num_buckets);
255
+ uint32_t new_hash_mask = new_num_buckets - 1;
256
+
257
+ hm_index cur_idx;
258
+ hm_index end_idx;
259
+ intrusive_hash_map_end(hash_map, &end_idx);
260
+ intrusive_hash_map_begin(hash_map, &cur_idx);
261
+ while (!hm_index_compare(&cur_idx, &end_idx)) {
262
+ hm_item *new_item = cur_idx.item;
263
+ intrusive_hash_map_next(hash_map, &cur_idx);
264
+ intrusive_hash_map_internal_insert(&new_buckets, new_hash_mask, new_item);
265
+ }
266
+
267
+ /* Set values for new chunked_vector. extend_threshold is set to half of
268
+ * new_num_buckets. */
269
+ hash_map->log2_num_buckets = new_log2_num_buckets;
270
+ chunked_vector_clear(&hash_map->buckets);
271
+ hash_map->buckets = new_buckets;
272
+ hash_map->hash_mask = new_hash_mask;
273
+ hash_map->extend_threshold = new_num_buckets >> 1;
274
+ }
275
+
276
+ /* Insert a hm_item. The hm_item must remain live until it is removed from the
277
+ table. This object does not take the ownership of hm_item. The caller must
278
+ remove this hm_item from the table and delete it before this table is
279
+ deleted. If hm_item exists already num_items is not changed. */
280
+ bool intrusive_hash_map_insert(intrusive_hash_map *hash_map, hm_item *item) {
281
+ if (hash_map->num_items >= hash_map->extend_threshold) {
282
+ intrusive_hash_map_extend(hash_map);
283
+ }
284
+ if (intrusive_hash_map_internal_insert(&hash_map->buckets,
285
+ hash_map->hash_mask, item)) {
286
+ hash_map->num_items++;
287
+ return true;
288
+ }
289
+ return false;
290
+ }
291
+
292
+ void intrusive_hash_map_clear(intrusive_hash_map *hash_map,
293
+ void (*free_object)(void *)) {
294
+ hm_index cur;
295
+ hm_index end;
296
+ intrusive_hash_map_end(hash_map, &end);
297
+ intrusive_hash_map_begin(hash_map, &cur);
298
+
299
+ while (!hm_index_compare(&cur, &end)) {
300
+ hm_index next = cur;
301
+ intrusive_hash_map_next(hash_map, &next);
302
+ if (cur.item != NULL) {
303
+ hm_item *item = intrusive_hash_map_erase(hash_map, cur.item->key);
304
+ (*free_object)((void *)item);
305
+ gpr_free(item);
306
+ }
307
+ cur = next;
308
+ }
309
+ }
310
+
311
+ void intrusive_hash_map_free(intrusive_hash_map *hash_map,
312
+ void (*free_object)(void *)) {
313
+ intrusive_hash_map_clear(hash_map, (*free_object));
314
+ hash_map->num_items = 0;
315
+ hash_map->extend_threshold = 0;
316
+ hash_map->log2_num_buckets = 0;
317
+ hash_map->hash_mask = 0;
318
+ chunked_vector_clear(&hash_map->buckets);
319
+ }