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
@@ -290,6 +290,12 @@
290
290
  #endif
291
291
  #endif /* GPR_NO_AUTODETECT_PLATFORM */
292
292
 
293
+ #if defined(__has_include)
294
+ #if __has_include(<atomic>)
295
+ #define GRPC_HAS_CXX11_ATOMIC
296
+ #endif /* __has_include(<atomic>) */
297
+ #endif /* defined(__has_include) */
298
+
293
299
  #ifndef GPR_PLATFORM_STRING
294
300
  #warning "GPR_PLATFORM_STRING not auto-detected"
295
301
  #define GPR_PLATFORM_STRING "unknown"
@@ -40,7 +40,7 @@
40
40
  extern "C" {
41
41
  #endif
42
42
 
43
- /* Propagation bits: this can be bitwise or-ed to form propagation_mask for
43
+ /** Propagation bits: this can be bitwise or-ed to form propagation_mask for
44
44
  * grpc_call */
45
45
  /** Propagate deadline */
46
46
  #define GRPC_PROPAGATE_DEADLINE ((uint32_t)1)
@@ -50,7 +50,7 @@ extern "C" {
50
50
  /** Propagate cancellation */
51
51
  #define GRPC_PROPAGATE_CANCELLATION ((uint32_t)8)
52
52
 
53
- /* Default propagation mask: clients of the core API are encouraged to encode
53
+ /** Default propagation mask: clients of the core API are encouraged to encode
54
54
  deltas from this in their implementations... ie write:
55
55
  GRPC_PROPAGATE_DEFAULTS & ~GRPC_PROPAGATE_DEADLINE to disable deadline
56
56
  propagation. Doing so gives flexibility in the future to define new
@@ -34,15 +34,16 @@
34
34
  #ifndef GRPC_IMPL_CODEGEN_SLICE_H
35
35
  #define GRPC_IMPL_CODEGEN_SLICE_H
36
36
 
37
+ #include <grpc/impl/codegen/port_platform.h>
38
+
37
39
  #include <stddef.h>
38
- #include <stdint.h>
39
40
 
40
41
  #include <grpc/impl/codegen/exec_ctx_fwd.h>
41
42
  #include <grpc/impl/codegen/gpr_slice.h>
42
43
 
43
44
  typedef struct grpc_slice grpc_slice;
44
45
 
45
- /* Slice API
46
+ /** Slice API
46
47
 
47
48
  A slice represents a contiguous reference counted array of bytes.
48
49
  It is cheap to take references to a slice, and it is cheap to create a
@@ -62,14 +63,14 @@ typedef struct grpc_slice_refcount_vtable {
62
63
  uint32_t (*hash)(grpc_slice slice);
63
64
  } grpc_slice_refcount_vtable;
64
65
 
65
- /* Reference count container for grpc_slice. Contains function pointers to
66
+ /** Reference count container for grpc_slice. Contains function pointers to
66
67
  increment and decrement reference counts. Implementations should cleanup
67
68
  when the reference count drops to zero.
68
69
  Typically client code should not touch this, and use grpc_slice_malloc,
69
70
  grpc_slice_new, or grpc_slice_new_with_len instead. */
70
71
  typedef struct grpc_slice_refcount {
71
72
  const grpc_slice_refcount_vtable *vtable;
72
- /* If a subset of this slice is taken, use this pointer for the refcount.
73
+ /** If a subset of this slice is taken, use this pointer for the refcount.
73
74
  Typically points back to the refcount itself, however iterning
74
75
  implementations can use this to avoid a verification step on each hash
75
76
  or equality check */
@@ -78,7 +79,7 @@ typedef struct grpc_slice_refcount {
78
79
 
79
80
  #define GRPC_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1)
80
81
 
81
- /* A grpc_slice s, if initialized, represents the byte range
82
+ /** A grpc_slice s, if initialized, represents the byte range
82
83
  s.bytes[0..s.length-1].
83
84
 
84
85
  It can have an associated ref count which has a destruction routine to be run
@@ -103,23 +104,23 @@ struct grpc_slice {
103
104
 
104
105
  #define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8
105
106
 
106
- /* Represents an expandable array of slices, to be interpreted as a
107
+ /** Represents an expandable array of slices, to be interpreted as a
107
108
  single item. */
108
109
  typedef struct {
109
- /* This is for internal use only. External users (i.e any code outside grpc
110
+ /** This is for internal use only. External users (i.e any code outside grpc
110
111
  * core) MUST NOT use this field */
111
112
  grpc_slice *base_slices;
112
113
 
113
- /* slices in the array (Points to the first valid grpc_slice in the array) */
114
+ /** slices in the array (Points to the first valid grpc_slice in the array) */
114
115
  grpc_slice *slices;
115
- /* the number of slices in the array */
116
+ /** the number of slices in the array */
116
117
  size_t count;
117
- /* the number of slices allocated in the array. External users (i.e any code
118
+ /** the number of slices allocated in the array. External users (i.e any code
118
119
  * outside grpc core) MUST NOT use this field */
119
120
  size_t capacity;
120
- /* the combined length of all slices in the array */
121
+ /** the combined length of all slices in the array */
121
122
  size_t length;
122
- /* inlined elements to avoid allocations */
123
+ /** inlined elements to avoid allocations */
123
124
  grpc_slice inlined[GRPC_SLICE_BUFFER_INLINE_ELEMENTS];
124
125
  } grpc_slice_buffer;
125
126
 
@@ -39,40 +39,40 @@ extern "C" {
39
39
  #endif
40
40
 
41
41
  typedef enum {
42
- /* Not an error; returned on success */
42
+ /** Not an error; returned on success */
43
43
  GRPC_STATUS_OK = 0,
44
44
 
45
- /* The operation was cancelled (typically by the caller). */
45
+ /** The operation was cancelled (typically by the caller). */
46
46
  GRPC_STATUS_CANCELLED = 1,
47
47
 
48
- /* Unknown error. An example of where this error may be returned is
48
+ /** Unknown error. An example of where this error may be returned is
49
49
  if a Status value received from another address space belongs to
50
50
  an error-space that is not known in this address space. Also
51
51
  errors raised by APIs that do not return enough error information
52
52
  may be converted to this error. */
53
53
  GRPC_STATUS_UNKNOWN = 2,
54
54
 
55
- /* Client specified an invalid argument. Note that this differs
55
+ /** Client specified an invalid argument. Note that this differs
56
56
  from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
57
57
  that are problematic regardless of the state of the system
58
58
  (e.g., a malformed file name). */
59
59
  GRPC_STATUS_INVALID_ARGUMENT = 3,
60
60
 
61
- /* Deadline expired before operation could complete. For operations
61
+ /** Deadline expired before operation could complete. For operations
62
62
  that change the state of the system, this error may be returned
63
63
  even if the operation has completed successfully. For example, a
64
64
  successful response from a server could have been delayed long
65
65
  enough for the deadline to expire. */
66
66
  GRPC_STATUS_DEADLINE_EXCEEDED = 4,
67
67
 
68
- /* Some requested entity (e.g., file or directory) was not found. */
68
+ /** Some requested entity (e.g., file or directory) was not found. */
69
69
  GRPC_STATUS_NOT_FOUND = 5,
70
70
 
71
- /* Some entity that we attempted to create (e.g., file or directory)
71
+ /** Some entity that we attempted to create (e.g., file or directory)
72
72
  already exists. */
73
73
  GRPC_STATUS_ALREADY_EXISTS = 6,
74
74
 
75
- /* The caller does not have permission to execute the specified
75
+ /** The caller does not have permission to execute the specified
76
76
  operation. PERMISSION_DENIED must not be used for rejections
77
77
  caused by exhausting some resource (use RESOURCE_EXHAUSTED
78
78
  instead for those errors). PERMISSION_DENIED must not be
@@ -80,15 +80,15 @@ typedef enum {
80
80
  instead for those errors). */
81
81
  GRPC_STATUS_PERMISSION_DENIED = 7,
82
82
 
83
- /* The request does not have valid authentication credentials for the
83
+ /** The request does not have valid authentication credentials for the
84
84
  operation. */
85
85
  GRPC_STATUS_UNAUTHENTICATED = 16,
86
86
 
87
- /* Some resource has been exhausted, perhaps a per-user quota, or
87
+ /** Some resource has been exhausted, perhaps a per-user quota, or
88
88
  perhaps the entire file system is out of space. */
89
89
  GRPC_STATUS_RESOURCE_EXHAUSTED = 8,
90
90
 
91
- /* Operation was rejected because the system is not in a state
91
+ /** Operation was rejected because the system is not in a state
92
92
  required for the operation's execution. For example, directory
93
93
  to be deleted may be non-empty, an rmdir operation is applied to
94
94
  a non-directory, etc.
@@ -109,14 +109,14 @@ typedef enum {
109
109
  read-modify-write on the same resource. */
110
110
  GRPC_STATUS_FAILED_PRECONDITION = 9,
111
111
 
112
- /* The operation was aborted, typically due to a concurrency issue
112
+ /** The operation was aborted, typically due to a concurrency issue
113
113
  like sequencer check failures, transaction aborts, etc.
114
114
 
115
115
  See litmus test above for deciding between FAILED_PRECONDITION,
116
116
  ABORTED, and UNAVAILABLE. */
117
117
  GRPC_STATUS_ABORTED = 10,
118
118
 
119
- /* Operation was attempted past the valid range. E.g., seeking or
119
+ /** Operation was attempted past the valid range. E.g., seeking or
120
120
  reading past end of file.
121
121
 
122
122
  Unlike INVALID_ARGUMENT, this error indicates a problem that may
@@ -133,26 +133,31 @@ typedef enum {
133
133
  they are done. */
134
134
  GRPC_STATUS_OUT_OF_RANGE = 11,
135
135
 
136
- /* Operation is not implemented or not supported/enabled in this service. */
136
+ /** Operation is not implemented or not supported/enabled in this service. */
137
137
  GRPC_STATUS_UNIMPLEMENTED = 12,
138
138
 
139
- /* Internal errors. Means some invariants expected by underlying
139
+ /** Internal errors. Means some invariants expected by underlying
140
140
  system has been broken. If you see one of these errors,
141
141
  something is very broken. */
142
142
  GRPC_STATUS_INTERNAL = 13,
143
143
 
144
- /* The service is currently unavailable. This is a most likely a
144
+ /** The service is currently unavailable. This is a most likely a
145
145
  transient condition and may be corrected by retrying with
146
146
  a backoff.
147
147
 
148
+ WARNING: Although data MIGHT not have been transmitted when this
149
+ status occurs, there is NOT A GUARANTEE that the server has not seen
150
+ anything. So in general it is unsafe to retry on this status code
151
+ if the call is non-idempotent.
152
+
148
153
  See litmus test above for deciding between FAILED_PRECONDITION,
149
154
  ABORTED, and UNAVAILABLE. */
150
155
  GRPC_STATUS_UNAVAILABLE = 14,
151
156
 
152
- /* Unrecoverable data loss or corruption. */
157
+ /** Unrecoverable data loss or corruption. */
153
158
  GRPC_STATUS_DATA_LOSS = 15,
154
159
 
155
- /* Force users to include a default branch: */
160
+ /** Force users to include a default branch: */
156
161
  GRPC_STATUS__DO_NOT_USE = -1
157
162
  } grpc_status_code;
158
163
 
@@ -33,7 +33,7 @@
33
33
 
34
34
  #ifndef GRPC_IMPL_CODEGEN_SYNC_H
35
35
  #define GRPC_IMPL_CODEGEN_SYNC_H
36
- /* Synchronization primitives for GPR.
36
+ /** Synchronization primitives for GPR.
37
37
 
38
38
  The type gpr_mu provides a non-reentrant mutex (lock).
39
39
 
@@ -35,7 +35,6 @@
35
35
  #define GRPC_LOAD_REPORTING_H
36
36
 
37
37
  #include <grpc/impl/codegen/port_platform.h>
38
- #include <grpc/slice.h>
39
38
 
40
39
  #ifdef __cplusplus
41
40
  extern "C" {
@@ -50,11 +49,12 @@ extern "C" {
50
49
  * gRPC LB system. */
51
50
  #define GRPC_LB_TOKEN_MD_KEY "lb-token"
52
51
 
53
- /** A sequence of values for load reporting purposes */
54
- typedef struct grpc_load_reporting_cost_context {
55
- grpc_slice *values;
56
- size_t values_count;
57
- } grpc_load_reporting_cost_context;
52
+ /** Metadata key for gRPC LB cost reporting.
53
+ *
54
+ * The value corresponding to this key is an opaque binary blob reported by the
55
+ * backend as part of its trailing metadata containing cost information for the
56
+ * call. */
57
+ #define GRPC_LB_COST_MD_KEY "lb-cost-bin"
58
58
 
59
59
  #ifdef __cplusplus
60
60
  }
@@ -41,11 +41,11 @@
41
41
  extern "C" {
42
42
  #endif
43
43
 
44
- /* Increment the refcount of s. Requires slice is initialized.
44
+ /** Increment the refcount of s. Requires slice is initialized.
45
45
  Returns s. */
46
46
  GPRAPI grpc_slice grpc_slice_ref(grpc_slice s);
47
47
 
48
- /* Decrement the ref count of s. If the ref count of s reaches zero, all
48
+ /** Decrement the ref count of s. If the ref count of s reaches zero, all
49
49
  slices sharing the ref count are destroyed, and considered no longer
50
50
  initialized. If s is ultimately derived from a call to grpc_slice_new(start,
51
51
  len, dest) where dest!=NULL , then (*dest)(start) is called, else if s is
@@ -53,12 +53,15 @@ GPRAPI grpc_slice grpc_slice_ref(grpc_slice s);
53
53
  where dest!=NULL , then (*dest)(start, len). Requires s initialized. */
54
54
  GPRAPI void grpc_slice_unref(grpc_slice s);
55
55
 
56
- /* Create a slice pointing at some data. Calls malloc to allocate a refcount
56
+ /** Copy slice - create a new slice that contains the same data as s */
57
+ GPRAPI grpc_slice grpc_slice_copy(grpc_slice s);
58
+
59
+ /** Create a slice pointing at some data. Calls malloc to allocate a refcount
57
60
  for the object, and arranges that destroy will be called with the pointer
58
61
  passed in at destruction. */
59
62
  GPRAPI grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *));
60
63
 
61
- /* Equivalent to grpc_slice_new, but with a separate pointer that is
64
+ /** Equivalent to grpc_slice_new, but with a separate pointer that is
62
65
  passed to the destroy function. This function can be useful when
63
66
  the data is part of a larger structure that must be destroyed when
64
67
  the data is no longer needed. */
@@ -66,23 +69,30 @@ GPRAPI grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
66
69
  void (*destroy)(void *),
67
70
  void *user_data);
68
71
 
69
- /* Equivalent to grpc_slice_new, but with a two argument destroy function that
72
+ /** Equivalent to grpc_slice_new, but with a two argument destroy function that
70
73
  also takes the slice length. */
71
74
  GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len,
72
75
  void (*destroy)(void *, size_t));
73
76
 
74
- /* Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc()
77
+ /** Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc()
75
78
  call.
76
79
  Aborts if malloc() fails. */
77
80
  GPRAPI grpc_slice grpc_slice_malloc(size_t length);
81
+ GPRAPI grpc_slice grpc_slice_malloc_large(size_t length);
82
+
83
+ #define GRPC_SLICE_MALLOC(len) \
84
+ ((len) <= GRPC_SLICE_INLINED_SIZE \
85
+ ? (grpc_slice){.refcount = NULL, \
86
+ .data.inlined = {.length = (uint8_t)(len)}} \
87
+ : grpc_slice_malloc_large((len)))
78
88
 
79
- /* Intern a slice:
89
+ /** Intern a slice:
80
90
 
81
91
  The return value for two invocations of this function with the same sequence
82
92
  of bytes is a slice which points to the same memory. */
83
93
  GPRAPI grpc_slice grpc_slice_intern(grpc_slice slice);
84
94
 
85
- /* Create a slice by copying a string.
95
+ /** Create a slice by copying a string.
86
96
  Does not preserve null terminators.
87
97
  Equivalent to:
88
98
  size_t len = strlen(source);
@@ -90,34 +100,46 @@ GPRAPI grpc_slice grpc_slice_intern(grpc_slice slice);
90
100
  memcpy(slice->data, source, len); */
91
101
  GPRAPI grpc_slice grpc_slice_from_copied_string(const char *source);
92
102
 
93
- /* Create a slice by copying a buffer.
103
+ /** Create a slice by copying a buffer.
94
104
  Equivalent to:
95
105
  grpc_slice slice = grpc_slice_malloc(len);
96
106
  memcpy(slice->data, source, len); */
97
107
  GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len);
