grpc 0.14.1 → 0.15.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 (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1398 -817
  3. data/include/grpc/compression.h +2 -1
  4. data/include/grpc/grpc.h +10 -1
  5. data/include/grpc/grpc_cronet.h +51 -0
  6. data/include/grpc/grpc_posix.h +70 -0
  7. data/include/grpc/impl/codegen/atm.h +2 -2
  8. data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
  9. data/include/grpc/impl/codegen/compression_types.h +39 -5
  10. data/include/grpc/impl/codegen/connectivity_state.h +1 -1
  11. data/include/grpc/impl/codegen/grpc_types.h +10 -0
  12. data/include/grpc/impl/codegen/log.h +2 -1
  13. data/include/grpc/impl/codegen/port_platform.h +30 -12
  14. data/include/grpc/impl/codegen/slice_buffer.h +2 -3
  15. data/include/grpc/impl/codegen/sync.h +2 -2
  16. data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
  17. data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
  18. data/include/grpc/support/avl.h +5 -0
  19. data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
  20. data/include/grpc/support/string_util.h +2 -1
  21. data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
  22. data/src/core/ext/census/gen/census.pb.c +179 -0
  23. data/src/core/ext/census/gen/census.pb.h +294 -0
  24. data/src/core/ext/census/grpc_filter.c +11 -7
  25. data/src/core/ext/client_config/channel_connectivity.c +28 -14
  26. data/src/core/ext/client_config/client_channel.c +77 -53
  27. data/src/core/ext/client_config/connector.h +1 -1
  28. data/src/core/ext/client_config/lb_policy.c +9 -6
  29. data/src/core/ext/client_config/lb_policy.h +9 -5
  30. data/src/core/ext/client_config/subchannel.c +58 -39
  31. data/src/core/ext/client_config/subchannel.h +3 -2
  32. data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
  33. data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
  34. data/src/core/ext/client_config/subchannel_index.c +20 -9
  35. data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
  36. data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
  37. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
  38. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
  39. data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
  40. data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
  41. data/src/core/ext/load_reporting/load_reporting.c +133 -0
  42. data/src/core/ext/load_reporting/load_reporting.h +75 -0
  43. data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
  44. data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
  45. data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
  46. data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
  47. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
  48. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
  49. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
  50. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
  51. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
  52. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
  53. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
  54. data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
  55. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
  56. data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
  57. data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
  58. data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
  59. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
  60. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
  62. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
  63. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
  64. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
  65. data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
  66. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
  67. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
  68. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
  69. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
  70. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
  71. data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
  72. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
  73. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
  74. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
  75. data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
  76. data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
  77. data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
  78. data/src/core/lib/channel/channel_args.c +26 -12
  79. data/src/core/lib/channel/channel_args.h +1 -1
  80. data/src/core/lib/channel/channel_stack.c +12 -8
  81. data/src/core/lib/channel/channel_stack.h +27 -11
  82. data/src/core/lib/channel/channel_stack_builder.c +2 -2
  83. data/src/core/lib/channel/compress_filter.c +26 -31
  84. data/src/core/lib/channel/compress_filter.h +4 -4
  85. data/src/core/lib/channel/connected_channel.c +7 -5
  86. data/src/core/lib/channel/http_client_filter.c +34 -8
  87. data/src/core/lib/channel/http_client_filter.h +1 -1
  88. data/src/core/lib/channel/http_server_filter.c +21 -12
  89. data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
  90. data/src/core/lib/http/httpcli.c +81 -59
  91. data/src/core/lib/http/httpcli.h +11 -15
  92. data/src/core/lib/http/httpcli_security_connector.c +5 -3
  93. data/src/core/lib/http/parser.c +127 -118
  94. data/src/core/lib/http/parser.h +11 -6
  95. data/src/core/lib/iomgr/closure.c +20 -16
  96. data/src/core/lib/iomgr/closure.h +19 -15
  97. data/src/core/lib/iomgr/endpoint.h +1 -1
  98. data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
  99. data/src/core/lib/iomgr/error.c +535 -0
  100. data/src/core/lib/iomgr/error.h +192 -0
  101. data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
  102. data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
  103. data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
  104. data/src/core/lib/iomgr/ev_posix.c +104 -14
  105. data/src/core/lib/iomgr/ev_posix.h +17 -7
  106. data/src/core/lib/iomgr/exec_ctx.c +25 -7
  107. data/src/core/lib/iomgr/exec_ctx.h +27 -8
  108. data/src/core/lib/iomgr/executor.c +2 -2
  109. data/src/core/lib/iomgr/executor.h +1 -1
  110. data/src/core/lib/iomgr/iocp_windows.c +2 -41
  111. data/src/core/lib/iomgr/iocp_windows.h +0 -8
  112. data/src/core/lib/iomgr/iomgr.c +5 -4
  113. data/src/core/lib/iomgr/iomgr_posix.c +5 -1
  114. data/src/core/lib/iomgr/iomgr_windows.c +1 -1
  115. data/src/core/lib/{support → iomgr}/load_file.c +15 -17
  116. data/src/core/lib/{support → iomgr}/load_file.h +8 -7
  117. data/src/core/lib/iomgr/polling_entity.c +104 -0
  118. data/src/core/lib/iomgr/polling_entity.h +81 -0
  119. data/src/core/lib/iomgr/pollset.h +6 -5
  120. data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
  121. data/src/core/lib/iomgr/pollset_windows.c +10 -6
  122. data/src/core/lib/iomgr/resolve_address.h +5 -9
  123. data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
  124. data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
  125. data/src/core/lib/iomgr/sockaddr.h +2 -2
  126. data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
  127. data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
  128. data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
  129. data/src/core/lib/iomgr/socket_windows.c +61 -2
  130. data/src/core/lib/iomgr/socket_windows.h +13 -0
  131. data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
  132. data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
  133. data/src/core/lib/iomgr/tcp_posix.c +43 -39
  134. data/src/core/lib/iomgr/tcp_server.h +5 -3
  135. data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
  136. data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
  137. data/src/core/lib/iomgr/tcp_windows.c +45 -50
  138. data/src/core/lib/iomgr/tcp_windows.h +1 -1
  139. data/src/core/lib/iomgr/timer.c +26 -13
  140. data/src/core/lib/iomgr/udp_server.c +28 -4
  141. data/src/core/lib/iomgr/udp_server.h +5 -1
  142. data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
  143. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
  144. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
  145. data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
  146. data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
  147. data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
  148. data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
  149. data/src/core/lib/iomgr/workqueue.h +5 -4
  150. data/src/core/lib/iomgr/workqueue_posix.c +40 -26
  151. data/src/core/lib/iomgr/workqueue_windows.c +2 -2
  152. data/src/core/lib/profiling/basic_timers.c +2 -2
  153. data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
  154. data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
  155. data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
  156. data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
  157. data/src/core/lib/security/credentials/credentials.c +233 -0
  158. data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
  159. data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
  160. data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
  161. data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
  162. data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
  163. data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
  164. data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
  166. data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
  167. data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
  168. data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
  169. data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
  170. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
  171. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
  172. data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
  173. data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
  174. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
  175. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
  176. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
  177. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
  178. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
  179. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
  180. data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
  181. data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
  182. data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
  183. data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
  184. data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
  185. data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
  186. data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
  187. data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
  188. data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
  189. data/src/core/lib/security/transport/tsi_error.c +40 -0
  190. data/src/core/lib/security/transport/tsi_error.h +42 -0
  191. data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
  192. data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
  193. data/src/core/lib/security/util/json_util.c +61 -0
  194. data/src/core/lib/security/util/json_util.h +55 -0
  195. data/src/core/lib/support/avl.c +11 -0
  196. data/src/core/lib/support/cpu_windows.c +2 -2
  197. data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
  198. data/src/core/lib/support/log.c +3 -1
  199. data/src/core/lib/support/log_linux.c +2 -2
  200. data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
  201. data/src/core/lib/support/murmur_hash.c +3 -5
  202. data/src/core/lib/support/string.c +10 -0
  203. data/src/core/lib/support/string.h +4 -0
  204. data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
  205. data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
  206. data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
  207. data/src/core/lib/support/subprocess_windows.c +1 -1
  208. data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
  209. data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
  210. data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
  211. data/src/core/lib/support/tmpfile_msys.c +1 -1
  212. data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
  213. data/src/core/lib/surface/alarm.c +2 -2
  214. data/src/core/lib/surface/byte_buffer_reader.c +13 -6
  215. data/src/core/lib/surface/call.c +323 -123
  216. data/src/core/lib/surface/call.h +2 -0
  217. data/src/core/lib/surface/call_log_batch.c +1 -1
  218. data/src/core/lib/surface/channel.c +64 -15
  219. data/src/core/lib/surface/channel.h +9 -0
  220. data/src/core/lib/surface/channel_ping.c +3 -3
  221. data/src/core/lib/surface/completion_queue.c +75 -19
  222. data/src/core/lib/surface/completion_queue.h +7 -2
  223. data/src/core/lib/surface/init.c +2 -1
  224. data/src/core/lib/surface/init_secure.c +4 -4
  225. data/src/core/lib/surface/lame_client.c +12 -8
  226. data/src/core/lib/surface/server.c +213 -120
  227. data/src/core/lib/surface/server.h +1 -0
  228. data/src/core/lib/surface/version.c +1 -1
  229. data/src/core/lib/transport/connectivity_state.c +40 -18
  230. data/src/core/lib/transport/connectivity_state.h +4 -1
  231. data/src/core/lib/transport/metadata.c +23 -23
  232. data/src/core/lib/transport/metadata.h +4 -0
  233. data/src/core/lib/transport/metadata_batch.c +9 -0
  234. data/src/core/lib/transport/metadata_batch.h +3 -0
  235. data/src/core/lib/transport/static_metadata.c +6 -5
  236. data/src/core/lib/transport/static_metadata.h +64 -60
  237. data/src/core/lib/transport/transport.c +24 -12
  238. data/src/core/lib/transport/transport.h +6 -5
  239. data/src/core/lib/transport/transport_impl.h +4 -0
  240. data/src/core/lib/transport/transport_op_string.c +2 -2
  241. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
  242. data/src/ruby/bin/math_services.rb +41 -2
  243. data/src/ruby/ext/grpc/rb_call.c +42 -40
  244. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  245. data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
  246. data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
  247. data/src/ruby/ext/grpc/rb_grpc.c +1 -3
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
  249. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
  250. data/src/ruby/ext/grpc/rb_loader.c +1 -1
  251. data/src/ruby/ext/grpc/rb_server.c +5 -3
  252. data/src/ruby/lib/grpc.rb +0 -3
  253. data/src/ruby/lib/grpc/errors.rb +3 -2
  254. data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
  255. data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
  256. data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
  257. data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
  258. data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
  259. data/src/ruby/lib/grpc/generic/service.rb +8 -8
  260. data/src/ruby/lib/grpc/version.rb +1 -1
  261. data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
  262. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
  263. data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
  264. data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
  265. data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
  266. data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
  267. data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
  268. data/src/ruby/pb/test/client.rb +5 -2
  269. data/src/ruby/spec/generic/active_call_spec.rb +3 -2
  270. data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
  271. data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
  272. data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
  273. data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
  274. metadata +86 -48
  275. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
  276. data/src/core/lib/security/credentials.c +0 -1296
  277. data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -37,13 +37,7 @@
37
37
  #include <grpc/support/port_platform.h>
38
38
  #include <grpc/support/slice.h>
39
39
 
40
- /* Common definitions for frame handling in the chttp2 transport */
41
-
42
- typedef enum {
43
- GRPC_CHTTP2_PARSE_OK,
44
- GRPC_CHTTP2_STREAM_ERROR,
45
- GRPC_CHTTP2_CONNECTION_ERROR
46
- } grpc_chttp2_parse_error;
40
+ #include "src/core/lib/iomgr/error.h"
47
41
 
48
42
  /* defined in internal.h */
49
43
  typedef struct grpc_chttp2_stream_parsing grpc_chttp2_stream_parsing;
@@ -37,24 +37,25 @@
37
37
 
38
38
  #include <grpc/support/alloc.h>
39
39
  #include <grpc/support/log.h>
40
+ #include <grpc/support/string_util.h>
40
41
  #include <grpc/support/useful.h>
41
42
  #include "src/core/ext/transport/chttp2/transport/internal.h"
42
43
  #include "src/core/lib/support/string.h"
43
44
  #include "src/core/lib/transport/transport.h"
44
45
 
45
- grpc_chttp2_parse_error grpc_chttp2_data_parser_init(
46
- grpc_chttp2_data_parser *parser) {
46
+ grpc_error *grpc_chttp2_data_parser_init(grpc_chttp2_data_parser *parser) {
47
47
  parser->state = GRPC_CHTTP2_DATA_FH_0;
48
48
  parser->parsing_frame = NULL;
49
- return GRPC_CHTTP2_PARSE_OK;
49
+ return GRPC_ERROR_NONE;
50
50
  }
51
51
 
52
52
  void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
53
53
  grpc_chttp2_data_parser *parser) {
54
54
  grpc_byte_stream *bs;
55
55
  if (parser->parsing_frame) {
56
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, parser->parsing_frame,
57
- 0, 1);
56
+ grpc_chttp2_incoming_byte_stream_finished(
57
+ exec_ctx, parser->parsing_frame, GRPC_ERROR_CREATE("Parser destroyed"),
58
+ 1);
58
59
  }
59
60
  while (
60
61
  (bs = grpc_chttp2_incoming_frame_queue_pop(&parser->incoming_frames))) {
@@ -62,11 +63,16 @@ void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
62
63
  }
63
64
  }
