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
@@ -52,12 +52,4 @@ void grpc_iocp_flush(void);
52
52
  void grpc_iocp_shutdown(void);
53
53
  void grpc_iocp_add_socket(grpc_winsocket *);
54
54
 
55
- void grpc_socket_notify_on_write(grpc_exec_ctx *exec_ctx,
56
- grpc_winsocket *winsocket,
57
- grpc_closure *closure);
58
-
59
- void grpc_socket_notify_on_read(grpc_exec_ctx *exec_ctx,
60
- grpc_winsocket *winsocket,
61
- grpc_closure *closure);
62
-
63
55
  #endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */
@@ -96,7 +96,8 @@ void grpc_iomgr_shutdown(void) {
96
96
  gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
97
97
  gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
98
98
  if (g_root_object.next != &g_root_object) {
99
- gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed",
99
+ gpr_log(GPR_DEBUG,
100
+ "Waiting for %" PRIuPTR " iomgr objects to be destroyed",
100
101
  count_objects());
101
102
  }
102
103
  last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
@@ -114,9 +115,9 @@ void grpc_iomgr_shutdown(void) {
114
115
  if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) {
115
116
  if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) {
116
117
  if (g_root_object.next != &g_root_object) {
117
- gpr_log(GPR_DEBUG,
118
- "Failed to free %d iomgr objects before shutdown deadline: "
119
- "memory leaks are likely",
118
+ gpr_log(GPR_DEBUG, "Failed to free %" PRIuPTR
119
+ " iomgr objects before shutdown deadline: "
120
+ "memory leaks are likely",
120
121
  count_objects());
121
122
  dump_objects("LEAKED");
122
123
  if (grpc_iomgr_abort_on_leaks()) {
@@ -41,12 +41,16 @@
41
41
  #include "src/core/lib/iomgr/tcp_posix.h"
42
42
 
43
43
  void grpc_iomgr_platform_init(void) {
44
+ grpc_wakeup_fd_global_init();
44
45
  grpc_event_engine_init();
45
46
  grpc_register_tracer("tcp", &grpc_tcp_trace);
46
47
  }
47
48
 
48
49
  void grpc_iomgr_platform_flush(void) {}
49
50
 
50
- void grpc_iomgr_platform_shutdown(void) { grpc_event_engine_shutdown(); }
51
+ void grpc_iomgr_platform_shutdown(void) {
52
+ grpc_event_engine_shutdown();
53
+ grpc_wakeup_fd_global_destroy();
54
+ }
51
55
 
52
56
  #endif /* GRPC_POSIX_SOCKET */
@@ -35,7 +35,7 @@
35
35
 
36
36
  #ifdef GPR_WINSOCK_SOCKET
37
37
 
38
- #include "src/core/lib/iomgr/sockaddr_win32.h"
38
+ #include "src/core/lib/iomgr/sockaddr_windows.h"
39
39
 
40
40
  #include <grpc/support/log.h>
41
41
 
@@ -31,7 +31,7 @@
31
31
  *
32
32
  */
33
33
 
34
- #include "src/core/lib/support/load_file.h"
34
+ #include "src/core/lib/iomgr/load_file.h"
35
35
 
36
36
  #include <errno.h>
37
37
  #include <string.h>
@@ -43,21 +43,19 @@
43
43
  #include "src/core/lib/support/block_annotate.h"
44
44
  #include "src/core/lib/support/string.h"
45
45
 
46
- gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
47
- int *success) {
46
+ grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
47
+ gpr_slice *output) {
48
48
  unsigned char *contents = NULL;
49
49
  size_t contents_size = 0;
50
- char *error_msg = NULL;
51
50
  gpr_slice result = gpr_empty_slice();
52
51
  FILE *file;
53
52
  size_t bytes_read = 0;
53
+ grpc_error *error = GRPC_ERROR_NONE;
54
54
 
55
55
  GRPC_SCHEDULING_START_BLOCKING_REGION;
56
56
  file = fopen(filename, "rb");
57
57
  if (file == NULL) {
58
- gpr_asprintf(&error_msg, "Could not open file %s (error = %s).", filename,
59
- strerror(errno));
60
- GPR_ASSERT(error_msg != NULL);
58
+ error = GRPC_OS_ERROR(errno, "fopen");
61
59
  goto end;
62
60
  }
63
61
  fseek(file, 0, SEEK_END);
@@ -67,25 +65,25 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
67
65
  contents = gpr_malloc(contents_size + (add_null_terminator ? 1 : 0));
68
66
  bytes_read = fread(contents, 1, contents_size, file);
69
67
  if (bytes_read < contents_size) {
68
+ error = GRPC_OS_ERROR(errno, "fread");
70
69
  GPR_ASSERT(ferror(file));
71
- gpr_asprintf(&error_msg, "Error %s occured while reading file %s.",
72
- strerror(errno), filename);
73
- GPR_ASSERT(error_msg != NULL);
74
70
  goto end;
75
71
  }
76
- if (success != NULL) *success = 1;
77
72
  if (add_null_terminator) {
78
73
  contents[contents_size++] = 0;
79
74
  }
80
75
  result = gpr_slice_new(contents, contents_size, gpr_free);
81
76
 
82
77
  end:
83
- if (error_msg != NULL) {
84
- gpr_log(GPR_ERROR, "%s", error_msg);
85
- gpr_free(error_msg);
86
- if (success != NULL) *success = 0;
87
- }
78
+ *output = result;
88
79
  if (file != NULL) fclose(file);
80
+ if (error != GRPC_ERROR_NONE) {
81
+ grpc_error *error_out = grpc_error_set_str(
82
+ GRPC_ERROR_CREATE_REFERENCING("Failed to load file", &error, 1),
83
+ GRPC_ERROR_STR_FILENAME, filename);
84
+ GRPC_ERROR_UNREF(error);
85
+ error = error_out;
86
+ }
89
87
  GRPC_SCHEDULING_END_BLOCKING_REGION;
90
- return result;
88
+ return error;
91
89
  }
@@ -31,25 +31,26 @@
31
31
  *
32
32
  */
33
33
 
34
- #ifndef GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H
35
- #define GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H
34
+ #ifndef GRPC_CORE_LIB_IOMGR_LOAD_FILE_H
35
+ #define GRPC_CORE_LIB_IOMGR_LOAD_FILE_H
36
36
 
37
37
  #include <stdio.h>
38
38
 
39
39
  #include <grpc/support/slice.h>
40
40
 
41
+ #include "src/core/lib/iomgr/error.h"
42
+
41
43
  #ifdef __cplusplus
42
44
  extern "C" {
43
45
  #endif
44
46
 
45
47
  /* Loads the content of a file into a slice. add_null_terminator will add
46
- a NULL terminator if non-zero. The success parameter, if not NULL,
47
- will be set to 1 in case of success and 0 in case of failure. */
48
- gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
49
- int *success);
48
+ a NULL terminator if non-zero. */
49
+ grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
50
+ gpr_slice *slice);
50
51
 
51
52
  #ifdef __cplusplus
52
53
  }
53
54
  #endif
54
55
 
55
- #endif /* GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H */
56
+ #endif /* GRPC_CORE_LIB_IOMGR_LOAD_FILE_H */
@@ -0,0 +1,104 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #include <grpc/support/alloc.h>
35
+ #include <grpc/support/log.h>
36
+
37
+ #include "src/core/lib/iomgr/polling_entity.h"
38
+
39
+ grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
40
+ grpc_pollset_set *pollset_set) {
41
+ grpc_polling_entity pollent;
42
+ pollent.pollent.pollset_set = pollset_set;
43
+ pollent.tag = POPS_POLLSET_SET;
44
+ return pollent;
45
+ }
46
+
47
+ grpc_polling_entity grpc_polling_entity_create_from_pollset(
48
+ grpc_pollset *pollset) {
49
+ grpc_polling_entity pollent;
50
+ pollent.pollent.pollset = pollset;
51
+ pollent.tag = POPS_POLLSET;
52
+ return pollent;
53
+ }
54
+
55
+ grpc_pollset *grpc_polling_entity_pollset(grpc_polling_entity *pollent) {
56
+ if (pollent->tag == POPS_POLLSET) {
57
+ return pollent->pollent.pollset;
58
+ }
59
+ return NULL;
60
+ }
61
+
62
+ grpc_pollset_set *grpc_polling_entity_pollset_set(
63
+ grpc_polling_entity *pollent) {
64
+ if (pollent->tag == POPS_POLLSET_SET) {
65
+ return pollent->pollent.pollset_set;
66
+ }
67
+ return NULL;
68
+ }
69
+
70
+ bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent) {
71
+ return pollent->tag == POPS_NONE;
72
+ }
73
+
74
+ void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
75
+ grpc_polling_entity *pollent,
76
+ grpc_pollset_set *pss_dst) {
77
+ if (pollent->tag == POPS_POLLSET) {
78
+ GPR_ASSERT(pollent->pollent.pollset != NULL);
79
+ grpc_pollset_set_add_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
80
+ } else if (pollent->tag == POPS_POLLSET_SET) {
81
+ GPR_ASSERT(pollent->pollent.pollset_set != NULL);
82
+ grpc_pollset_set_add_pollset_set(exec_ctx, pss_dst,
83
+ pollent->pollent.pollset_set);
84
+ } else {
85
+ gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
86
+ abort();
87
+ }
88
+ }
89
+
90
+ void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx,
91
+ grpc_polling_entity *pollent,
92
+ grpc_pollset_set *pss_dst) {
93
+ if (pollent->tag == POPS_POLLSET) {
94
+ GPR_ASSERT(pollent->pollent.pollset != NULL);
95
+ grpc_pollset_set_del_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
96
+ } else if (pollent->tag == POPS_POLLSET_SET) {
97
+ GPR_ASSERT(pollent->pollent.pollset_set != NULL);
98
+ grpc_pollset_set_del_pollset_set(exec_ctx, pss_dst,
99
+ pollent->pollent.pollset_set);
100
+ } else {
101
+ gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
102
+ abort();
103
+ }
104
+ }
@@ -0,0 +1,81 @@
1
+ /*
2
+ *
3
+ * Copyright 2015, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H
35
+ #define GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H
36
+
37
+ #include "src/core/lib/iomgr/pollset.h"
38
+ #include "src/core/lib/iomgr/pollset_set.h"
39
+
40
+ /* A grpc_polling_entity is a pollset-or-pollset_set container. It allows
41
+ * functions that
42
+ * accept a pollset XOR a pollset_set to do so through an abstract interface.
43
+ * No ownership is taken. */
44
+
45
+ typedef struct grpc_polling_entity {
46
+ union {
47
+ grpc_pollset *pollset;
48
+ grpc_pollset_set *pollset_set;
49
+ } pollent;
50
+ enum pops_tag { POPS_NONE, POPS_POLLSET, POPS_POLLSET_SET } tag;
51
+ } grpc_polling_entity;
52
+
53
+ grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
54
+ grpc_pollset_set *pollset_set);
55
+ grpc_polling_entity grpc_polling_entity_create_from_pollset(
56
+ grpc_pollset *pollset);
57
+
58
+ /** If \a pollent contains a pollset, return it. Otherwise, return NULL */
59
+ grpc_pollset *grpc_polling_entity_pollset(grpc_polling_entity *pollent);
60
+
61
+ /** If \a pollent contains a pollset_set, return it. Otherwise, return NULL */
62
+ grpc_pollset_set *grpc_polling_entity_pollset_set(grpc_polling_entity *pollent);
63
+
64
+ bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent);
65
+
66
+ /** Add the pollset or pollset_set in \a pollent to the destination pollset_set
67
+ * \a
68
+ * pss_dst */
69
+ void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
70
+ grpc_polling_entity *pollent,
71
+ grpc_pollset_set *pss_dst);
72
+
73
+ /** Delete the pollset or pollset_set in \a pollent from the destination
74
+ * pollset_set \a
75
+ * pss_dst */
76
+ void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx,
77
+ grpc_polling_entity *pollent,
78
+ grpc_pollset_set *pss_dst);
79
+ /* pollset_set specific */
80
+
81
+ #endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */
@@ -81,14 +81,15 @@ void grpc_pollset_destroy(grpc_pollset *pollset);
81
81
  May call grpc_closure_list_run on grpc_closure_list, without holding the
