grpc 1.1.2 → 1.2.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 (255) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1257 -404
  3. data/etc/roots.pem +189 -102
  4. data/include/grpc/census.h +7 -7
  5. data/include/grpc/compression.h +4 -4
  6. data/include/grpc/grpc.h +13 -7
  7. data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
  8. data/include/grpc/impl/codegen/grpc_types.h +39 -30
  9. data/include/grpc/impl/codegen/slice.h +24 -6
  10. data/include/grpc/impl/codegen/sync.h +8 -0
  11. data/include/grpc/load_reporting.h +63 -0
  12. data/include/grpc/slice.h +37 -1
  13. data/include/grpc/slice_buffer.h +7 -0
  14. data/include/grpc/support/alloc.h +3 -0
  15. data/include/grpc/support/useful.h +3 -0
  16. data/src/core/ext/census/gen/census.pb.h +1 -1
  17. data/src/core/ext/census/gen/trace_context.pb.c +9 -36
  18. data/src/core/ext/census/gen/trace_context.pb.h +20 -26
  19. data/src/core/ext/census/grpc_filter.c +3 -5
  20. data/src/core/ext/census/trace_context.c +1 -1
  21. data/src/core/ext/census/trace_context.h +3 -0
  22. data/src/core/ext/census/trace_label.h +61 -0
  23. data/src/core/ext/census/trace_propagation.h +63 -0
  24. data/src/core/ext/census/trace_status.h +45 -0
  25. data/src/core/ext/census/trace_string.h +50 -0
  26. data/src/core/ext/census/tracing.c +31 -11
  27. data/src/core/ext/census/tracing.h +124 -0
  28. data/src/core/ext/client_channel/client_channel.c +456 -368
  29. data/src/core/ext/client_channel/client_channel.h +4 -0
  30. data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
  31. data/src/core/ext/client_channel/connector.c +3 -3
  32. data/src/core/ext/client_channel/connector.h +4 -3
  33. data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
  34. data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
  35. data/src/core/ext/client_channel/http_proxy.c +125 -0
  36. data/src/core/ext/client_channel/http_proxy.h +39 -0
  37. data/src/core/ext/client_channel/lb_policy.c +56 -35
  38. data/src/core/ext/client_channel/lb_policy.h +46 -39
  39. data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
  40. data/src/core/ext/client_channel/parse_address.c +32 -6
  41. data/src/core/ext/client_channel/proxy_mapper.c +63 -0
  42. data/src/core/ext/client_channel/proxy_mapper.h +89 -0
  43. data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
  44. data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
  45. data/src/core/ext/client_channel/resolver.c +16 -9
  46. data/src/core/ext/client_channel/resolver.h +23 -12
  47. data/src/core/ext/client_channel/resolver_factory.h +1 -0
  48. data/src/core/ext/client_channel/resolver_registry.c +15 -11
  49. data/src/core/ext/client_channel/resolver_registry.h +5 -3
  50. data/src/core/ext/client_channel/subchannel.c +44 -27
  51. data/src/core/ext/client_channel/subchannel.h +6 -2
  52. data/src/core/ext/client_channel/uri_parser.c +26 -14
  53. data/src/core/ext/client_channel/uri_parser.h +3 -1
  54. data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
  55. data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
  56. data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
  57. data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
  58. data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
  59. data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
  60. data/src/core/ext/load_reporting/load_reporting.c +20 -0
  61. data/src/core/ext/load_reporting/load_reporting.h +1 -16
  62. data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
  63. data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
  64. data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
  65. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
  66. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
  67. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
  68. data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
  69. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
  70. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
  71. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
  72. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
  73. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
  74. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
  75. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
  76. data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
  77. data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
  78. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
  79. data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
  80. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
  81. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
  84. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
  86. data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
  87. data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
  88. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
  89. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
  90. data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
  91. data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
  92. data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
  93. data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
  94. data/src/core/lib/channel/channel_stack.c +14 -44
  95. data/src/core/lib/channel/channel_stack.h +10 -17
  96. data/src/core/lib/channel/channel_stack_builder.c +2 -3
  97. data/src/core/lib/channel/compress_filter.c +54 -46
  98. data/src/core/lib/channel/connected_channel.c +4 -4
  99. data/src/core/lib/channel/connected_channel.h +5 -0
  100. data/src/core/lib/channel/context.h +3 -0
  101. data/src/core/lib/channel/deadline_filter.c +61 -61
  102. data/src/core/lib/channel/deadline_filter.h +8 -5
  103. data/src/core/lib/channel/handshaker.c +47 -7
  104. data/src/core/lib/channel/handshaker.h +21 -3
  105. data/src/core/lib/channel/http_client_filter.c +149 -99
  106. data/src/core/lib/channel/http_server_filter.c +163 -147
  107. data/src/core/lib/channel/message_size_filter.c +15 -10
  108. data/src/core/lib/compression/algorithm_metadata.h +4 -4
  109. data/src/core/lib/compression/compression.c +17 -23
  110. data/src/core/lib/http/httpcli.c +3 -2
  111. data/src/core/lib/http/httpcli.h +2 -1
  112. data/src/core/lib/http/httpcli_security_connector.c +2 -3
  113. data/src/core/lib/http/parser.c +2 -2
  114. data/src/core/lib/iomgr/closure.c +6 -3
  115. data/src/core/lib/iomgr/closure.h +4 -2
  116. data/src/core/lib/iomgr/combiner.c +35 -5
  117. data/src/core/lib/iomgr/combiner.h +21 -2
  118. data/src/core/lib/iomgr/endpoint.c +3 -2
  119. data/src/core/lib/iomgr/endpoint.h +3 -2
  120. data/src/core/lib/iomgr/error.c +60 -94
  121. data/src/core/lib/iomgr/error.h +7 -10
  122. data/src/core/lib/iomgr/error_internal.h +54 -0
  123. data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
  124. data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
  125. data/src/core/lib/iomgr/ev_posix.c +7 -8
  126. data/src/core/lib/iomgr/ev_posix.h +4 -4
  127. data/src/core/lib/iomgr/exec_ctx.c +11 -6
  128. data/src/core/lib/iomgr/exec_ctx.h +11 -14
  129. data/src/core/lib/iomgr/executor.c +2 -2
  130. data/src/core/lib/iomgr/load_file.c +1 -1
  131. data/src/core/lib/iomgr/network_status_tracker.c +5 -81
  132. data/src/core/lib/iomgr/pollset.h +1 -3
  133. data/src/core/lib/iomgr/pollset_set.h +2 -1
  134. data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
  135. data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
  136. data/src/core/lib/iomgr/pollset_uv.c +25 -11
  137. data/src/core/lib/iomgr/pollset_windows.c +0 -11
  138. data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
  139. data/src/core/lib/iomgr/resource_quota.c +41 -11
  140. data/src/core/lib/iomgr/resource_quota.h +6 -0
  141. data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
  142. data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
  143. data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
  144. data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
  145. data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
  146. data/src/core/lib/iomgr/tcp_posix.c +4 -5
  147. data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
  148. data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
  149. data/src/core/lib/iomgr/tcp_uv.c +11 -5
  150. data/src/core/lib/iomgr/tcp_windows.c +20 -7
  151. data/src/core/lib/iomgr/timer_generic.c +15 -22
  152. data/src/core/lib/iomgr/timer_generic.h +1 -1
  153. data/src/core/lib/iomgr/timer_uv.c +10 -6
  154. data/src/core/lib/iomgr/timer_uv.h +1 -1
  155. data/src/core/lib/iomgr/udp_server.c +45 -6
  156. data/src/core/lib/iomgr/udp_server.h +7 -1
  157. data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
  158. data/src/core/lib/json/json.c +1 -2
  159. data/src/core/lib/profiling/basic_timers.c +17 -3
  160. data/src/core/lib/security/context/security_context.c +3 -10
  161. data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
  162. data/src/core/lib/security/credentials/credentials.c +48 -2
  163. data/src/core/lib/security/credentials/credentials.h +13 -0
  164. data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
  165. data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
  166. data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
  167. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
  168. data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
  169. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
  170. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
  171. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
  172. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
  173. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
  174. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
  175. data/src/core/lib/security/transport/client_auth_filter.c +72 -47
  176. data/src/core/lib/security/transport/lb_targets_info.c +70 -0
  177. data/src/core/lib/security/transport/lb_targets_info.h +47 -0
  178. data/src/core/lib/security/transport/secure_endpoint.c +3 -3
  179. data/src/core/lib/security/transport/security_connector.c +125 -28
  180. data/src/core/lib/security/transport/security_connector.h +4 -3
  181. data/src/core/lib/security/transport/security_handshaker.c +13 -9
  182. data/src/core/lib/security/transport/server_auth_filter.c +31 -40
  183. data/src/core/lib/security/util/b64.c +1 -1
  184. data/src/core/lib/slice/slice.c +110 -20
  185. data/src/core/lib/slice/slice_buffer.c +92 -39
  186. data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
  187. data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
  188. data/src/core/lib/slice/slice_intern.c +346 -0
  189. data/src/core/lib/slice/slice_internal.h +15 -0
  190. data/src/core/lib/slice/slice_string_helpers.c +5 -0
  191. data/src/core/lib/slice/slice_string_helpers.h +5 -0
  192. data/src/core/lib/support/alloc.c +26 -1
  193. data/src/core/lib/support/cmdline.c +2 -4
  194. data/src/core/lib/support/cpu_posix.c +2 -7
  195. data/src/core/lib/support/histogram.c +1 -2
  196. data/src/core/lib/support/log_posix.c +8 -4
  197. data/src/core/lib/support/spinlock.h +52 -0
  198. data/src/core/lib/support/subprocess_posix.c +1 -2
  199. data/src/core/lib/support/sync.c +7 -1
  200. data/src/core/lib/support/sync_posix.c +9 -0
  201. data/src/core/lib/support/time_windows.c +7 -1
  202. data/src/core/lib/surface/call.c +647 -629
  203. data/src/core/lib/surface/call.h +4 -1
  204. data/src/core/lib/surface/call_details.c +8 -2
  205. data/src/core/lib/surface/call_log_batch.c +17 -6
  206. data/src/core/lib/surface/channel.c +49 -59
  207. data/src/core/lib/surface/channel.h +5 -6
  208. data/src/core/lib/surface/completion_queue.c +16 -45
  209. data/src/core/lib/surface/completion_queue.h +0 -3
  210. data/src/core/lib/surface/init.c +6 -2
  211. data/src/core/lib/surface/init_secure.c +1 -1
  212. data/src/core/lib/surface/lame_client.c +14 -4
  213. data/src/core/lib/surface/server.c +79 -82
  214. data/src/core/lib/surface/validate_metadata.c +46 -15
  215. data/src/core/lib/surface/validate_metadata.h +43 -0
  216. data/src/core/lib/surface/version.c +2 -2
  217. data/src/core/lib/transport/bdp_estimator.c +104 -0
  218. data/src/core/lib/transport/bdp_estimator.h +76 -0
  219. data/src/core/lib/transport/connectivity_state.c +33 -13
  220. data/src/core/lib/transport/connectivity_state.h +15 -5
  221. data/src/core/lib/transport/error_utils.c +124 -0
  222. data/src/core/lib/transport/error_utils.h +56 -0
  223. data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
  224. data/src/core/lib/transport/metadata.c +259 -503
  225. data/src/core/lib/transport/metadata.h +69 -68
  226. data/src/core/lib/transport/metadata_batch.c +183 -63
  227. data/src/core/lib/transport/metadata_batch.h +50 -26
  228. data/src/core/lib/transport/pid_controller.c +28 -8
  229. data/src/core/lib/transport/pid_controller.h +15 -2
  230. data/src/core/lib/transport/service_config.c +21 -18
  231. data/src/core/lib/transport/service_config.h +5 -5
  232. data/src/core/lib/transport/static_metadata.c +753 -112
  233. data/src/core/lib/transport/static_metadata.h +403 -264
  234. data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
  235. data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
  236. data/src/core/lib/transport/timeout_encoding.c +11 -9
  237. data/src/core/lib/transport/timeout_encoding.h +3 -1
  238. data/src/core/lib/transport/transport.c +47 -87
  239. data/src/core/lib/transport/transport.h +20 -25
  240. data/src/core/lib/transport/transport_op_string.c +7 -19
  241. data/src/core/lib/tsi/fake_transport_security.c +2 -4
  242. data/src/core/lib/tsi/ssl_transport_security.c +7 -16
  243. data/src/core/lib/tsi/transport_security.c +2 -4
  244. data/src/ruby/ext/grpc/extconf.rb +4 -1
  245. data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
  246. data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
  247. data/src/ruby/ext/grpc/rb_call.c +47 -46
  248. data/src/ruby/ext/grpc/rb_channel.c +21 -6
  249. data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
  250. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
  251. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
  252. data/src/ruby/ext/grpc/rb_server.c +6 -4
  253. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  254. data/src/ruby/lib/grpc/version.rb +1 -1
  255. metadata +33 -9