64
65
 
65
- grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
66
- grpc_chttp2_data_parser *parser, uint8_t flags) {
66
+ grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
67
+ uint8_t flags,
68
+ uint32_t stream_id) {
67
69
  if (flags & ~GRPC_CHTTP2_DATA_FLAG_END_STREAM) {
68
- gpr_log(GPR_ERROR, "unsupported data flags: 0x%02x", flags);
69
- return GRPC_CHTTP2_STREAM_ERROR;
70
+ char *msg;
71
+ gpr_asprintf(&msg, "unsupported data flags: 0x%02x", flags);
72
+ grpc_error *err = grpc_error_set_int(
73
+ GRPC_ERROR_CREATE(msg), GRPC_ERROR_INT_STREAM_ID, (intptr_t)stream_id);
74
+ gpr_free(msg);
75
+ return err;
70
76
  }
71
77
 
72
78
  if (flags & GRPC_CHTTP2_DATA_FLAG_END_STREAM) {
@@ -75,7 +81,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
75
81
  parser->is_last_frame = 0;
76
82
  }
77
83
 
78
- return GRPC_CHTTP2_PARSE_OK;
84
+ return GRPC_ERROR_NONE;
79
85
  }
80
86
 
81
87
  void grpc_chttp2_incoming_frame_queue_merge(
@@ -139,7 +145,7 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
139
145
  stats->data_bytes += write_bytes;
140
146
  }
