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
@@ -0,0 +1,63 @@
1
+
2
+ /* Copyright (C) 2004 by Daniel Stenberg et al
3
+ *
4
+ * Permission to use, copy, modify, and distribute this software and its
5
+ * documentation for any purpose and without fee is hereby granted, provided
6
+ * that the above copyright notice appear in all copies and that both that
7
+ * copyright notice and this permission notice appear in supporting
8
+ * documentation, and that the name of M.I.T. not be used in advertising or
9
+ * publicity pertaining to distribution of the software without specific,
10
+ * written prior permission. M.I.T. makes no representations about the
11
+ * suitability of this software for any purpose. It is provided "as is"
12
+ * without express or implied warranty.
13
+ */
14
+
15
+ #include "ares_setup.h"
16
+ #include <assert.h>
17
+
18
+ #include "ares.h"
19
+ #include "ares_private.h"
20
+
21
+ /*
22
+ * ares_cancel() cancels all ongoing requests/resolves that might be going on
23
+ * on the given channel. It does NOT kill the channel, use ares_destroy() for
24
+ * that.
25
+ */
26
+ void ares_cancel(ares_channel channel)
27
+ {
28
+ struct query *query;
29
+ struct list_node list_head_copy;
30
+ struct list_node* list_head;
31
+ struct list_node* list_node;
32
+ int i;
33
+
34
+ if (!ares__is_list_empty(&(channel->all_queries)))
35
+ {
36
+ /* Swap list heads, so that only those queries which were present on entry
37
+ * into this function are cancelled. New queries added by callbacks of
38
+ * queries being cancelled will not be cancelled themselves.
39
+ */
40
+ list_head = &(channel->all_queries);
41
+ list_head_copy.prev = list_head->prev;
42
+ list_head_copy.next = list_head->next;
43
+ list_head_copy.prev->next = &list_head_copy;
44
+ list_head_copy.next->prev = &list_head_copy;
45
+ list_head->prev = list_head;
46
+ list_head->next = list_head;
47
+ for (list_node = list_head_copy.next; list_node != &list_head_copy; )
48
+ {
49
+ query = list_node->data;
50
+ list_node = list_node->next; /* since we're deleting the query */
51
+ query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
52
+ ares__free_query(query);
53
+ }
54
+ }
55
+ if (!(channel->flags & ARES_FLAG_STAYOPEN) && ares__is_list_empty(&(channel->all_queries)))
56
+ {
57
+ if (channel->servers)
58
+ {
59
+ for (i = 0; i < channel->nservers; i++)
60
+ ares__close_sockets(channel, &channel->servers[i]);
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,202 @@
1
+
2
+ /* Copyright 1998 by the Massachusetts Institute of Technology.
3
+ *
4
+ * Permission to use, copy, modify, and distribute this
5
+ * software and its documentation for any purpose and without
6
+ * fee is hereby granted, provided that the above copyright
7
+ * notice appear in all copies and that both that copyright
8
+ * notice and this permission notice appear in supporting
9
+ * documentation, and that the name of M.I.T. not be used in
10
+ * advertising or publicity pertaining to distribution of the
11
+ * software without specific, written prior permission.
12
+ * M.I.T. makes no representations about the suitability of
13
+ * this software for any purpose. It is provided "as is"
14
+ * without express or implied warranty.
15
+ */
16
+
17
+ #include "ares_setup.h"
18
+
19
+ #ifdef HAVE_NETINET_IN_H
20
+ # include <netinet/in.h>
21
+ #endif
22
+ #ifdef HAVE_ARPA_NAMESER_H
23
+ # include <arpa/nameser.h>
24
+ #else
25
+ # include "nameser.h"
26
+ #endif
27
+ #ifdef HAVE_ARPA_NAMESER_COMPAT_H
28
+ # include <arpa/nameser_compat.h>
29
+ #endif
30
+
31
+ #include "ares.h"
32
+ #include "ares_dns.h"
33
+ #include "ares_private.h"
34
+
35
+ #ifndef T_OPT
36
+ # define T_OPT 41 /* EDNS0 option (meta-RR) */
37
+ #endif
38
+
39
+ /* Header format, from RFC 1035:
40
+ * 1 1 1 1 1 1
41
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
42
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
43
+ * | ID |
44
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
45
+ * |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
46
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
47
+ * | QDCOUNT |
48
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
49
+ * | ANCOUNT |
50
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
51
+ * | NSCOUNT |
52
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
53
+ * | ARCOUNT |
54
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
55
+ *
56
+ * AA, TC, RA, and RCODE are only set in responses. Brief description
57
+ * of the remaining fields:
58
+ * ID Identifier to match responses with queries
59
+ * QR Query (0) or response (1)
60
+ * Opcode For our purposes, always QUERY
61
+ * RD Recursion desired
62
+ * Z Reserved (zero)
63
+ * QDCOUNT Number of queries
64
+ * ANCOUNT Number of answers
65
+ * NSCOUNT Number of name server records
66
+ * ARCOUNT Number of additional records
67
+ *
68
+ * Question format, from RFC 1035:
69
+ * 1 1 1 1 1 1
70
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
71
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
72
+ * | |
73
+ * / QNAME /
74
+ * / /
75
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
76
+ * | QTYPE |
77
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
78
+ * | QCLASS |
79
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
80
+ *
81
+ * The query name is encoded as a series of labels, each represented
82
+ * as a one-byte length (maximum 63) followed by the text of the
83
+ * label. The list is terminated by a label of length zero (which can
84
+ * be thought of as the root domain).
85
+ */
86
+
87
+ int ares_create_query(const char *name, int dnsclass, int type,
88
+ unsigned short id, int rd, unsigned char **bufp,
89
+ int *buflenp, int max_udp_size)
90
+ {
91
+ size_t len;
92
+ unsigned char *q;
93
+ const char *p;
94
+ size_t buflen;
95
+ unsigned char *buf;
96
+
97
+ /* Set our results early, in case we bail out early with an error. */
98
+ *buflenp = 0;
99
+ *bufp = NULL;
100
+
101
+ /* Allocate a memory area for the maximum size this packet might need. +2
102
+ * is for the length byte and zero termination if no dots or ecscaping is
103
+ * used.
104
+ */
105
+ len = strlen(name) + 2 + HFIXEDSZ + QFIXEDSZ +
106
+ (max_udp_size ? EDNSFIXEDSZ : 0);
107
+ buf = ares_malloc(len);
108
+ if (!buf)
109
+ return ARES_ENOMEM;
110
+
111
+ /* Set up the header. */
112
+ q = buf;
113
+ memset(q, 0, HFIXEDSZ);
114
+ DNS_HEADER_SET_QID(q, id);
115
+ DNS_HEADER_SET_OPCODE(q, QUERY);
116
+ if (rd) {
117
+ DNS_HEADER_SET_RD(q, 1);
118
+ }
119
+ else {
120
+ DNS_HEADER_SET_RD(q, 0);
121
+ }
122
+ DNS_HEADER_SET_QDCOUNT(q, 1);
123
+
124
+ if (max_udp_size) {
125
+ DNS_HEADER_SET_ARCOUNT(q, 1);
126
+ }
127
+
128
+ /* A name of "." is a screw case for the loop below, so adjust it. */
129
+ if (strcmp(name, ".") == 0)
130
+ name++;
131
+
132
+ /* Start writing out the name after the header. */
133
+ q += HFIXEDSZ;
134
+ while (*name)
135
+ {
136
+ if (*name == '.') {
137
+ free (buf);
138
+ return ARES_EBADNAME;
139
+ }
140
+
141
+ /* Count the number of bytes in this label. */
142
+ len = 0;
143
+ for (p = name; *p && *p != '.'; p++)
144
+ {
145
+ if (*p == '\\' && *(p + 1) != 0)
146
+ p++;
147
+ len++;
148
+ }
149
+ if (len > MAXLABEL) {
150
+ free (buf);
151
+ return ARES_EBADNAME;
152
+ }
153
+
154
+ /* Encode the length and copy the data. */
155
+ *q++ = (unsigned char)len;
156
+ for (p = name; *p && *p != '.'; p++)
157
+ {
158
+ if (*p == '\\' && *(p + 1) != 0)
159
+ p++;
160
+ *q++ = *p;
161
+ }
162
+
163
+ /* Go to the next label and repeat, unless we hit the end. */
164
+ if (!*p)
165
+ break;
166
+ name = p + 1;
167
+ }
168
+
169
+ /* Add the zero-length label at the end. */
170
+ *q++ = 0;
171
+
172
+ /* Finish off the question with the type and class. */
173
+ DNS_QUESTION_SET_TYPE(q, type);
174
+ DNS_QUESTION_SET_CLASS(q, dnsclass);
175
+
176
+ q += QFIXEDSZ;
177
+ if (max_udp_size)
178
+ {
179
+ memset(q, 0, EDNSFIXEDSZ);
180
+ q++;
181
+ DNS_RR_SET_TYPE(q, T_OPT);
182
+ DNS_RR_SET_CLASS(q, max_udp_size);
183
+ q += (EDNSFIXEDSZ-1);
184
+ }
185
+ buflen = (q - buf);
186
+
187
+ /* Reject names that are longer than the maximum of 255 bytes that's
188
+ * specified in RFC 1035 ("To simplify implementations, the total length of
189
+ * a domain name (i.e., label octets and label length octets) is restricted
190
+ * to 255 octets or less."). */
191
+ if (buflen > (MAXCDNAME + HFIXEDSZ + QFIXEDSZ +
192
+ (max_udp_size ? EDNSFIXEDSZ : 0))) {
193
+ free (buf);
194
+ return ARES_EBADNAME;
195
+ }
196
+
197
+ /* we know this fits in an int at this point */
198
+ *buflenp = (int) buflen;
199
+ *bufp = buf;
200
+
201
+ return ARES_SUCCESS;
202
+ }
@@ -0,0 +1,221 @@
1
+
2
+ /* Copyright (C) 2009-2013 by Daniel Stenberg
3
+ *
4
+ * Permission to use, copy, modify, and distribute this
5
+ * software and its documentation for any purpose and without
6
+ * fee is hereby granted, provided that the above copyright
7
+ * notice appear in all copies and that both that copyright
8
+ * notice and this permission notice appear in supporting
9
+ * documentation, and that the name of M.I.T. not be used in
10
+ * advertising or publicity pertaining to distribution of the
11
+ * software without specific, written prior permission.
12
+ * M.I.T. makes no representations about the suitability of
13
+ * this software for any purpose. It is provided "as is"
14
+ * without express or implied warranty.
15
+ */
16
+
17
+
18
+ #include "ares_setup.h"
19
+
20
+ #include <stddef.h>
21
+
22
+ #include "ares.h"
23
+ #include "ares_data.h"
24
+ #include "ares_private.h"
25
+
26
+
27
+ /*
28
+ ** ares_free_data() - c-ares external API function.
29
+ **
30
+ ** This function must be used by the application to free data memory that
31
+ ** has been internally allocated by some c-ares function and for which a
32
+ ** pointer has already been returned to the calling application. The list
33
+ ** of c-ares functions returning pointers that must be free'ed using this
34
+ ** function is:
35
+ **
36
+ ** ares_get_servers()
37
+ ** ares_parse_srv_reply()
38
+ ** ares_parse_txt_reply()
39
+ */
40
+
41
+ void ares_free_data(void *dataptr)
42
+ {
43
+ struct ares_data *ptr;
44
+
45
+ if (!dataptr)
46
+ return;
47
+
48
+ #ifdef __INTEL_COMPILER
49
+ # pragma warning(push)
50
+ # pragma warning(disable:1684)
51
+ /* 1684: conversion from pointer to same-sized integral type */
52
+ #endif
53
+
54
+ ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
55
+
56
+ #ifdef __INTEL_COMPILER
57
+ # pragma warning(pop)
58
+ #endif
59
+
60
+ if (ptr->mark != ARES_DATATYPE_MARK)
61
+ return;
62
+
63
+ switch (ptr->type)
64
+ {
65
+ case ARES_DATATYPE_MX_REPLY:
66
+
67
+ if (ptr->data.mx_reply.next)
68
+ ares_free_data(ptr->data.mx_reply.next);
69
+ if (ptr->data.mx_reply.host)
70
+ ares_free(ptr->data.mx_reply.host);
71
+ break;
72
+
73
+ case ARES_DATATYPE_SRV_REPLY:
74
+
75
+ if (ptr->data.srv_reply.next)
76
+ ares_free_data(ptr->data.srv_reply.next);
77
+ if (ptr->data.srv_reply.host)
78
+ ares_free(ptr->data.srv_reply.host);
79
+ break;
80
+
81
+ case ARES_DATATYPE_TXT_REPLY:
82
+ case ARES_DATATYPE_TXT_EXT:
83
+
84
+ if (ptr->data.txt_reply.next)
85
+ ares_free_data(ptr->data.txt_reply.next);
86
+ if (ptr->data.txt_reply.txt)
87
+ ares_free(ptr->data.txt_reply.txt);
88
+ break;
89
+
90
+ case ARES_DATATYPE_ADDR_NODE:
91
+
92
+ if (ptr->data.addr_node.next)
93
+ ares_free_data(ptr->data.addr_node.next);
94
+ break;
95
+
96
+ case ARES_DATATYPE_ADDR_PORT_NODE:
97
+
98
+ if (ptr->data.addr_port_node.next)
99
+ ares_free_data(ptr->data.addr_port_node.next);
100
+ break;
101
+
102
+ case ARES_DATATYPE_NAPTR_REPLY:
103
+
104
+ if (ptr->data.naptr_reply.next)
105
+ ares_free_data(ptr->data.naptr_reply.next);
106
+ if (ptr->data.naptr_reply.flags)
107
+ ares_free(ptr->data.naptr_reply.flags);
108
+ if (ptr->data.naptr_reply.service)
109
+ ares_free(ptr->data.naptr_reply.service);
110
+ if (ptr->data.naptr_reply.regexp)
111
+ ares_free(ptr->data.naptr_reply.regexp);
112
+ if (ptr->data.naptr_reply.replacement)
113
+ ares_free(ptr->data.naptr_reply.replacement);
114
+ break;
115
+
116
+ case ARES_DATATYPE_SOA_REPLY:
117
+ if (ptr->data.soa_reply.nsname)
118
+ ares_free(ptr->data.soa_reply.nsname);
119
+ if (ptr->data.soa_reply.hostmaster)
120
+ ares_free(ptr->data.soa_reply.hostmaster);
121
+ break;
122
+
123
+ default:
124
+ return;
125
+ }
126
+
127
+ ares_free(ptr);
128
+ }
129
+
130
+
131
+ /*
132
+ ** ares_malloc_data() - c-ares internal helper function.
133
+ **
134
+ ** This function allocates memory for a c-ares private ares_data struct
135
+ ** for the specified ares_datatype, initializes c-ares private fields
136
+ ** and zero initializes those which later might be used from the public
137
+ ** API. It returns an interior pointer which can be passed by c-ares
138
+ ** functions to the calling application, and that must be free'ed using
139
+ ** c-ares external API function ares_free_data().
140
+ */
141
+
142
+ void *ares_malloc_data(ares_datatype type)
143
+ {
144
+ struct ares_data *ptr;
145
+
146
+ ptr = ares_malloc(sizeof(struct ares_data));
147
+ if (!ptr)
148
+ return NULL;
149
+
150
+ switch (type)
151
+ {
152
+ case ARES_DATATYPE_MX_REPLY:
153
+ ptr->data.mx_reply.next = NULL;
154
+ ptr->data.mx_reply.host = NULL;
155
+ ptr->data.mx_reply.priority = 0;
156
+ break;
157
+
158
+ case ARES_DATATYPE_SRV_REPLY:
159
+ ptr->data.srv_reply.next = NULL;
160
+ ptr->data.srv_reply.host = NULL;
161
+ ptr->data.srv_reply.priority = 0;
162
+ ptr->data.srv_reply.weight = 0;
163
+ ptr->data.srv_reply.port = 0;
164
+ break;
165
+
166
+ case ARES_DATATYPE_TXT_EXT:
167
+ ptr->data.txt_ext.record_start = 0;
168
+ /* FALLTHROUGH */
169
+
170
+ case ARES_DATATYPE_TXT_REPLY:
171
+ ptr->data.txt_reply.next = NULL;
172
+ ptr->data.txt_reply.txt = NULL;
173
+ ptr->data.txt_reply.length = 0;
174
+ break;
175
+
176
+ case ARES_DATATYPE_ADDR_NODE:
177
+ ptr->data.addr_node.next = NULL;
178
+ ptr->data.addr_node.family = 0;
179
+ memset(&ptr->data.addr_node.addrV6, 0,
180
+ sizeof(ptr->data.addr_node.addrV6));
181
+ break;
182
+
183
+ case ARES_DATATYPE_ADDR_PORT_NODE:
184
+ ptr->data.addr_port_node.next = NULL;
185
+ ptr->data.addr_port_node.family = 0;
186
+ ptr->data.addr_port_node.udp_port = 0;
187
+ ptr->data.addr_port_node.tcp_port = 0;
188
+ memset(&ptr->data.addr_port_node.addrV6, 0,
189
+ sizeof(ptr->data.addr_port_node.addrV6));
190
+ break;
191
+
192
+ case ARES_DATATYPE_NAPTR_REPLY:
193
+ ptr->data.naptr_reply.next = NULL;
194
+ ptr->data.naptr_reply.flags = NULL;
195
+ ptr->data.naptr_reply.service = NULL;
196
+ ptr->data.naptr_reply.regexp = NULL;
197
+ ptr->data.naptr_reply.replacement = NULL;
198
+ ptr->data.naptr_reply.order = 0;
199
+ ptr->data.naptr_reply.preference = 0;
200
+ break;
201
+
202
+ case ARES_DATATYPE_SOA_REPLY:
203
+ ptr->data.soa_reply.nsname = NULL;
204
+ ptr->data.soa_reply.hostmaster = NULL;
205
+ ptr->data.soa_reply.serial = 0;
206
+ ptr->data.soa_reply.refresh = 0;
207
+ ptr->data.soa_reply.retry = 0;
208
+ ptr->data.soa_reply.expire = 0;
209
+ ptr->data.soa_reply.minttl = 0;
210
+ break;
211
+
212
+ default:
213
+ ares_free(ptr);
214
+ return NULL;
215
+ }
216
+
217
+ ptr->mark = ARES_DATATYPE_MARK;
218
+ ptr->type = type;
219
+
220
+ return &ptr->data;
221
+ }