82
82
  pollset
83
83
  lock */
84
- void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
85
- grpc_pollset_worker **worker, gpr_timespec now,
86
- gpr_timespec deadline);
84
+ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
85
+ grpc_pollset_worker **worker, gpr_timespec now,
86
+ gpr_timespec deadline) GRPC_MUST_USE_RESULT;
87
87
 
88
88
  /* Break one polling thread out of polling work for this pollset.
89
89
  If specific_worker is GRPC_POLLSET_KICK_BROADCAST, kick ALL the workers.
90
90
  Otherwise, if specific_worker is non-NULL, then kick that worker. */
91
- void grpc_pollset_kick(grpc_pollset *pollset,
92
- grpc_pollset_worker *specific_worker);
91
+ grpc_error *grpc_pollset_kick(grpc_pollset *pollset,
92
+ grpc_pollset_worker *specific_worker)
93
+ GRPC_MUST_USE_RESULT;
93
94
 
94
95
  #endif /* GRPC_CORE_LIB_IOMGR_POLLSET_H */
@@ -32,12 +32,15 @@
32
32
  */
33
33
 
34
34
  #include <grpc/support/port_platform.h>
35
+ #include <stdint.h>
35
36
 
36
37
  #ifdef GPR_WINSOCK_SOCKET
37
38
 