141
147
 
142
- grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
148
+ grpc_error *grpc_chttp2_data_parser_parse(
143
149
  grpc_exec_ctx *exec_ctx, void *parser,
144
150
  grpc_chttp2_transport_parsing *transport_parsing,
145
151
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
@@ -149,19 +155,20 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
149
155
  grpc_chttp2_data_parser *p = parser;
150
156
  uint32_t message_flags;
151
157
  grpc_chttp2_incoming_byte_stream *incoming_byte_stream;
158
+ char *msg;
152
159
 
153
160
  if (is_last && p->is_last_frame) {
154
161
  stream_parsing->received_close = 1;
155
162
  }
156
163
 
157
164
  if (cur == end) {
158
- return GRPC_CHTTP2_PARSE_OK;
165
+ return GRPC_ERROR_NONE;
159
166
  }
160
167
 
161
168
  switch (p->state) {
162
169
  case GRPC_CHTTP2_DATA_ERROR:
163
170
  p->state = GRPC_CHTTP2_DATA_ERROR;
164
- return GRPC_CHTTP2_STREAM_ERROR;
171
+ return GRPC_ERROR_REF(p->error);
165
172
  fh_0:
166
173
  case GRPC_CHTTP2_DATA_FH_0:
167
174
  stream_parsing->stats.incoming.framing_bytes++;
@@ -174,13 +181,23 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
174
181
  p->is_frame_compressed = 1; /* GPR_TRUE */
175
182
  break;
176
183
  default:
177
- gpr_log(GPR_ERROR, "Bad GRPC frame type 0x%02x", p->frame_type);
184
+ gpr_asprintf(&msg, "Bad GRPC frame type 0x%02x", p->frame_type);
185
+ p->error = GRPC_ERROR_CREATE(msg);
186
+ p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID,
187
+ (intptr_t)stream_parsing->id);
188
+ gpr_free(msg);
189
+ msg = gpr_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
190
+ p->error =
191
+ grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES, msg);
192
+ gpr_free(msg);
193
+ p->error =
194
+ grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg);
178
195
  p->state = GRPC_CHTTP2_DATA_ERROR;