98
108
 
99
- /* Create a slice pointing to constant memory */
109
+ /** Create a slice pointing to constant memory */
100
110
  GPRAPI grpc_slice grpc_slice_from_static_string(const char *source);
101
111
 
102
- /* Create a slice pointing to constant memory */
112
+ /** Create a slice pointing to constant memory */
103
113
  GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len);
104
114
 
105
- /* Return a result slice derived from s, which shares a ref count with s, where
106
- result.data==s.data+begin, and result.length==end-begin.
107
- The ref count of s is increased by one.
115
+ /** Return a result slice derived from s, which shares a ref count with \a s,
116
+ where result.data==s.data+begin, and result.length==end-begin. The ref count
117
+ of \a s is increased by one. Do not assign result back to \a s.
108
118
  Requires s initialized, begin <= end, begin <= s.length, and
109
119
  end <= source->length. */
110
120
  GPRAPI grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end);
111
121
 
112
- /* The same as grpc_slice_sub, but without altering the ref count */
122
+ /** The same as grpc_slice_sub, but without altering the ref count */
113
123
  GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end);
114
124
 
115
- /* Splits s into two: modifies s to be s[0:split], and returns a new slice,
125
+ /** Splits s into two: modifies s to be s[0:split], and returns a new slice,
116
126
  sharing a refcount with s, that contains s[split:s.length].
117
127
  Requires s intialized, split <= s.length */
