grpc 1.2.5 → 1.3.4

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 (327) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1434 -399
  3. data/etc/roots.pem +34 -150
  4. data/include/grpc/grpc.h +71 -0
  5. data/include/grpc/impl/codegen/atm.h +5 -0
  6. data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
  7. data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
  8. data/include/grpc/impl/codegen/atm_windows.h +11 -0
  9. data/include/grpc/impl/codegen/grpc_types.h +54 -13
  10. data/include/grpc/impl/codegen/port_platform.h +15 -1
  11. data/include/grpc/support/alloc.h +2 -1
  12. data/include/grpc/support/sync.h +4 -0
  13. data/include/grpc/support/tls.h +1 -1
  14. data/src/core/ext/census/gen/trace_context.pb.h +1 -1
  15. data/src/core/ext/census/grpc_filter.c +14 -10
  16. data/src/core/ext/census/grpc_plugin.c +3 -1
  17. data/src/core/ext/census/trace_label.h +1 -1
  18. data/src/core/ext/census/trace_propagation.h +1 -1
  19. data/src/core/ext/census/trace_status.h +1 -1
  20. data/src/core/ext/census/trace_string.h +1 -1
  21. data/src/core/ext/census/tracing.h +1 -1
  22. data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
  23. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
  24. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
  25. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
  26. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
  27. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
  28. data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
  29. data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
  30. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
  31. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
  32. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
  33. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
  34. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
  35. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
  36. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
  37. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
  38. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
  39. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
  40. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
  41. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
  42. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
  43. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
  44. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
  45. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
  46. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
  47. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
  48. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
  49. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
  50. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
  51. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
  52. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
  53. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
  54. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
  55. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
  56. data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
  57. data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
  63. data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
  64. data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
  65. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
  66. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
  67. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
  68. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
  69. data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
  70. data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
  71. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
  72. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
  73. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
  74. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
  75. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
  76. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
  77. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
  78. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
  79. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
  80. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
  81. data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
  82. data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
  83. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
  84. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  85. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
  86. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
  87. data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
  88. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
  89. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
  90. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
  91. data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
  92. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
  93. data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
  94. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
  95. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
  96. data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
  97. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
  98. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
  99. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
  100. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
  101. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
  102. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  103. data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
  104. data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
  105. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
  106. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
  107. data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
  108. data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
  109. data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
  110. data/src/core/lib/channel/channel_args.c +7 -0
  111. data/src/core/lib/channel/channel_args.h +2 -0
  112. data/src/core/lib/channel/channel_stack.c +20 -27
  113. data/src/core/lib/channel/channel_stack.h +18 -16
  114. data/src/core/lib/channel/compress_filter.c +20 -18
  115. data/src/core/lib/channel/connected_channel.c +9 -8
  116. data/src/core/lib/channel/deadline_filter.c +28 -24
  117. data/src/core/lib/channel/deadline_filter.h +3 -3
  118. data/src/core/lib/channel/handshaker.c +3 -2
  119. data/src/core/lib/channel/http_client_filter.c +119 -61
  120. data/src/core/lib/channel/http_server_filter.c +124 -69
  121. data/src/core/lib/channel/message_size_filter.c +23 -19
  122. data/src/core/lib/http/httpcli.c +8 -6
  123. data/src/core/lib/http/httpcli_security_connector.c +5 -5
  124. data/src/core/lib/http/parser.c +57 -31
  125. data/src/core/lib/iomgr/closure.c +15 -0
  126. data/src/core/lib/iomgr/closure.h +4 -0
  127. data/src/core/lib/iomgr/combiner.c +8 -0
  128. data/src/core/lib/iomgr/endpoint_pair.h +2 -3
  129. data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
  130. data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
  131. data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
  132. data/src/core/lib/iomgr/error.c +360 -177
  133. data/src/core/lib/iomgr/error.h +31 -33
  134. data/src/core/lib/iomgr/error_internal.h +30 -9
  135. data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
  136. data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
  137. data/src/core/lib/iomgr/ev_posix.c +6 -0
  138. data/src/core/lib/iomgr/ev_posix.h +3 -0
  139. data/src/core/lib/iomgr/exec_ctx.c +6 -0
  140. data/src/core/lib/iomgr/executor.c +8 -2
  141. data/src/core/lib/iomgr/load_file.c +6 -3
  142. data/src/core/lib/iomgr/lockfree_event.c +238 -0
  143. data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
  144. data/src/core/lib/iomgr/pollset.h +4 -0
  145. data/src/core/lib/iomgr/pollset_windows.c +2 -2
  146. data/src/core/lib/iomgr/port.h +9 -0
  147. data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
  148. data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
  149. data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
  150. data/src/core/lib/iomgr/resource_quota.c +19 -4
  151. data/src/core/lib/iomgr/resource_quota.h +2 -0
  152. data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
  153. data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
  154. data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
  155. data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
  156. data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
  157. data/src/core/lib/iomgr/tcp_client.h +0 -4
  158. data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
  159. data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
  160. data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
  161. data/src/core/lib/iomgr/tcp_posix.c +111 -22
  162. data/src/core/lib/iomgr/tcp_posix.h +3 -4
  163. data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
  165. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
  166. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
  167. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
  168. data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
  169. data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
  170. data/src/core/lib/iomgr/tcp_uv.c +16 -13
  171. data/src/core/lib/iomgr/tcp_windows.c +24 -12
  172. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  173. data/src/core/lib/iomgr/timer.h +3 -0
  174. data/src/core/lib/iomgr/timer_generic.c +257 -72
  175. data/src/core/lib/iomgr/timer_generic.h +1 -1
  176. data/src/core/lib/iomgr/timer_heap.c +8 -8
  177. data/src/core/lib/iomgr/udp_server.c +54 -24
  178. data/src/core/lib/iomgr/udp_server.h +7 -7
  179. data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
  180. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
  181. data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
  182. data/src/core/lib/profiling/basic_timers.c +1 -1
  183. data/src/core/lib/security/credentials/credentials.h +1 -1
  184. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
  185. data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
  186. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
  187. data/src/core/lib/security/transport/client_auth_filter.c +33 -26
  188. data/src/core/lib/security/transport/secure_endpoint.c +8 -5
  189. data/src/core/lib/security/transport/security_connector.c +37 -37
  190. data/src/core/lib/security/transport/security_connector.h +1 -1
  191. data/src/core/lib/security/transport/security_handshaker.c +15 -12
  192. data/src/core/lib/security/transport/server_auth_filter.c +20 -18
  193. data/src/core/lib/security/transport/tsi_error.c +5 -3
  194. data/src/core/lib/security/transport/tsi_error.h +1 -1
  195. data/src/core/lib/{security/util → slice}/b64.c +21 -6
  196. data/src/core/lib/{security/util → slice}/b64.h +16 -4
  197. data/src/core/lib/slice/slice.c +4 -2
  198. data/src/core/lib/slice/slice_buffer.c +16 -14
  199. data/src/core/lib/support/arena.c +98 -0
  200. data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
  201. data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
  202. data/src/core/lib/support/cpu_linux.c +5 -0
  203. data/src/core/lib/support/sync.c +4 -0
  204. data/src/core/lib/support/time.c +4 -10
  205. data/src/core/lib/support/wrap_memcpy.c +3 -1
  206. data/src/core/lib/surface/call.c +252 -221
  207. data/src/core/lib/surface/channel.c +72 -21
  208. data/src/core/lib/surface/channel.h +8 -0
  209. data/src/core/lib/surface/completion_queue.c +2 -3
  210. data/src/core/lib/surface/completion_queue_factory.c +77 -0
  211. data/src/core/lib/surface/completion_queue_factory.h +51 -0
  212. data/src/core/lib/surface/init_secure.c +3 -1
  213. data/src/core/lib/surface/lame_client.c +18 -14
  214. data/src/core/lib/surface/server.c +43 -41
  215. data/src/core/lib/surface/validate_metadata.c +8 -4
  216. data/src/core/lib/surface/version.c +2 -2
  217. data/src/core/lib/transport/bdp_estimator.h +1 -1
  218. data/src/core/lib/transport/connectivity_state.c +2 -1
  219. data/src/core/lib/transport/error_utils.c +17 -17
  220. data/src/core/lib/transport/error_utils.h +1 -1
  221. data/src/core/lib/transport/metadata_batch.c +6 -7
  222. data/src/core/lib/transport/pid_controller.c +1 -0
  223. data/src/core/lib/transport/service_config.c +12 -0
  224. data/src/core/lib/transport/service_config.h +6 -0
  225. data/src/core/lib/transport/transport.c +29 -17
  226. data/src/core/lib/transport/transport.h +85 -42
  227. data/src/core/lib/transport/transport_impl.h +5 -3
  228. data/src/core/lib/transport/transport_op_string.c +20 -14
  229. data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
  230. data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
  231. data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
  232. data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
  233. data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
  234. data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
  235. data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
  236. data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
  237. data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
  238. data/src/ruby/ext/grpc/extconf.rb +1 -0
  239. data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
  240. data/src/ruby/ext/grpc/rb_channel.c +520 -93
  241. data/src/ruby/ext/grpc/rb_channel.h +2 -0
  242. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
  243. data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
  244. data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
  245. data/src/ruby/ext/grpc/rb_grpc.c +29 -7
  246. data/src/ruby/ext/grpc/rb_grpc.h +2 -0
  247. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
  249. data/src/ruby/ext/grpc/rb_server.c +5 -3
  250. data/src/ruby/lib/grpc/version.rb +1 -1
  251. data/src/ruby/spec/channel_connection_spec.rb +173 -0
  252. data/src/ruby/spec/channel_spec.rb +29 -0
  253. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
  254. data/third_party/cares/ares_build.h +264 -0
  255. data/third_party/cares/cares/ares.h +636 -0
  256. data/third_party/cares/cares/ares__close_sockets.c +61 -0
  257. data/third_party/cares/cares/ares__get_hostent.c +261 -0
  258. data/third_party/cares/cares/ares__read_line.c +73 -0
  259. data/third_party/cares/cares/ares__timeval.c +111 -0
  260. data/third_party/cares/cares/ares_cancel.c +63 -0
  261. data/third_party/cares/cares/ares_create_query.c +202 -0
  262. data/third_party/cares/cares/ares_data.c +221 -0
  263. data/third_party/cares/cares/ares_data.h +72 -0
  264. data/third_party/cares/cares/ares_destroy.c +108 -0
  265. data/third_party/cares/cares/ares_dns.h +103 -0
  266. data/third_party/cares/cares/ares_expand_name.c +205 -0
  267. data/third_party/cares/cares/ares_expand_string.c +70 -0
  268. data/third_party/cares/cares/ares_fds.c +59 -0
  269. data/third_party/cares/cares/ares_free_hostent.c +41 -0
  270. data/third_party/cares/cares/ares_free_string.c +25 -0
  271. data/third_party/cares/cares/ares_getenv.c +30 -0
  272. data/third_party/cares/cares/ares_getenv.h +26 -0
  273. data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
  274. data/third_party/cares/cares/ares_gethostbyname.c +518 -0
  275. data/third_party/cares/cares/ares_getnameinfo.c +422 -0
  276. data/third_party/cares/cares/ares_getopt.c +122 -0
  277. data/third_party/cares/cares/ares_getopt.h +53 -0
  278. data/third_party/cares/cares/ares_getsock.c +66 -0
  279. data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
  280. data/third_party/cares/cares/ares_init.c +2146 -0
  281. data/third_party/cares/cares/ares_iphlpapi.h +221 -0
  282. data/third_party/cares/cares/ares_ipv6.h +78 -0
  283. data/third_party/cares/cares/ares_library_init.c +167 -0
  284. data/third_party/cares/cares/ares_library_init.h +42 -0
  285. data/third_party/cares/cares/ares_llist.c +63 -0
  286. data/third_party/cares/cares/ares_llist.h +39 -0
  287. data/third_party/cares/cares/ares_mkquery.c +24 -0
  288. data/third_party/cares/cares/ares_nowarn.c +260 -0
  289. data/third_party/cares/cares/ares_nowarn.h +61 -0
  290. data/third_party/cares/cares/ares_options.c +402 -0
  291. data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
  292. data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
  293. data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
  294. data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
  295. data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
  296. data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
  297. data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
  298. data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
  299. data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
  300. data/third_party/cares/cares/ares_platform.c +11035 -0
  301. data/third_party/cares/cares/ares_platform.h +43 -0
  302. data/third_party/cares/cares/ares_private.h +363 -0
  303. data/third_party/cares/cares/ares_process.c +1359 -0
  304. data/third_party/cares/cares/ares_query.c +186 -0
  305. data/third_party/cares/cares/ares_rules.h +125 -0
  306. data/third_party/cares/cares/ares_search.c +316 -0
  307. data/third_party/cares/cares/ares_send.c +131 -0
  308. data/third_party/cares/cares/ares_setup.h +217 -0
  309. data/third_party/cares/cares/ares_strcasecmp.c +66 -0
  310. data/third_party/cares/cares/ares_strcasecmp.h +30 -0
  311. data/third_party/cares/cares/ares_strdup.c +49 -0
  312. data/third_party/cares/cares/ares_strdup.h +24 -0
  313. data/third_party/cares/cares/ares_strerror.c +56 -0
  314. data/third_party/cares/cares/ares_timeout.c +88 -0
  315. data/third_party/cares/cares/ares_version.c +11 -0
  316. data/third_party/cares/cares/ares_version.h +24 -0
  317. data/third_party/cares/cares/ares_writev.c +79 -0
  318. data/third_party/cares/cares/bitncmp.c +59 -0
  319. data/third_party/cares/cares/bitncmp.h +26 -0
  320. data/third_party/cares/cares/config-win32.h +377 -0
  321. data/third_party/cares/cares/inet_net_pton.c +450 -0
  322. data/third_party/cares/cares/inet_ntop.c +208 -0
  323. data/third_party/cares/cares/setup_once.h +554 -0
  324. data/third_party/cares/cares/windows_port.c +22 -0
  325. data/third_party/cares/config_darwin/ares_config.h +523 -0
  326. data/third_party/cares/config_linux/ares_config.h +524 -0
  327. metadata +164 -68