179
- return GRPC_CHTTP2_STREAM_ERROR;
196
+ return GRPC_ERROR_REF(p->error);
180
197
  }
181
198
  if (++cur == end) {
182
199
  p->state = GRPC_CHTTP2_DATA_FH_1;
183
- return GRPC_CHTTP2_PARSE_OK;
200
+ return GRPC_ERROR_NONE;
184
201
  }
185
202
  /* fallthrough */
186
203
  case GRPC_CHTTP2_DATA_FH_1:
@@ -188,7 +205,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
188
205
  p->frame_size = ((uint32_t)*cur) << 24;
189
206
  if (++cur == end) {
190
207
  p->state = GRPC_CHTTP2_DATA_FH_2;
191
- return GRPC_CHTTP2_PARSE_OK;
208
+ return GRPC_ERROR_NONE;
192
209
  }
193
210
  /* fallthrough */
194
211
  case GRPC_CHTTP2_DATA_FH_2:
@@ -196,7 +213,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
196
213
  p->frame_size |= ((uint32_t)*cur) << 16;
197
214
  if (++cur == end) {
198
215
  p->state = GRPC_CHTTP2_DATA_FH_3;
199
- return GRPC_CHTTP2_PARSE_OK;
216
+ return GRPC_ERROR_NONE;
200
217
  }