118
128
  GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split);
119
129
 
120
- /* Splits s into two: modifies s to be s[split:s.length], and returns a new
130
+ typedef enum {
131
+ GRPC_SLICE_REF_TAIL = 1,
132
+ GRPC_SLICE_REF_HEAD = 2,
133
+ GRPC_SLICE_REF_BOTH = 1 + 2
134
+ } grpc_slice_ref_whom;
135
+
136
+ /** The same as grpc_slice_split_tail, but with an option to skip altering
137
+ * refcounts (grpc_slice_split_tail_maybe_ref(..., true) is equivalent to
138
+ * grpc_slice_split_tail(...)) */
139
+ GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *s, size_t split,
140
+ grpc_slice_ref_whom ref_whom);
141
+
142
+ /** Splits s into two: modifies s to be s[split:s.length], and returns a new
121
143
  slice, sharing a refcount with s, that contains s[0:split].
122
144
  Requires s intialized, split <= s.length */
123
145
  GPRAPI grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split);
@@ -129,35 +151,35 @@ GPRAPI int grpc_slice_default_eq_impl(grpc_slice a, grpc_slice b);
129
151
 
130
152
  GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b);
131
153
 
132
- /* Returns <0 if a < b, ==0 if a == b, >0 if a > b
154
+ /** Returns <0 if a < b, ==0 if a == b, >0 if a > b
133
155
  The order is arbitrary, and is not guaranteed to be stable across different
134
156
  versions of the API. */