@@ -52,28 +52,31 @@ describe GRPC::Pool do
52
52
  expect(p.ready_for_work?).to be(false)
53
53
  end
54
54
 
55
- it 'it stops being ready after all workers jobs waiting or running' do
55
+ it 'it stops being ready after all workers are busy' do
56
56
  p = Pool.new(5)
57
57
  p.start
58
- job = proc { sleep(3) } # sleep so workers busy when done scheduling
59
- 5.times do
60
- expect(p.ready_for_work?).to be(true)
61
- p.schedule(&job)
58
+
59
+ wait_mu = Mutex.new
60
+ wait_cv = ConditionVariable.new
61
+ wait = true
62
+
63
+ job = proc do
64
+ wait_mu.synchronize do
65
+ wait_cv.wait(wait_mu) while wait
66
+ end
62
67
  end
63
- expect(p.ready_for_work?).to be(false)
64
- end
65
68
 
66
- it 'it becomes ready again after jobs complete' do
67
- p = Pool.new(5)
68
- p.start
69
- job = proc {}
70
69
  5.times do
71
70
  expect(p.ready_for_work?).to be(true)
72
71
  p.schedule(&job)
73
72
  end
73
+
74
74
  expect(p.ready_for_work?).to be(false)
75
- sleep 5 # give the pool time do get at least one task done
76
- expect(p.ready_for_work?).to be(true)
75
+
76
+ wait_mu.synchronize do
77
+ wait = false
78
+ wait_cv.broadcast
79
+ end
77
80
  end