201
218
  /* fallthrough */
202
219
  case GRPC_CHTTP2_DATA_FH_3:
@@ -204,7 +221,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
204
221
  p->frame_size |= ((uint32_t)*cur) << 8;
205
222
  if (++cur == end) {
206
223
  p->state = GRPC_CHTTP2_DATA_FH_4;
207
- return GRPC_CHTTP2_PARSE_OK;
224
+ return GRPC_ERROR_NONE;
208
225
  }
209
226
  /* fallthrough */
210
227
  case GRPC_CHTTP2_DATA_FH_4:
@@ -225,7 +242,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
225
242
  grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
226
243
  stream_parsing);
227
244
  if (cur == end) {
228
- return GRPC_CHTTP2_PARSE_OK;
245
+ return GRPC_ERROR_NONE;
229
246
  }
230
247
  uint32_t remaining = (uint32_t)(end - cur);
231
248
  if (remaining == p->frame_size) {
@@ -233,19 +250,19 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
233
250
  grpc_chttp2_incoming_byte_stream_push(
234
251
  exec_ctx, p->parsing_frame,
235
252
  gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
236
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, 1,
237
- 1);
253
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame,
254
+ GRPC_ERROR_NONE, 1);
238
255
  p->parsing_frame = NULL;
239
256
  p->state = GRPC_CHTTP2_DATA_FH_0;
240
- return GRPC_CHTTP2_PARSE_OK;
257
+ return GRPC_ERROR_NONE;
241
258
  } else if (remaining > p->frame_size) {
242
259
  stream_parsing->stats.incoming.data_bytes += p->frame_size;
243
260
  grpc_chttp2_incoming_byte_stream_push(
244
261
  exec_ctx, p->parsing_frame,
245
262
  gpr_slice_sub(slice, (size_t)(cur - beg),
246
263
  (size_t)(cur + p->frame_size - beg)));
247
- grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, 1,
248
- 1);
264
+ grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame,
265
+ GRPC_ERROR_NONE, 1);
249
266
  p->parsing_frame = NULL;
250
267
  cur += p->frame_size;
251
268
  goto fh_0; /* loop */
@@ -256,9 +273,9 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
256
273
  gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
257
274
  p->frame_size -= remaining;
258
275
  stream_parsing->stats.incoming.data_bytes += remaining;
259
- return GRPC_CHTTP2_PARSE_OK;
276
+ return GRPC_ERROR_NONE;
260
277
  }
261
278
  }
262
279
 
263
- GPR_UNREACHABLE_CODE(return GRPC_CHTTP2_CONNECTION_ERROR);
280
+ GPR_UNREACHABLE_CODE(return GRPC_ERROR_CREATE("Should never reach here"));
264
281
  }
@@ -66,6 +66,7 @@ typedef struct {
66
66
  uint8_t is_last_frame;
67
67
  uint8_t frame_type;
68
68
  uint32_t frame_size;
69
+ grpc_error *error;
69
70
 
70
71
  int is_frame_compressed;
71
72
  grpc_chttp2_incoming_frame_queue incoming_frames;
@@ -79,19 +80,19 @@ grpc_byte_stream *grpc_chttp2_incoming_frame_queue_pop(
79
80
  grpc_chttp2_incoming_frame_queue *q);
80
81
 
81
82
  /* initialize per-stream state for data frame parsing */
82
- grpc_chttp2_parse_error grpc_chttp2_data_parser_init(
83
- grpc_chttp2_data_parser *parser);
83
+ grpc_error *grpc_chttp2_data_parser_init(grpc_chttp2_data_parser *parser);
84
84
 
85
85
  void grpc_chttp2_data_parser_destroy(grpc_exec_ctx *exec_ctx,
86
86
  grpc_chttp2_data_parser *parser);
87
87
 
88
88
  /* start processing a new data frame */
89
- grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
90
- grpc_chttp2_data_parser *parser, uint8_t flags);
89
+ grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser,
90
+ uint8_t flags,
91
+ uint32_t stream_id);
91
92
 