38
39
  #include "src/core/lib/iomgr/pollset_set_windows.h"
39
40
 
40
- grpc_pollset_set* grpc_pollset_set_create(void) { return NULL; }
41
+ grpc_pollset_set* grpc_pollset_set_create(void) {
42
+ return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
43
+ }
41
44
 
42
45
  void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
43
46
 
@@ -109,7 +109,7 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
109
109
  pollset->shutting_down = 1;
110
110
  grpc_pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
111
111
  if (!pollset->is_iocp_worker) {
112
- grpc_exec_ctx_enqueue(exec_ctx, closure, true, NULL);
112
+ grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_NONE, NULL);
113
113
  } else {
114
114
  pollset->on_shutdown = closure;
115
115
  }
@@ -127,9 +127,9 @@ void grpc_pollset_reset(grpc_pollset *pollset) {
127
127
  pollset->on_shutdown = NULL;
128
128
  }
129
129
 
130
- void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
131
- grpc_pollset_worker **worker_hdl, gpr_timespec now,
132
- gpr_timespec deadline) {
130
+ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
131
+ grpc_pollset_worker **worker_hdl,
132
+ gpr_timespec now, gpr_timespec deadline) {
133
133
  grpc_pollset_worker worker;
134
134
  *worker_hdl = &worker;
135
135
 
@@ -167,7 +167,8 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
167
167
  }