135
157
  GPRAPI int grpc_slice_cmp(grpc_slice a, grpc_slice b);
136
158
  GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char *b);
137
159
  GPRAPI int grpc_slice_buf_cmp(grpc_slice a, const void *b, size_t blen);
138
160
 
139
- /* return non-zero if the first blen bytes of a are equal to b */
161
+ /** return non-zero if the first blen bytes of a are equal to b */
140
162
  GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void *b, size_t blen);
141
163
 
142
- /* return the index of the last instance of \a c in \a s, or -1 if not found */
164
+ /** return the index of the last instance of \a c in \a s, or -1 if not found */
143
165
  GPRAPI int grpc_slice_rchr(grpc_slice s, char c);
144
166
  GPRAPI int grpc_slice_chr(grpc_slice s, char c);
145
167
 
146
- /* return the index of the first occurance of \a needle in \a haystack, or -1 if
147
- * it's not found */
168
+ /** return the index of the first occurance of \a needle in \a haystack, or -1
169
+ if it's not found */
148
170
  GPRAPI int grpc_slice_slice(grpc_slice haystack, grpc_slice needle);
149
171
 
150
172
  GPRAPI uint32_t grpc_slice_hash(grpc_slice s);
151
173
 
152
- /* Do two slices point at the same memory, with the same length
174
+ /** Do two slices point at the same memory, with the same length
153
175
  If a or b is inlined, actually compares data */