92
93
  /* handle a slice of a data frame - is_last indicates the last slice of a
93
94
  frame */
94
- grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
95
+ grpc_error *grpc_chttp2_data_parser_parse(
95
96
  grpc_exec_ctx *exec_ctx, void *parser,
96
97
  grpc_chttp2_transport_parsing *transport_parsing,
97
98
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
@@ -38,6 +38,7 @@
38
38
 
39
39
  #include <grpc/support/alloc.h>
40
40
  #include <grpc/support/log.h>
41
+ #include <grpc/support/string_util.h>
41
42
 
42
43
  void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p) {
43
44
  p->debug_data = NULL;
@@ -47,11 +48,15 @@ void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p) {
47
48
  gpr_free(p->debug_data);
48
49
  }
49
50
 
50
- grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
51
- grpc_chttp2_goaway_parser *p, uint32_t length, uint8_t flags) {
51
+ grpc_error *grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser *p,
52
+ uint32_t length,
53
+ uint8_t flags) {
52
54
  if (length < 8) {
53
- gpr_log(GPR_ERROR, "goaway frame too short (%d bytes)", length);
54
- return GRPC_CHTTP2_CONNECTION_ERROR;
55
+ char *msg;
56
+ gpr_asprintf(&msg, "goaway frame too short (%d bytes)", length);
57
+ grpc_error *err = GRPC_ERROR_CREATE(msg);
58
+ gpr_free(msg);
59
+ return err;
55
60
  }
56
61
 
57
62
  gpr_free(p->debug_data);
@@ -59,10 +64,10 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
59
64
  p->debug_data = gpr_malloc(p->debug_length);
60
65
  p->debug_pos = 0;
61
66
  p->state = GRPC_CHTTP2_GOAWAY_LSI0;
62
- return GRPC_CHTTP2_PARSE_OK;
67
+ return GRPC_ERROR_NONE;
63
68
  }
64
69
 
65
- grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
70
+ grpc_error *grpc_chttp2_goaway_parser_parse(
66
71
  grpc_exec_ctx *exec_ctx, void *parser,
67
72
  grpc_chttp2_transport_parsing *transport_parsing,
68
73
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
@@ -75,7 +80,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
75
80
  case GRPC_CHTTP2_GOAWAY_LSI0:
76
81
  if (cur == end) {
77
82
  p->state = GRPC_CHTTP2_GOAWAY_LSI0;
78
- return GRPC_CHTTP2_PARSE_OK;
83
+ return GRPC_ERROR_NONE;
79
84
  }
80
85
  p->last_stream_id = ((uint32_t)*cur) << 24;
81
86
  ++cur;
@@ -83,7 +88,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
83
88
  case GRPC_CHTTP2_GOAWAY_LSI1:
84
89
  if (cur == end) {
85
90
  p->state = GRPC_CHTTP2_GOAWAY_LSI1;
86
- return GRPC_CHTTP2_PARSE_OK;
91
+ return GRPC_ERROR_NONE;
87
92
  }
88
93
  p->last_stream_id |= ((uint32_t)*cur) << 16;
89
94
  ++cur;
@@ -91,7 +96,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
91
96
  case GRPC_CHTTP2_GOAWAY_LSI2:
92
97
  if (cur == end) {
93
98
  p->state = GRPC_CHTTP2_GOAWAY_LSI2;
94
- return GRPC_CHTTP2_PARSE_OK;
99
+ return GRPC_ERROR_NONE;
95
100
  }
96
101
  p->last_stream_id |= ((uint32_t)*cur) << 8;
97
102
  ++cur;
@@ -99,7 +104,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
99
104
  case GRPC_CHTTP2_GOAWAY_LSI3:
100
105
  if (cur == end) {
101
106
  p->state = GRPC_CHTTP2_GOAWAY_LSI3;
102
- return GRPC_CHTTP2_PARSE_OK;
107
+ return GRPC_ERROR_NONE;
103
108
  }
104
109
  p->last_stream_id |= ((uint32_t)*cur);
105
110
  ++cur;
@@ -107,7 +112,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
107
112
  case GRPC_CHTTP2_GOAWAY_ERR0:
108
113
  if (cur == end) {
109
114
  p->state = GRPC_CHTTP2_GOAWAY_ERR0;
110
- return GRPC_CHTTP2_PARSE_OK;
115
+ return GRPC_ERROR_NONE;
111
116
  }
112
117
  p->error_code = ((uint32_t)*cur) << 24;
113
118
  ++cur;
@@ -115,7 +120,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
115
120
  case GRPC_CHTTP2_GOAWAY_ERR1:
116
121
  if (cur == end) {
117
122
  p->state = GRPC_CHTTP2_GOAWAY_ERR1;
118
- return GRPC_CHTTP2_PARSE_OK;
123
+ return GRPC_ERROR_NONE;
119
124
  }
120
125
  p->error_code |= ((uint32_t)*cur) << 16;
121
126
  ++cur;
@@ -123,7 +128,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
123
128
  case GRPC_CHTTP2_GOAWAY_ERR2:
124
129
  if (cur == end) {
125
130
  p->state = GRPC_CHTTP2_GOAWAY_ERR2;
126
- return GRPC_CHTTP2_PARSE_OK;
131
+ return GRPC_ERROR_NONE;
127
132
  }
128
133
  p->error_code |= ((uint32_t)*cur) << 8;
129
134
  ++cur;
@@ -131,13 +136,14 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
131
136
  case GRPC_CHTTP2_GOAWAY_ERR3:
132
137
  if (cur == end) {
133
138
  p->state = GRPC_CHTTP2_GOAWAY_ERR3;
134
- return GRPC_CHTTP2_PARSE_OK;
139
+ return GRPC_ERROR_NONE;
135
140
  }
136
141
  p->error_code |= ((uint32_t)*cur);
137
142
  ++cur;
138
143
  /* fallthrough */
139
144
  case GRPC_CHTTP2_GOAWAY_DEBUG:
140
- memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
145
+ if (end != cur)
146
+ memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
141
147
  GPR_ASSERT((size_t)(end - cur) < UINT32_MAX - p->debug_pos);
142
148
  p->debug_pos += (uint32_t)(end - cur);
143
149
  p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
@@ -150,9 +156,9 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
150
156
  gpr_slice_new(p->debug_data, p->debug_length, gpr_free);
151
157
  p->debug_data = NULL;
152
158
  }