168
168
 
169
169
  if (pollset->shutting_down && pollset->on_shutdown != NULL) {
170
- grpc_exec_ctx_enqueue(exec_ctx, pollset->on_shutdown, true, NULL);
170
+ grpc_exec_ctx_sched(exec_ctx, pollset->on_shutdown, GRPC_ERROR_NONE,
171
+ NULL);
171
172
  pollset->on_shutdown = NULL;
172
173
  }
173
174
  goto done;
@@ -197,9 +198,11 @@ done:
197
198
  }
198
199
  gpr_cv_destroy(&worker.cv);
199
200
  *worker_hdl = NULL;
201
+ return GRPC_ERROR_NONE;
200
202
  }
201
203
 
202
- void grpc_pollset_kick(grpc_pollset *p, grpc_pollset_worker *specific_worker) {
204
+ grpc_error *grpc_pollset_kick(grpc_pollset *p,
205
+ grpc_pollset_worker *specific_worker) {
203
206
  if (specific_worker != NULL) {
204
207
  if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
205
208
  for (specific_worker =
@@ -233,6 +236,7 @@ void grpc_pollset_kick(grpc_pollset *p, grpc_pollset_worker *specific_worker) {
233
236
  p->kicked_without_pollers = 1;
234
237
  }
235
238
  }
239
+ return GRPC_ERROR_NONE;
236
240
  }
237
241
 
238
242
  void grpc_kick_poller(void) { grpc_iocp_kick(); }