@@ -179,9 +179,30 @@ typedef struct {
179
179
  Larger values give lower CPU usage for large messages, but more head of line
180
180
  blocking for small messages. */
181
181
  #define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size"
182
+ /** Should BDP probing be performed? */
183
+ #define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe"
184
+ /** Minimum time (in milliseconds) between successive ping frames being sent */
185
+ #define GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS \
186
+ "grpc.http2.min_time_between_pings_ms"
187
+ /** How many pings can we send before needing to send a data frame or header
188
+ frame?
189
+ (0 indicates that an infinite number of pings can be sent without sending
190
+ a data frame or header frame) */
191
+ #define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \
192
+ "grpc.http2.max_pings_without_data"
182
193
  /** How much data are we willing to queue up per stream if
183
194
  GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */
184
195
  #define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
196
+ /** After a duration of this time the client pings the server to see if the
197
+ transport is still alive. Int valued, seconds. */
198
+ #define GRPC_ARG_HTTP2_KEEPALIVE_TIME "grpc.http2.keepalive_time"
199
+ /** After waiting for a duration of this time, if the client does not receive
200
+ the ping ack, it will close the transport. Int valued, seconds. */
201
+ #define GRPC_ARG_HTTP2_KEEPALIVE_TIMEOUT "grpc.http2.keepalive_timeout"
202
+ /** Is it permissible to send keepalive pings without any outstanding streams.
203
+ Int valued, 0(false)/1(true). */
204
+ #define GRPC_ARG_HTTP2_KEEPALIVE_PERMIT_WITHOUT_CALLS \
205
+ "grpc.http2.keepalive_permit_without_calls"
185
206
  /** Default authority to pass if none specified on call construction. A string.
186
207
  * */
187
208
  #define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority"
@@ -211,12 +232,18 @@ typedef struct {
211
232
  /** If non-zero, a pointer to a buffer pool (use grpc_resource_quota_arg_vtable
212
233
  to fetch an appropriate pointer arg vtable) */
213
234
  #define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota"
235
+ /** If non-zero, expand wildcard addresses to a list of local addresses. */
236
+ #define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs"
214
237
  /** Service config data in JSON form. Not intended for use outside of tests. */
215
238
  #define GRPC_ARG_SERVICE_CONFIG "grpc.service_config"
216
239
  /** LB policy name. */
217
240
  #define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name"
218
241
  /** The grpc_socket_mutator instance that set the socket options. A pointer. */
219
242
  #define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
243
+ /** If non-zero, Cronet transport will coalesce packets to fewer frames when
244
+ * possible. */
245
+ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
246
+ "grpc.use_cronet_packet_coalescing"
220
247
  /** \} */
221
248
 
222
249
  /** Result of a grpc call. If the caller satisfies the prerequisites of a
@@ -294,9 +321,11 @@ typedef enum grpc_call_error {
294
321
 
295
322
  /** A single metadata element */
296
323
  typedef struct grpc_metadata {
297
- const char *key;
298
- const char *value;
299
- size_t value_length;
324
+ /* the key, value values are expected to line up with grpc_mdelem: if changing
325
+ them, update metadata.h at the same time. */
326
+ grpc_slice key;
327
+ grpc_slice value;
328
+
300
329
  uint32_t flags;
301
330
 
302
331
  /** The following fields are reserved for grpc internal use.
@@ -338,10 +367,8 @@ typedef struct {
338
367
  } grpc_metadata_array;
339
368
 
340
369
  typedef struct {
341
- char *method;
342
- size_t method_capacity;
343
- char *host;
344
- size_t host_capacity;
370
+ grpc_slice method;
371
+ grpc_slice host;
345
372
  gpr_timespec deadline;
346
373
  uint32_t flags;
347
374
  void *reserved;
@@ -425,7 +452,10 @@ typedef struct grpc_op {
425
452
  size_t trailing_metadata_count;
426
453
  grpc_metadata *trailing_metadata;
427
454
  grpc_status_code status;
428
- const char *status_details;
455
+ /* optional: set to NULL if no details need sending, non-NULL if they do
456
+ * pointer will not be retained past the start_batch call
457
+ */
458
+ grpc_slice *status_details;
429
459
  } send_status_from_server;
430
460
  /** ownership of the array is with the caller, but ownership of the elements
431
461
  stays with the call object (ie key, value members are owned by the call
@@ -450,28 +480,7 @@ typedef struct grpc_op {
450
480
  value, or reuse it in a future op. */
451
481
  grpc_metadata_array *trailing_metadata;
452
482
  grpc_status_code *status;
453
- /** status_details is a buffer owned by the application before the op
454
- completes and after the op has completed. During the operation
455
- status_details may be reallocated to a size larger than
456
- *status_details_capacity, in which case *status_details_capacity will
457
- be updated with the new array capacity.
458
-
459
- Pre-allocating space:
460
- size_t my_capacity = 8;
461
- char *my_details = gpr_malloc(my_capacity);
462
- x.status_details = &my_details;
463
- x.status_details_capacity = &my_capacity;
464
-
465
- Not pre-allocating space:
466
- size_t my_capacity = 0;
467
- char *my_details = NULL;
468
- x.status_details = &my_details;
469
- x.status_details_capacity = &my_capacity;
470
-
471
- After the call:
472
- gpr_free(my_details); */
473
- char **status_details;
474
- size_t *status_details_capacity;
483
+ grpc_slice *status_details;
475
484
  } recv_status_on_client;
476
485
  struct {
477
486
  /** out argument, set to 1 if the call failed in any way (seen as a
@@ -40,6 +40,8 @@
40
40
  #include <grpc/impl/codegen/exec_ctx_fwd.h>
41
41
  #include <grpc/impl/codegen/gpr_slice.h>
42
42
 
43
+ typedef struct grpc_slice grpc_slice;
44
+
43
45
  /* Slice API
44
46
 
45
47
  A slice represents a contiguous reference counted array of bytes.
@@ -53,14 +55,25 @@
53
55
  reference ownership semantics (who should call unref?) and mutability
54
56
  constraints (is the callee allowed to modify the slice?) */
55
57
 
58
+ typedef struct grpc_slice_refcount_vtable {
59
+ void (*ref)(void *);
60
+ void (*unref)(grpc_exec_ctx *exec_ctx, void *);
61
+ int (*eq)(grpc_slice a, grpc_slice b);
62
+ uint32_t (*hash)(grpc_slice slice);
63
+ } grpc_slice_refcount_vtable;
64
+
56
65
  /* Reference count container for grpc_slice. Contains function pointers to
57
66
  increment and decrement reference counts. Implementations should cleanup
58
67
  when the reference count drops to zero.
59
68
  Typically client code should not touch this, and use grpc_slice_malloc,
60
69
  grpc_slice_new, or grpc_slice_new_with_len instead. */
61
70
  typedef struct grpc_slice_refcount {
62
- void (*ref)(void *);
63
- void (*unref)(grpc_exec_ctx *exec_ctx, void *);
71
+ const grpc_slice_refcount_vtable *vtable;
72
+ /* If a subset of this slice is taken, use this pointer for the refcount.
73
+ Typically points back to the refcount itself, however iterning
74
+ implementations can use this to avoid a verification step on each hash
75
+ or equality check */
76
+ struct grpc_slice_refcount *sub_refcount;
64
77
  } grpc_slice_refcount;
65
78
 
66
79
  #define GRPC_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1)
@@ -74,7 +87,7 @@ typedef struct grpc_slice_refcount {
74
87
 
75
88
  If the slice does not have a refcount, it represents an inlined small piece
76
89
  of data that is copied by value. */
77
- typedef struct grpc_slice {
90
+ struct grpc_slice {
78
91
  struct grpc_slice_refcount *refcount;
79
92
  union {
80
93
  struct {
@@ -86,18 +99,23 @@ typedef struct grpc_slice {
86
99
  uint8_t bytes[GRPC_SLICE_INLINED_SIZE];
87
100
  } inlined;
88
101
  } data;
89
- } grpc_slice;
102
+ };
90
103
 
91
104
  #define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8
92
105
 
93
106
  /* Represents an expandable array of slices, to be interpreted as a
94
107
  single item. */
95
108
  typedef struct {
96
- /* slices in the array */
109
+ /* This is for internal use only. External users (i.e any code outside grpc
110
+ * core) MUST NOT use this field */
111
+ grpc_slice *base_slices;
112
+
113
+ /* slices in the array (Points to the first valid grpc_slice in the array) */
97
114
  grpc_slice *slices;
98
115
  /* the number of slices in the array */
99
116
  size_t count;
100
- /* the number of slices allocated in the array */
117
+ /* the number of slices allocated in the array. External users (i.e any code
118
+ * outside grpc core) MUST NOT use this field */
101
119
  size_t capacity;
102
120
  /* the combined length of all slices in the array */
103
121
  size_t length;
@@ -52,6 +52,10 @@
52
52
  provides no memory barriers.
53
53
  */
54
54
 
55
+ #ifdef __cplusplus
56
+ extern "C" {
57
+ #endif
58
+
55
59
  /* Platform-specific type declarations of gpr_mu and gpr_cv. */
56
60
  #include <grpc/impl/codegen/port_platform.h>
57
61
  #include <grpc/impl/codegen/sync_generic.h>
@@ -64,4 +68,8 @@
64
68
  #error Unable to determine platform for sync
65
69
  #endif
66
70
 
71
+ #ifdef __cplusplus
72
+ }
73
+ #endif
74
+
67
75
  #endif /* GRPC_IMPL_CODEGEN_SYNC_H */
@@ -0,0 +1,63 @@
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
+ #ifndef GRPC_LOAD_REPORTING_H
35
+ #define GRPC_LOAD_REPORTING_H
36
+
37
+ #include <grpc/impl/codegen/port_platform.h>
38
+ #include <grpc/slice.h>
39
+
40
+ #ifdef __cplusplus
41
+ extern "C" {
42
+ #endif
43
+
44
+ /** Metadata key for the gRPC LB load balancer token.
45
+ *
46
+ * The value corresponding to this key is an opaque token that is given to the
47
+ * frontend as part of each pick; the frontend sends this token to the backend
48
+ * in each request it sends when using that pick. The token is used by the
49
+ * backend to verify the request and to allow the backend to report load to the
50
+ * gRPC LB system. */
51
+ #define GRPC_LB_TOKEN_MD_KEY "lb-token"
52
+
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;
58
+
59
+ #ifdef __cplusplus
60
+ }
61
+ #endif
62
+
63
+ #endif /* GRPC_LOAD_REPORTING_H */
@@ -76,6 +76,12 @@ GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len,
76
76
  Aborts if malloc() fails. */
77
77
  GPRAPI grpc_slice grpc_slice_malloc(size_t length);
78
78
 
79
+ /* Intern a slice:
80
+
81
+ The return value for two invocations of this function with the same sequence
82
+ of bytes is a slice which points to the same memory. */
83
+ GPRAPI grpc_slice grpc_slice_intern(grpc_slice slice);
84
+
79
85
  /* Create a slice by copying a string.
80
86
  Does not preserve null terminators.
81
87
  Equivalent to:
@@ -93,6 +99,9 @@ GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len);
93
99
  /* Create a slice pointing to constant memory */
94
100
  GPRAPI grpc_slice grpc_slice_from_static_string(const char *source);
95
101
 
102
+ /* Create a slice pointing to constant memory */
103
+ GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len);
104
+
96
105
  /* Return a result slice derived from s, which shares a ref count with s, where
97
106
  result.data==s.data+begin, and result.length==end-begin.
98
107
  The ref count of s is increased by one.
@@ -113,18 +122,45 @@ GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split);
113
122
  Requires s intialized, split <= s.length */
114
123
  GPRAPI grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split);
115
124
 
116
- GPRAPI grpc_slice gpr_empty_slice(void);
125
+ GPRAPI grpc_slice grpc_empty_slice(void);
126
+
127
+ GPRAPI uint32_t grpc_slice_default_hash_impl(grpc_slice s);
128
+ GPRAPI int grpc_slice_default_eq_impl(grpc_slice a, grpc_slice b);
129
+
130
+ GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b);
117
131
 
118
132
  /* Returns <0 if a < b, ==0 if a == b, >0 if a > b
119
133
  The order is arbitrary, and is not guaranteed to be stable across different
120
134
  versions of the API. */
121
135
  GPRAPI int grpc_slice_cmp(grpc_slice a, grpc_slice b);
122
136
  GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char *b);
137
+ GPRAPI int grpc_slice_buf_cmp(grpc_slice a, const void *b, size_t blen);
138
+
139
+ /* return non-zero if the first blen bytes of a are equal to b */
140
+ GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void *b, size_t blen);
141
+
142
+ /* return the index of the last instance of \a c in \a s, or -1 if not found */
143
+ GPRAPI int grpc_slice_rchr(grpc_slice s, char c);
144
+ GPRAPI int grpc_slice_chr(grpc_slice s, char c);
145
+
146
+ /* return the index of the first occurance of \a needle in \a haystack, or -1 if
147
+ * it's not found */
148
+ GPRAPI int grpc_slice_slice(grpc_slice haystack, grpc_slice needle);
149
+
150
+ GPRAPI uint32_t grpc_slice_hash(grpc_slice s);
123
151
 