153
- return GRPC_CHTTP2_PARSE_OK;
159
+ return GRPC_ERROR_NONE;
154
160
  }
155
- GPR_UNREACHABLE_CODE(return GRPC_CHTTP2_CONNECTION_ERROR);
161
+ GPR_UNREACHABLE_CODE(return GRPC_ERROR_CREATE("Should never reach here"));
156
162
  }
157
163
 
158
164
  void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
@@ -63,9 +63,9 @@ typedef struct {
63
63
 
64
64
  void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser *p);
65
65
  void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p);
66
- grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
66
+ grpc_error *grpc_chttp2_goaway_parser_begin_frame(
67
67
  grpc_chttp2_goaway_parser *parser, uint32_t length, uint8_t flags);
68
- grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
68
+ grpc_error *grpc_chttp2_goaway_parser_parse(
69
69
  grpc_exec_ctx *exec_ctx, void *parser,
70
70
  grpc_chttp2_transport_parsing *transport_parsing,
71
71
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
@@ -38,6 +38,7 @@
38
38
 
39
39
  #include <grpc/support/alloc.h>
40
40
  #include <grpc/support/log.h>
41
+ #include <grpc/support/string_util.h>
41
42
 
42
43
  gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) {
43
44
  gpr_slice slice = gpr_slice_malloc(9 + 8);
@@ -57,18 +58,22 @@ gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) {
57
58
  return slice;
58
59
  }
59
60
 
60
- grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
61
- grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags) {
61
+ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
62
+ uint32_t length,
63
+ uint8_t flags) {
62
64
  if (flags & 0xfe || length != 8) {
63
- gpr_log(GPR_ERROR, "invalid ping: length=%d, flags=%02x", length, flags);
64
- return GRPC_CHTTP2_CONNECTION_ERROR;
65
+ char *msg;
66
+ gpr_asprintf(&msg, "invalid ping: length=%d, flags=%02x", length, flags);
67
+ grpc_error *error = GRPC_ERROR_CREATE(msg);
68
+ gpr_free(msg);
69
+ return error;
65
70
  }
66
71
  parser->byte = 0;
67
72
  parser->is_ack = flags;
68
- return GRPC_CHTTP2_PARSE_OK;
73
+ return GRPC_ERROR_NONE;
69
74
  }
70
75
 
71
- grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
76
+ grpc_error *grpc_chttp2_ping_parser_parse(
72
77
  grpc_exec_ctx *exec_ctx, void *parser,
73
78
  grpc_chttp2_transport_parsing *transport_parsing,
74
79
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
@@ -93,5 +98,5 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
93
98
  }
94
99
  }
95
100
 