154
176
  GPRAPI int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b);
155
177
 
156
- /* Return a slice pointing to newly allocated memory that has the same contents
178
+ /** Return a slice pointing to newly allocated memory that has the same contents
157
179
  * as \a s */
158
180
  GPRAPI grpc_slice grpc_slice_dup(grpc_slice a);
159
181
 
160
- /* Return a copy of slice as a C string. Offers no protection against embedded
182
+ /** Return a copy of slice as a C string. Offers no protection against embedded
161
183
  NULL's. Returned string must be freed with gpr_free. */
162
184
  GPRAPI char *grpc_slice_to_c_string(grpc_slice s);
163
185
 
@@ -40,15 +40,15 @@
40
40
  extern "C" {
41
41
  #endif
42
42
 
43
- /* initialize a slice buffer */
43
+ /** initialize a slice buffer */
44
44
  GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb);
45
- /* destroy a slice buffer - unrefs any held elements */
45
+ /** destroy a slice buffer - unrefs any held elements */
46
46
  GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer *sb);
47
- /* Add an element to a slice buffer - takes ownership of the slice.
47
+ /** Add an element to a slice buffer - takes ownership of the slice.
48
48
  This function is allowed to concatenate the passed in slice to the end of
49
49
  some other slice if desired by the slice buffer. */