78
81
  end
79
82
 
@@ -105,13 +108,20 @@ describe GRPC::Pool do
105
108
  it 'stops jobs when there are long running jobs' do
106
109
  p = Pool.new(1)
107
110
  p.start
108
- o, q = Object.new, Queue.new
111
+
112
+ wait_forever_mu = Mutex.new
113
+ wait_forever_cv = ConditionVariable.new
114
+ wait_forever = true
115
+
116
+ job_running = Queue.new
109
117
  job = proc do
110
- sleep(5) # long running
111
- q.push(o)
118
+ job_running.push(Object.new)
119
+ wait_forever_mu.synchronize do
120
+ wait_forever_cv.wait while wait_forever
121
+ end
112
122
  end
113
123
  p.schedule(&job)
114
- sleep(1) # should ensure the long job gets scheduled
124
+ job_running.pop
115
125
  expect { p.stop }.not_to raise_error
116
126
  end
117
127
  end
@@ -0,0 +1,264 @@
1
+ #ifndef __CARES_BUILD_H
2
+ #define __CARES_BUILD_H
3
+
4
+
5
+ /* Copyright (C) 2009 - 2013 by Daniel Stenberg et al
6
+ *
7
+ * Permission to use, copy, modify, and distribute this software and its
8
+ * documentation for any purpose and without fee is hereby granted, provided
9
+ * that the above copyright notice appear in all copies and that both that
10
+ * copyright notice and this permission notice appear in supporting
11
+ * documentation, and that the name of M.I.T. not be used in advertising or
12
+ * publicity pertaining to distribution of the software without specific,
13
+ * written prior permission. M.I.T. makes no representations about the
14
+ * suitability of this software for any purpose. It is provided "as is"
15
+ * without express or implied warranty.
16
+ */
17
+
18
+ /* ================================================================ */
19
+ /* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
20
+ /* ================================================================ */
21
+
22
+ /*
23
+ * NOTE 1:
24
+ * -------
25
+ *
26
+ * See file ares_build.h.in, run configure, and forget that this file
27
+ * exists it is only used for non-configure systems.
28
+ * But you can keep reading if you want ;-)
29
+ *
30
+ */
31
+
32
+ /* ================================================================ */
33
+ /* NOTES FOR NON-CONFIGURE SYSTEMS */
34
+ /* ================================================================ */
35
+
36
+ /*
37
+ * NOTE 1:
38
+ * -------
39
+ *
40
+ * Nothing in this file is intended to be modified or adjusted by the
41
+ * c-ares library user nor by the c-ares library builder.
42
+ *
43
+ * If you think that something actually needs to be changed, adjusted
44
+ * or fixed in this file, then, report it on the c-ares development
45
+ * mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
46
+ *
47
+ * Try to keep one section per platform, compiler and architecture,
48
+ * otherwise, if an existing section is reused for a different one and
49
+ * later on the original is adjusted, probably the piggybacking one can
50
+ * be adversely changed.
51
+ *
52
+ * In order to differentiate between platforms/compilers/architectures
53
+ * use only compiler built in predefined preprocessor symbols.
54
+ *
55
+ * This header file shall only export symbols which are 'cares' or 'CARES'
56
+ * prefixed, otherwise public name space would be polluted.
57
+ *
58
+ * NOTE 2:
59
+ * -------
60
+ *
61
+ * Right now you might be staring at file ares_build.h.dist or ares_build.h,
62
+ * this is due to the following reason: file ares_build.h.dist is renamed
63
+ * to ares_build.h when the c-ares source code distribution archive file is
64
+ * created.
65
+ *
66
+ * File ares_build.h.dist is not included in the distribution archive.
67
+ * File ares_build.h is not present in the git tree.
68
+ *
69
+ * The distributed ares_build.h file is only intended to be used on systems
70
+ * which can not run the also distributed configure script.
71
+ *
72
+ * On systems capable of running the configure script, the configure process
73
+ * will overwrite the distributed ares_build.h file with one that is suitable
74
+ * and specific to the library being configured and built, which is generated
75
+ * from the ares_build.h.in template file.
76
+ *
77
+ * If you check out from git on a non-configure platform, you must run the
78
+ * appropriate buildconf* script to set up ares_build.h and other local files.
79
+ *
80
+ */
81
+
82
+ /* ================================================================ */
83
+ /* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
84
+ /* ================================================================ */
85
+
86
+ #ifdef CARES_SIZEOF_LONG
87
+ # error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h"
88
+ Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined
89
+ #endif
90
+
91
+ #ifdef CARES_TYPEOF_ARES_SOCKLEN_T
92
+ # error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
93
+ Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
94
+ #endif
95
+
96
+ #ifdef CARES_SIZEOF_ARES_SOCKLEN_T
97
+ # error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
98
+ Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined
99
+ #endif
100
+
101
+ /* ================================================================ */
102
+ /* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */
103
+ /* ================================================================ */
104
+
105
+ #if defined(__DJGPP__) || defined(__GO32__)
106
+ # define CARES_SIZEOF_LONG 4
107
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
108
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
109
+
110
+ #elif defined(__SALFORDC__)
111
+ # define CARES_SIZEOF_LONG 4
112
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
113
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
114
+
115
+ #elif defined(__BORLANDC__)
116
+ # define CARES_SIZEOF_LONG 4
117
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
118
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
119
+
120
+ #elif defined(__TURBOC__)
121
+ # define CARES_SIZEOF_LONG 4
122
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
123
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
124
+
125
+ #elif defined(__WATCOMC__)
126
+ # define CARES_SIZEOF_LONG 4
127
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
128
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
129
+
130
+ #elif defined(__POCC__)
131
+ # define CARES_SIZEOF_LONG 4
132
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
133
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
134
+
135
+ #elif defined(__LCC__)
136
+ # define CARES_SIZEOF_LONG 4
137
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
138
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
139
+
140
+ #elif defined(__SYMBIAN32__)
141
+ # define CARES_SIZEOF_LONG 4
142
+ # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
143
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
144
+
145
+ #elif defined(__MWERKS__)
146
+ # define CARES_SIZEOF_LONG 4
147
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
148
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
149
+
150
+ #elif defined(_WIN32_WCE)
151
+ # define CARES_SIZEOF_LONG 4
152
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
153
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
154
+
155
+ #elif defined(__MINGW32__)
156
+ # define CARES_SIZEOF_LONG 4
157
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
158
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
159
+
160
+ #elif defined(__VMS)
161
+ # define CARES_SIZEOF_LONG 4
162
+ # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
163
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
164
+
165
+ #elif defined(__OS400__)
166
+ # if defined(__ILEC400__)
167
+ # define CARES_SIZEOF_LONG 4
168
+ # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
169
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
170
+ # define CARES_PULL_SYS_TYPES_H 1
171
+ # define CARES_PULL_SYS_SOCKET_H 1
172
+ # endif
173
+
174
+ #elif defined(__MVS__)
175
+ # if defined(__IBMC__) || defined(__IBMCPP__)
176
+ # if defined(_ILP32)
177
+ # define CARES_SIZEOF_LONG 4
178
+ # elif defined(_LP64)
179
+ # define CARES_SIZEOF_LONG 8
180
+ # endif
181
+ # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
182
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
183
+ # define CARES_PULL_SYS_TYPES_H 1
184
+ # define CARES_PULL_SYS_SOCKET_H 1
185
+ # endif
186
+
187
+ #elif defined(__370__)
188
+ # if defined(__IBMC__) || defined(__IBMCPP__)
189
+ # if defined(_ILP32)
190
+ # define CARES_SIZEOF_LONG 4
191
+ # elif defined(_LP64)
192
+ # define CARES_SIZEOF_LONG 8
193
+ # endif
194
+ # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
195
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
196
+ # define CARES_PULL_SYS_TYPES_H 1
197
+ # define CARES_PULL_SYS_SOCKET_H 1
198
+ # endif
199
+
200
+ #elif defined(TPF)
201
+ # define CARES_SIZEOF_LONG 8
202
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
203
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
204
+
205
+ /* ===================================== */
206
+ /* KEEP MSVC THE PENULTIMATE ENTRY */
207
+ /* ===================================== */
208
+
209
+ #elif defined(_MSC_VER)
210
+ # define CARES_SIZEOF_LONG 4
211
+ # define CARES_TYPEOF_ARES_SOCKLEN_T int
212
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
213
+
214
+ /* ===================================== */
215
+ /* KEEP GENERIC GCC THE LAST ENTRY */
216
+ /* ===================================== */
217
+
218
+ #elif defined(__GNUC__)
219
+ # if defined(__LP64__) || \
220
+ defined(__x86_64__) || defined(__ppc64__)
221
+ # define CARES_SIZEOF_LONG 8
222
+ # elif defined(__ILP32__) || \
223
+ defined(__i386__) || defined(__ppc__) || defined(__arm__)
224
+ # define CARES_SIZEOF_LONG 4
225
+ # endif
226
+ # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
227
+ # define CARES_SIZEOF_ARES_SOCKLEN_T 4
228
+ # define CARES_PULL_SYS_TYPES_H 1
229
+ # define CARES_PULL_SYS_SOCKET_H 1
230
+
231
+ #else
232
+ # error "Unknown non-configure build target!"
233
+ Error Compilation_aborted_Unknown_non_configure_build_target
234
+ #endif
235
+
236
+ /* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */
237
+ /* sys/types.h is required here to properly make type definitions below. */
238
+ #ifdef CARES_PULL_SYS_TYPES_H
239
+ # include <sys/types.h>
240
+ #endif
241
+
242
+ /* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
243
+ /* sys/socket.h is required here to properly make type definitions below. */
244
+ #ifdef CARES_PULL_SYS_SOCKET_H
245
+ # include <sys/socket.h>
246
+ #endif
247
+
248
+ /* Data type definition of ares_socklen_t. */
249
+
250
+ #ifdef CARES_TYPEOF_ARES_SOCKLEN_T
251
+ typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
252
+ #endif
253
+
254
+ /* Undefine UNICODE, as c-ares does not use the ANSI version of functions */
255
+ /* explicitly. */
256
+ #ifdef UNICODE
257
+ # undef UNICODE
258
+ #endif
259
+
260
+ #ifdef _UNICODE
261
+ # undef _UNICODE
262
+ #endif
263
+
264
+ #endif /* __CARES_BUILD_H */
@@ -0,0 +1,636 @@
1
+
2
+ /* Copyright 1998 by the Massachusetts Institute of Technology.
3
+ * Copyright (C) 2007-2013 by Daniel Stenberg
4
+ *
5
+ * Permission to use, copy, modify, and distribute this
6
+ * software and its documentation for any purpose and without
7
+ * fee is hereby granted, provided that the above copyright
8
+ * notice appear in all copies and that both that copyright
9
+ * notice and this permission notice appear in supporting
10
+ * documentation, and that the name of M.I.T. not be used in
11
+ * advertising or publicity pertaining to distribution of the
12
+ * software without specific, written prior permission.
13
+ * M.I.T. makes no representations about the suitability of
14
+ * this software for any purpose. It is provided "as is"
15
+ * without express or implied warranty.
16
+ */
17
+
18
+ #ifndef ARES__H
19
+ #define ARES__H
20
+
21
+ #include "ares_version.h" /* c-ares version defines */
22
+ #include "ares_build.h" /* c-ares build definitions */
23
+ #include "ares_rules.h" /* c-ares rules enforcement */
24
+
25
+ /*
26
+ * Define WIN32 when build target is Win32 API
27
+ */
28
+
29
+ #if (defined(_WIN32) || defined(__WIN32__)) && \
30
+ !defined(WIN32) && !defined(__SYMBIAN32__)
31
+ # define WIN32
32
+ #endif
33
+
34
+ #include <sys/types.h>
35
+
36
+ /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
37
+ libc5-based Linux systems. Only include it on system that are known to
38
+ require it! */
39
+ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
40
+ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
41
+ defined(ANDROID) || defined(__ANDROID__)
42
+ #include <sys/select.h>
43
+ #endif
44
+ #if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
45
+ #include <sys/bsdskt.h>
46
+ #endif
47
+
48
+ #if defined(WATT32)
49
+ # include <netinet/in.h>
50
+ # include <sys/socket.h>
51
+ # include <tcp.h>
52
+ #elif defined(_WIN32_WCE)
53
+ # ifndef WIN32_LEAN_AND_MEAN
54
+ # define WIN32_LEAN_AND_MEAN
55
+ # endif
56
+ # include <windows.h>
57
+ # include <winsock.h>
58
+ #elif defined(WIN32)
59
+ # ifndef WIN32_LEAN_AND_MEAN
60
+ # define WIN32_LEAN_AND_MEAN
61
+ # endif
62
+ # include <windows.h>
63
+ # include <winsock2.h>
64
+ # include <ws2tcpip.h>
65
+ #else
66
+ # include <sys/socket.h>
67
+ # include <netinet/in.h>
68
+ #endif
69
+
70
+ #ifdef __cplusplus
71
+ extern "C" {
72
+ #endif
73
+
74
+ /*
75
+ ** c-ares external API function linkage decorations.
76
+ */
77
+
78
+ #ifdef CARES_STATICLIB
79
+ # define CARES_EXTERN
80
+ #elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
81
+ # if defined(CARES_BUILDING_LIBRARY)
82
+ # define CARES_EXTERN __declspec(dllexport)
83
+ # else
84
+ # define CARES_EXTERN __declspec(dllimport)
85
+ # endif
86
+ #elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING)
87
+ # define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
88
+ #else
89
+ # define CARES_EXTERN
90
+ #endif
91
+
92
+
93
+ #define ARES_SUCCESS 0
94
+
95
+ /* Server error codes (ARES_ENODATA indicates no relevant answer) */
96
+ #define ARES_ENODATA 1
97
+ #define ARES_EFORMERR 2
98
+ #define ARES_ESERVFAIL 3
99
+ #define ARES_ENOTFOUND 4
100
+ #define ARES_ENOTIMP 5
101
+ #define ARES_EREFUSED 6
102
+
103
+ /* Locally generated error codes */
104
+ #define ARES_EBADQUERY 7
105
+ #define ARES_EBADNAME 8
106
+ #define ARES_EBADFAMILY 9
107
+ #define ARES_EBADRESP 10
108
+ #define ARES_ECONNREFUSED 11
109
+ #define ARES_ETIMEOUT 12
110
+ #define ARES_EOF 13
111
+ #define ARES_EFILE 14
112
+ #define ARES_ENOMEM 15
113
+ #define ARES_EDESTRUCTION 16
114
+ #define ARES_EBADSTR 17
115
+
116
+ /* ares_getnameinfo error codes */
117
+ #define ARES_EBADFLAGS 18
118
+
119
+ /* ares_getaddrinfo error codes */
120
+ #define ARES_ENONAME 19
121
+ #define ARES_EBADHINTS 20
122
+
123
+ /* Uninitialized library error code */
124
+ #define ARES_ENOTINITIALIZED 21 /* introduced in 1.7.0 */
125
+
126
+ /* ares_library_init error codes */
127
+ #define ARES_ELOADIPHLPAPI 22 /* introduced in 1.7.0 */
128
+ #define ARES_EADDRGETNETWORKPARAMS 23 /* introduced in 1.7.0 */
129
+
130
+ /* More error codes */
131
+ #define ARES_ECANCELLED 24 /* introduced in 1.7.0 */
132
+
133
+ /* Flag values */
134
+ #define ARES_FLAG_USEVC (1 << 0)
135
+ #define ARES_FLAG_PRIMARY (1 << 1)
136
+ #define ARES_FLAG_IGNTC (1 << 2)
137
+ #define ARES_FLAG_NORECURSE (1 << 3)
138
+ #define ARES_FLAG_STAYOPEN (1 << 4)
139
+ #define ARES_FLAG_NOSEARCH (1 << 5)
140
+ #define ARES_FLAG_NOALIASES (1 << 6)
141
+ #define ARES_FLAG_NOCHECKRESP (1 << 7)
142
+ #define ARES_FLAG_EDNS (1 << 8)
143
+
144
+ /* Option mask values */
145
+ #define ARES_OPT_FLAGS (1 << 0)
146
+ #define ARES_OPT_TIMEOUT (1 << 1)
147
+ #define ARES_OPT_TRIES (1 << 2)
148
+ #define ARES_OPT_NDOTS (1 << 3)
149
+ #define ARES_OPT_UDP_PORT (1 << 4)
150
+ #define ARES_OPT_TCP_PORT (1 << 5)
151
+ #define ARES_OPT_SERVERS (1 << 6)
152
+ #define ARES_OPT_DOMAINS (1 << 7)
153
+ #define ARES_OPT_LOOKUPS (1 << 8)
154
+ #define ARES_OPT_SOCK_STATE_CB (1 << 9)
155
+ #define ARES_OPT_SORTLIST (1 << 10)
156
+ #define ARES_OPT_SOCK_SNDBUF (1 << 11)
157
+ #define ARES_OPT_SOCK_RCVBUF (1 << 12)
158
+ #define ARES_OPT_TIMEOUTMS (1 << 13)
159
+ #define ARES_OPT_ROTATE (1 << 14)
160
+ #define ARES_OPT_EDNSPSZ (1 << 15)
161
+ #define ARES_OPT_NOROTATE (1 << 16)
162
+
163
+ /* Nameinfo flag values */
164
+ #define ARES_NI_NOFQDN (1 << 0)
165
+ #define ARES_NI_NUMERICHOST (1 << 1)
166
+ #define ARES_NI_NAMEREQD (1 << 2)
167
+ #define ARES_NI_NUMERICSERV (1 << 3)
168
+ #define ARES_NI_DGRAM (1 << 4)
169
+ #define ARES_NI_TCP 0
170
+ #define ARES_NI_UDP ARES_NI_DGRAM
171
+ #define ARES_NI_SCTP (1 << 5)
172
+ #define ARES_NI_DCCP (1 << 6)
173
+ #define ARES_NI_NUMERICSCOPE (1 << 7)
174
+ #define ARES_NI_LOOKUPHOST (1 << 8)
175
+ #define ARES_NI_LOOKUPSERVICE (1 << 9)
176
+ /* Reserved for future use */
177
+ #define ARES_NI_IDN (1 << 10)
178
+ #define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
179
+ #define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
180
+
181
+ /* Addrinfo flag values */
182
+ #define ARES_AI_CANONNAME (1 << 0)
183
+ #define ARES_AI_NUMERICHOST (1 << 1)
184
+ #define ARES_AI_PASSIVE (1 << 2)
185
+ #define ARES_AI_NUMERICSERV (1 << 3)
186
+ #define ARES_AI_V4MAPPED (1 << 4)
187
+ #define ARES_AI_ALL (1 << 5)
188
+ #define ARES_AI_ADDRCONFIG (1 << 6)
189
+ /* Reserved for future use */
190
+ #define ARES_AI_IDN (1 << 10)
191
+ #define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
192
+ #define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
193
+ #define ARES_AI_CANONIDN (1 << 13)
194
+
195
+ #define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
196
+ ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
197
+ ARES_AI_ADDRCONFIG)
198
+ #define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
199
+ many sockets */
200
+ #define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
201
+ #define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
202
+ ARES_GETSOCK_MAXNUM)))
203
+
204
+ /* c-ares library initialization flag values */
205
+ #define ARES_LIB_INIT_NONE (0)
206
+ #define ARES_LIB_INIT_WIN32 (1 << 0)
207
+ #define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32)
208
+
209
+
210
+ /*
211
+ * Typedef our socket type
212
+ */
213
+
214
+ #ifndef ares_socket_typedef
215
+ #ifdef WIN32
216
+ typedef SOCKET ares_socket_t;
217
+ #define ARES_SOCKET_BAD INVALID_SOCKET
218
+ #else
219
+ typedef int ares_socket_t;
220
+ #define ARES_SOCKET_BAD -1
221
+ #endif
222
+ #define ares_socket_typedef
223
+ #endif /* ares_socket_typedef */
224
+
225
+ typedef void (*ares_sock_state_cb)(void *data,
226
+ ares_socket_t socket_fd,
227
+ int readable,
228
+ int writable);
229
+
230
+ struct apattern;
231
+
232
+ /* NOTE about the ares_options struct to users and developers.
233
+
234
+ This struct will remain looking like this. It will not be extended nor
235
+ shrunk in future releases, but all new options will be set by ares_set_*()
236
+ options instead of with the ares_init_options() function.
237
+
238
+ Eventually (in a galaxy far far away), all options will be settable by
239
+ ares_set_*() options and the ares_init_options() function will become
240
+ deprecated.
241
+
242
+ When new options are added to c-ares, they are not added to this
243
+ struct. And they are not "saved" with the ares_save_options() function but
244
+ instead we encourage the use of the ares_dup() function. Needless to say,
245
+ if you add config options to c-ares you need to make sure ares_dup()
246
+ duplicates this new option.
247
+
248
+ */
249
+ struct ares_options {
250
+ int flags;
251
+ int timeout; /* in seconds or milliseconds, depending on options */
252
+ int tries;
253
+ int ndots;
254
+ unsigned short udp_port;
255
+ unsigned short tcp_port;
256
+ int socket_send_buffer_size;
257
+ int socket_receive_buffer_size;
258
+ struct in_addr *servers;
259
+ int nservers;
260
+ char **domains;
261
+ int ndomains;
262
+ char *lookups;
263
+ ares_sock_state_cb sock_state_cb;
264
+ void *sock_state_cb_data;
265
+ struct apattern *sortlist;
266
+ int nsort;
267
+ int ednspsz;
268
+ };
269
+
270
+ struct hostent;
271
+ struct timeval;
272
+ struct sockaddr;
273
+ struct ares_channeldata;
274
+
275
+ typedef struct ares_channeldata *ares_channel;
276
+
277
+ typedef void (*ares_callback)(void *arg,
278
+ int status,
279
+ int timeouts,
280
+ unsigned char *abuf,
281
+ int alen);
282
+
283
+ typedef void (*ares_host_callback)(void *arg,
284
+ int status,
285
+ int timeouts,
286
+ struct hostent *hostent);
287
+
288
+ typedef void (*ares_nameinfo_callback)(void *arg,
289
+ int status,
290
+ int timeouts,
291
+ char *node,
292
+ char *service);
293
+
294
+ typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
295
+ int type,
296
+ void *data);
297
+
298
+ typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd,
299
+ int type,
300
+ void *data);
301
+
302
+ CARES_EXTERN int ares_library_init(int flags);
303
+
304
+ CARES_EXTERN int ares_library_init_mem(int flags,
305
+ void *(*amalloc)(size_t size),
306
+ void (*afree)(void *ptr),
307
+ void *(*arealloc)(void *ptr, size_t size));
308
+
309
+ CARES_EXTERN int ares_library_initialized(void);
310
+
311
+ CARES_EXTERN void ares_library_cleanup(void);
312
+
313
+ CARES_EXTERN const char *ares_version(int *version);
314
+
315
+ CARES_EXTERN int ares_init(ares_channel *channelptr);
316
+
317
+ CARES_EXTERN int ares_init_options(ares_channel *channelptr,
318
+ struct ares_options *options,
319
+ int optmask);
320
+
321
+ CARES_EXTERN int ares_save_options(ares_channel channel,
322
+ struct ares_options *options,
323
+ int *optmask);
324
+
325
+ CARES_EXTERN void ares_destroy_options(struct ares_options *options);
326
+
327
+ CARES_EXTERN int ares_dup(ares_channel *dest,
328
+ ares_channel src);
329
+
330
+ CARES_EXTERN void ares_destroy(ares_channel channel);
331
+
332
+ CARES_EXTERN void ares_cancel(ares_channel channel);
333
+
334
+ /* These next 3 configure local binding for the out-going socket
335
+ * connection. Use these to specify source IP and/or network device
336
+ * on multi-homed systems.
337
+ */
338
+ CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip);
339
+
340
+ /* local_ip6 should be 16 bytes in length */
341
+ CARES_EXTERN void ares_set_local_ip6(ares_channel channel,
342
+ const unsigned char* local_ip6);
343
+
344
+ /* local_dev_name should be null terminated. */
345
+ CARES_EXTERN void ares_set_local_dev(ares_channel channel,
346
+ const char* local_dev_name);
347
+
348
+ CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
349
+ ares_sock_create_callback callback,
350
+ void *user_data);
351
+
352
+ CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
353
+ ares_sock_config_callback callback,
354
+ void *user_data);
355
+
356
+ CARES_EXTERN int ares_set_sortlist(ares_channel channel,
357
+ const char *sortstr);
358
+
359
+ CARES_EXTERN void ares_send(ares_channel channel,
360
+ const unsigned char *qbuf,
361
+ int qlen,
362
+ ares_callback callback,
363
+ void *arg);
364
+
365
+ CARES_EXTERN void ares_query(ares_channel channel,
366
+ const char *name,
367
+ int dnsclass,
368
+ int type,
369
+ ares_callback callback,
370
+ void *arg);
371
+
372
+ CARES_EXTERN void ares_search(ares_channel channel,
373
+ const char *name,
374
+ int dnsclass,
375
+ int type,
376
+ ares_callback callback,
377
+ void *arg);
378
+
379
+ CARES_EXTERN void ares_gethostbyname(ares_channel channel,
380
+ const char *name,
381
+ int family,
382
+ ares_host_callback callback,
383
+ void *arg);
384
+
385
+ CARES_EXTERN int ares_gethostbyname_file(ares_channel channel,
386
+ const char *name,
387
+ int family,
388
+ struct hostent **host);
389
+
390
+ CARES_EXTERN void ares_gethostbyaddr(ares_channel channel,
391
+ const void *addr,
392
+ int addrlen,
393
+ int family,
394
+ ares_host_callback callback,
395
+ void *arg);
396
+
397
+ CARES_EXTERN void ares_getnameinfo(ares_channel channel,
398
+ const struct sockaddr *sa,
399
+ ares_socklen_t salen,
400
+ int flags,
401
+ ares_nameinfo_callback callback,
402
+ void *arg);
403
+
404
+ CARES_EXTERN int ares_fds(ares_channel channel,
405
+ fd_set *read_fds,
406
+ fd_set *write_fds);
407
+
408
+ CARES_EXTERN int ares_getsock(ares_channel channel,
409
+ ares_socket_t *socks,
410
+ int numsocks);
411
+
412
+ CARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
413
+ struct timeval *maxtv,
414
+ struct timeval *tv);
415
+
416
+ CARES_EXTERN void ares_process(ares_channel channel,
417
+ fd_set *read_fds,
418
+ fd_set *write_fds);
419
+
420
+ CARES_EXTERN void ares_process_fd(ares_channel channel,
421
+ ares_socket_t read_fd,
422
+ ares_socket_t write_fd);
423
+
424
+ CARES_EXTERN int ares_create_query(const char *name,
425
+ int dnsclass,
426
+ int type,
427
+ unsigned short id,
428
+ int rd,
429
+ unsigned char **buf,
430
+ int *buflen,
431
+ int max_udp_size);
432
+
433
+ CARES_EXTERN int ares_mkquery(const char *name,
434
+ int dnsclass,
435
+ int type,
436
+ unsigned short id,
437
+ int rd,
438
+ unsigned char **buf,
439
+ int *buflen);
440
+
441
+ CARES_EXTERN int ares_expand_name(const unsigned char *encoded,
442
+ const unsigned char *abuf,
443
+ int alen,
444
+ char **s,
445
+ long *enclen);
446
+
447
+ CARES_EXTERN int ares_expand_string(const unsigned char *encoded,
448
+ const unsigned char *abuf,
449
+ int alen,
450
+ unsigned char **s,
451
+ long *enclen);
452
+
453
+ /*
454
+ * NOTE: before c-ares 1.7.0 we would most often use the system in6_addr
455
+ * struct below when ares itself was built, but many apps would use this
456
+ * private version since the header checked a HAVE_* define for it. Starting
457
+ * with 1.7.0 we always declare and use our own to stop relying on the
458
+ * system's one.
459
+ */
460
+ struct ares_in6_addr {
461
+ union {
462
+ unsigned char _S6_u8[16];
463
+ } _S6_un;
464
+ };
465
+
466
+ struct ares_addrttl {
467
+ struct in_addr ipaddr;
468
+ int ttl;
469
+ };
470
+
471
+ struct ares_addr6ttl {
472
+ struct ares_in6_addr ip6addr;
473
+ int ttl;
474
+ };
475
+
476
+ struct ares_srv_reply {
477
+ struct ares_srv_reply *next;
478
+ char *host;
479
+ unsigned short priority;
480
+ unsigned short weight;
481
+ unsigned short port;
482
+ };
483
+
484
+ struct ares_mx_reply {
485
+ struct ares_mx_reply *next;
486
+ char *host;
487
+ unsigned short priority;
488
+ };
489
+
490
+ struct ares_txt_reply {
491
+ struct ares_txt_reply *next;
492
+ unsigned char *txt;
493
+ size_t length; /* length excludes null termination */
494
+ };
495
+
496
+ /* NOTE: This structure is a superset of ares_txt_reply
497
+ */
498
+ struct ares_txt_ext {
499
+ struct ares_txt_ext *next;
500
+ unsigned char *txt;
501
+ size_t length;
502
+ /* 1 - if start of new record
503
+ * 0 - if a chunk in the same record */
504
+ unsigned char record_start;
505
+ };
506
+
507
+ struct ares_naptr_reply {
508
+ struct ares_naptr_reply *next;
509
+ unsigned char *flags;
510
+ unsigned char *service;
511
+ unsigned char *regexp;
512
+ char *replacement;
513
+ unsigned short order;
514
+ unsigned short preference;
515
+ };
516
+
517
+ struct ares_soa_reply {
518
+ char *nsname;
519
+ char *hostmaster;
520
+ unsigned int serial;
521
+ unsigned int refresh;
522
+ unsigned int retry;
523
+ unsigned int expire;
524
+ unsigned int minttl;
525
+ };
526
+
527
+ /*
528
+ ** Parse the buffer, starting at *abuf and of length alen bytes, previously
529
+ ** obtained from an ares_search call. Put the results in *host, if nonnull.
530
+ ** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
531
+ ** their TTLs in that array, and set *naddrttls to the number of addresses
532
+ ** so written.
533
+ */
534
+
535
+ CARES_EXTERN int ares_parse_a_reply(const unsigned char *abuf,
536
+ int alen,
537
+ struct hostent **host,
538
+ struct ares_addrttl *addrttls,
539
+ int *naddrttls);
540
+
541
+ CARES_EXTERN int ares_parse_aaaa_reply(const unsigned char *abuf,
542
+ int alen,
543
+ struct hostent **host,
544
+ struct ares_addr6ttl *addrttls,
545
+ int *naddrttls);
546
+
547
+ CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
548
+ int alen,
549
+ const void *addr,
550
+ int addrlen,
551
+ int family,
552
+ struct hostent **host);
553
+
554
+ CARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf,
555
+ int alen,
556
+ struct hostent **host);
557
+
558
+ CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
559
+ int alen,
560
+ struct ares_srv_reply** srv_out);
561
+
562
+ CARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf,
563
+ int alen,
564
+ struct ares_mx_reply** mx_out);
565
+
566
+ CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
567
+ int alen,
568
+ struct ares_txt_reply** txt_out);
569
+
570
+ CARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
571
+ int alen,
572
+ struct ares_txt_ext** txt_out);
573
+
574
+ CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
575
+ int alen,
576
+ struct ares_naptr_reply** naptr_out);
577
+
578
+ CARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf,
579
+ int alen,
580
+ struct ares_soa_reply** soa_out);
581
+
582
+ CARES_EXTERN void ares_free_string(void *str);
583
+
584
+ CARES_EXTERN void ares_free_hostent(struct hostent *host);
585
+
586
+ CARES_EXTERN void ares_free_data(void *dataptr);
587
+
588
+ CARES_EXTERN const char *ares_strerror(int code);
589
+
590
+ struct ares_addr_node {
591
+ struct ares_addr_node *next;
592
+ int family;
593
+ union {
594
+ struct in_addr addr4;
595
+ struct ares_in6_addr addr6;
596
+ } addr;
597
+ };
598
+
599
+ struct ares_addr_port_node {
600
+ struct ares_addr_port_node *next;
601
+ int family;
602
+ union {
603
+ struct in_addr addr4;
604
+ struct ares_in6_addr addr6;
605
+ } addr;
606
+ int udp_port;
607
+ int tcp_port;
608
+ };
609
+
610
+ CARES_EXTERN int ares_set_servers(ares_channel channel,
611
+ struct ares_addr_node *servers);
612
+ CARES_EXTERN int ares_set_servers_ports(ares_channel channel,
613
+ struct ares_addr_port_node *servers);
614
+
615
+ /* Incomming string format: host[:port][,host[:port]]... */
616
+ CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
617
+ const char* servers);
618
+ CARES_EXTERN int ares_set_servers_ports_csv(ares_channel channel,
619
+ const char* servers);
620
+
621
+ CARES_EXTERN int ares_get_servers(ares_channel channel,
622
+ struct ares_addr_node **servers);
623
+ CARES_EXTERN int ares_get_servers_ports(ares_channel channel,
624
+ struct ares_addr_port_node **servers);
625
+
626
+ CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
627
+ ares_socklen_t size);
628
+
629
+ CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
630
+
631
+
632
+ #ifdef __cplusplus
633
+ }
634
+ #endif
635
+
636
+ #endif /* ARES__H */