96
- return GRPC_CHTTP2_PARSE_OK;
101
+ return GRPC_ERROR_NONE;
97
102
  }
@@ -46,9 +46,9 @@ typedef struct {
46
46
 
47
47
  gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes);
48
48
 
49
- grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
50
- grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags);
51
- grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
49
+ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
50
+ uint32_t length, uint8_t flags);
51
+ grpc_error *grpc_chttp2_ping_parser_parse(
52
52
  grpc_exec_ctx *exec_ctx, void *parser,
53
53
  grpc_chttp2_transport_parsing *transport_parsing,
54
54
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
@@ -34,7 +34,9 @@
34
34
  #include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h"
35
35
  #include "src/core/ext/transport/chttp2/transport/internal.h"
36
36
 
37
+ #include <grpc/support/alloc.h>
37
38
  #include <grpc/support/log.h>
39
+ #include <grpc/support/string_util.h>
38
40
 
39
41
  #include "src/core/ext/transport/chttp2/transport/frame.h"
40
42
 
@@ -45,15 +47,20 @@ gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
45
47
  stats->framing_bytes += frame_size;
46
48
  uint8_t *p = GPR_SLICE_START_PTR(slice);
47
49
 
50
+ // Frame size.
48
51
  *p++ = 0;
49
52
  *p++ = 0;
50
53
  *p++ = 4;
54
+ // Frame type.
51
55
  *p++ = GRPC_CHTTP2_FRAME_RST_STREAM;
56
+ // Flags.
52
57
  *p++ = 0;
58
+ // Stream ID.
53
59
  *p++ = (uint8_t)(id >> 24);
54
60
  *p++ = (uint8_t)(id >> 16);
55
61
  *p++ = (uint8_t)(id >> 8);
56
62
  *p++ = (uint8_t)(id);
63
+ // Error code.
57
64
  *p++ = (uint8_t)(code >> 24);
58
65
  *p++ = (uint8_t)(code >> 16);
59
66
  *p++ = (uint8_t)(code >> 8);
@@ -62,18 +69,21 @@ gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
62
69
  return slice;
63
70
  }
64
71
 
65
- grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
72
+ grpc_error *grpc_chttp2_rst_stream_parser_begin_frame(
66
73
  grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags) {
67
74
  if (length != 4) {
68
- gpr_log(GPR_ERROR, "invalid rst_stream: length=%d, flags=%02x", length,
69
- flags);
70
- return GRPC_CHTTP2_CONNECTION_ERROR;
75
+ char *msg;
76
+ gpr_asprintf(&msg, "invalid rst_stream: length=%d, flags=%02x", length,
77
+ flags);
78
+ grpc_error *err = GRPC_ERROR_CREATE(msg);
79
+ gpr_free(msg);
80
+ return err;
71
81
  }
72
82
  parser->byte = 0;
73
- return GRPC_CHTTP2_PARSE_OK;
83
+ return GRPC_ERROR_NONE;
74
84
  }
75
85
 
76
- grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
86
+ grpc_error *grpc_chttp2_rst_stream_parser_parse(
77
87
  grpc_exec_ctx *exec_ctx, void *parser,
78
88
  grpc_chttp2_transport_parsing *transport_parsing,
79
89
  grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
@@ -92,12 +102,15 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
92
102
  if (p->byte == 4) {
93
103
  GPR_ASSERT(is_last);
94
104
  stream_parsing->received_close = 1;
95
- stream_parsing->saw_rst_stream = 1;
96
- stream_parsing->rst_stream_reason = (((uint32_t)p->reason_bytes[0]) << 24) |
97
- (((uint32_t)p->reason_bytes[1]) << 16) |
98
- (((uint32_t)p->reason_bytes[2]) << 8) |
99
- (((uint32_t)p->reason_bytes[3]));
105
+ if (stream_parsing->forced_close_error == GRPC_ERROR_NONE) {
106
+ stream_parsing->forced_close_error = grpc_error_set_int(
107
+ GRPC_ERROR_CREATE("RST_STREAM"), GRPC_ERROR_INT_HTTP2_ERROR,
108
+ (intptr_t)((((uint32_t)p->reason_bytes[0]) << 24) |
109
+ (((uint32_t)p->reason_bytes[1]) << 16) |
110
+ (((uint32_t)p->reason_bytes[2]) << 8) |
111
+ (((uint32_t)p->reason_bytes[3]))));
112
+ }
100
113
  }
101
114
 
102
- return GRPC_CHTTP2_PARSE_OK;
115
+ return GRPC_ERROR_NONE;
103
116
  }