124
152
  /* Do two slices point at the same memory, with the same length
125
153
  If a or b is inlined, actually compares data */
126
154
  GPRAPI int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b);
127
155
 
156
+ /* Return a slice pointing to newly allocated memory that has the same contents
157
+ * as \a s */
158
+ GPRAPI grpc_slice grpc_slice_dup(grpc_slice a);
159
+
160
+ /* Return a copy of slice as a C string. Offers no protection against embedded
161
+ NULL's. Returned string must be freed with gpr_free. */
162
+ GPRAPI char *grpc_slice_to_c_string(grpc_slice s);
163
+
128
164
  #ifdef __cplusplus
129
165
  }
130
166
  #endif
@@ -77,8 +77,15 @@ GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n,
77
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) */
81
+ GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
82
+ grpc_slice_buffer *src,
83
+ size_t n, void *dst);
80
84
  /* take the first slice in the slice buffer */
81
85
  GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src);
86
+ /* undo the above with (a possibly different) \a slice */
87
+ GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *src,
88
+ grpc_slice slice);
82
89
 
83
90
  #ifdef __cplusplus
84
91
  }
@@ -44,6 +44,7 @@ extern "C" {
44
44
 
45
45
  typedef struct gpr_allocation_functions {
46
46
  void *(*malloc_fn)(size_t size);
47
+ void *(*zalloc_fn)(size_t size); /* if NULL, uses malloc_fn then memset */
47
48
  void *(*realloc_fn)(void *ptr, size_t size);
48
49
  void (*free_fn)(void *ptr);
49
50
  } gpr_allocation_functions;
@@ -54,6 +55,8 @@ typedef struct gpr_allocation_functions {
54
55
  * contain.
55
56
  */
56
57
  GPRAPI void *gpr_malloc(size_t size);
58
+ /* like malloc, but zero all bytes before returning them */
59
+ GPRAPI void *gpr_zalloc(size_t size);
57
60
  /* free */
58
61
  GPRAPI void gpr_free(void *ptr);
59
62
  /* realloc, never returns NULL */
@@ -74,4 +74,7 @@
74
74
 
75
75
  #define GPR_ICMP(a, b) ((a) < (b) ? -1 : ((a) > (b) ? 1 : 0))
76
76
 
77
+ #define GPR_HASH_POINTER(x, range) \
78
+ ((((size_t)x) >> 4) ^ (((size_t)x) >> 9) ^ (((size_t)x) >> 14)) % (range)
79
+
77
80
  #endif /* GRPC_SUPPORT_USEFUL_H */
@@ -292,4 +292,4 @@ extern const pb_field_t google_census_Metric_fields[5];
292
292
  } /* extern "C" */
293
293
  #endif
294
294
 
295
- #endif
295
+ #endif /* GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  *
3
- * Copyright 2016, Google Inc.
3
+ * Copyright 2017, Google Inc.
4
4
  * All rights reserved.
5
5
  *
6
6
  * Redistribution and use in source and binary forms, with or without
@@ -31,51 +31,24 @@
31
31
  *
32
32
  */
33
33
  /* Automatically generated nanopb constant definitions */
34
- /* Generated by nanopb-0.3.5-dev */
34
+ /* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */
35
35
 
36
36
  #include "src/core/ext/census/gen/trace_context.pb.h"
37
37
 
38
+ /* @@protoc_insertion_point(includes) */
38
39
  #if PB_PROTO_HEADER_VERSION != 30
39
40
  #error Regenerate this file with the current version of nanopb generator.
40
41
  #endif
41
42
 
42
43
 
43
44
 
44
- const pb_field_t google_trace_TraceId_fields[3] = {
45
- PB_FIELD( 1, FIXED64 , OPTIONAL, STATIC , FIRST, google_trace_TraceId, hi, hi, 0),
46
- PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceId, lo, hi, 0),
45
+ const pb_field_t google_trace_TraceContext_fields[5] = {
46
+ PB_FIELD( 1, FIXED64 , OPTIONAL, STATIC , FIRST, google_trace_TraceContext, trace_id_hi, trace_id_hi, 0),
47
+ PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, trace_id_lo, trace_id_hi, 0),
48
+ PB_FIELD( 3, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_id, trace_id_lo, 0),
49
+ PB_FIELD( 4, FIXED32 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_options, span_id, 0),
47
50
  PB_LAST_FIELD
48
51
  };