50
50
  GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice);
51
- /* add an element to a slice buffer - takes ownership of the slice and returns
51
+ /** add an element to a slice buffer - takes ownership of the slice and returns
52
52
  the index of the slice.
53
53
  Guarantees that the slice will not be concatenated at the end of another
54
54
  slice (i.e. the data for this slice will begin at the first byte of the
@@ -59,31 +59,35 @@ GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb,
59
59
  grpc_slice slice);
60
60
  GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices,
61
61
  size_t n);
62
- /* add a very small (less than 8 bytes) amount of data to the end of a slice
62
+ /** add a very small (less than 8 bytes) amount of data to the end of a slice
63
63
  buffer: returns a pointer into which to add the data */
64
64
  GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len);
65
- /* pop the last buffer, but don't unref it */
65
+ /** pop the last buffer, but don't unref it */
66
66
  GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer *sb);
67
- /* clear a slice buffer, unref all elements */
67
+ /** clear a slice buffer, unref all elements */
68
68
  GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb);
69
- /* swap the contents of two slice buffers */
69
+ /** swap the contents of two slice buffers */
70
70
  GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b);
71
- /* move all of the elements of src into dst */
71
+ /** move all of the elements of src into dst */
72
72
  GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src,
73
73
  grpc_slice_buffer *dst);
74
- /* remove n bytes from the end of a slice buffer */
74
+ /** remove n bytes from the end of a slice buffer */
75
75
  GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n,
76
76
  grpc_slice_buffer *garbage);
77
- /* move the first n bytes of src into dst */
77
+ /** move the first n bytes of src into dst */
78
78
  GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
79
79
  grpc_slice_buffer *dst);
80
- /* move the first n bytes of src into dst (copying them) */
80
+ /** move the first n bytes of src into dst without adding references */
81
+ GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src,
82
+ size_t n,
83
+ grpc_slice_buffer *dst);
84
+ /** move the first n bytes of src into dst (copying them) */
81
85
  GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
82
86
  grpc_slice_buffer *src,
83
87
  size_t n, void *dst);
84
- /* take the first slice in the slice buffer */
88
+ /** take the first slice in the slice buffer */
85
89
  GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src);
86
- /* undo the above with (a possibly different) \a slice */
90
+ /** undo the above with (a possibly different) \a slice */
87
91
  GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *src,
88
92
  grpc_slice slice);
89
93