49
52
 
50
- const pb_field_t google_trace_TraceContext_fields[4] = {
51
- PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, google_trace_TraceContext, trace_id, trace_id, &google_trace_TraceId_fields),
52
- PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_id, trace_id, 0),
53
- PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, is_sampled, span_id, 0),
54
- PB_LAST_FIELD
55
- };
56
-
57
-
58
- /* Check that field information fits in pb_field_t */
59
- #if !defined(PB_FIELD_32BIT)
60
- /* If you get an error here, it means that you need to define PB_FIELD_32BIT
61
- * compile-time option. You can do that in pb.h or on compiler command line.
62
- *
63
- * The reason you need to do this is that some of your messages contain tag
64
- * numbers or field sizes that are larger than what can fit in 8 or 16 bit
65
- * field descriptors.
66
- */
67
- PB_STATIC_ASSERT((pb_membersize(google_trace_TraceContext, trace_id) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_trace_TraceId_google_trace_TraceContext)
68
- #endif
69
-
70
- #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
71
- /* If you get an error here, it means that you need to define PB_FIELD_16BIT
72
- * compile-time option. You can do that in pb.h or on compiler command line.
73
- *
74
- * The reason you need to do this is that some of your messages contain tag
75
- * numbers or field sizes that are larger than what can fit in the default
76
- * 8 bit descriptors.
77
- */
78
- PB_STATIC_ASSERT((pb_membersize(google_trace_TraceContext, trace_id) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_trace_TraceId_google_trace_TraceContext)
79
- #endif
80
-
81
53
 
54
+ /* @@protoc_insertion_point(eof) */