diff options
Diffstat (limited to 'src')
21 files changed, 2661 insertions, 23 deletions
diff --git a/src/c-ares/ares_build.h b/src/c-ares/ares_build.h new file mode 100644 index 0000000000..7d69f1e6ae --- /dev/null +++ b/src/c-ares/ares_build.h @@ -0,0 +1,254 @@ +#ifndef __CARES_BUILD_H +#define __CARES_BUILD_H + + +/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. M.I.T. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +/* ================================================================ */ +/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ +/* ================================================================ */ + +/* + * NOTE 1: + * ------- + * + * See file ares_build.h.in, run configure, and forget that this file + * exists it is only used for non-configure systems. + * But you can keep reading if you want ;-) + * + */ + +/* ================================================================ */ +/* NOTES FOR NON-CONFIGURE SYSTEMS */ +/* ================================================================ */ + +/* + * NOTE 1: + * ------- + * + * Nothing in this file is intended to be modified or adjusted by the + * c-ares library user nor by the c-ares library builder. + * + * If you think that something actually needs to be changed, adjusted + * or fixed in this file, then, report it on the c-ares development + * mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ + * + * Try to keep one section per platform, compiler and architecture, + * otherwise, if an existing section is reused for a different one and + * later on the original is adjusted, probably the piggybacking one can + * be adversely changed. + * + * In order to differentiate between platforms/compilers/architectures + * use only compiler built in predefined preprocessor symbols. + * + * This header file shall only export symbols which are 'cares' or 'CARES' + * prefixed, otherwise public name space would be polluted. + * + * NOTE 2: + * ------- + * + * Right now you might be staring at file ares_build.h.dist or ares_build.h, + * this is due to the following reason: file ares_build.h.dist is renamed + * to ares_build.h when the c-ares source code distribution archive file is + * created. + * + * File ares_build.h.dist is not included in the distribution archive. + * File ares_build.h is not present in the git tree. + * + * The distributed ares_build.h file is only intended to be used on systems + * which can not run the also distributed configure script. + * + * On systems capable of running the configure script, the configure process + * will overwrite the distributed ares_build.h file with one that is suitable + * and specific to the library being configured and built, which is generated + * from the ares_build.h.in template file. + * + * If you check out from git on a non-configure platform, you must run the + * appropriate buildconf* script to set up ares_build.h and other local files. + * + */ + +/* ================================================================ */ +/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ +/* ================================================================ */ + +#ifdef CARES_SIZEOF_LONG +# error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h" + Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined +#endif + +#ifdef CARES_TYPEOF_ARES_SOCKLEN_T +# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" + Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined +#endif + +#ifdef CARES_SIZEOF_ARES_SOCKLEN_T +# error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h" + Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined +#endif + +/* ================================================================ */ +/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ +/* ================================================================ */ + +#if defined(__DJGPP__) || defined(__GO32__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__SALFORDC__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__BORLANDC__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__TURBOC__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__WATCOMC__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__POCC__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__LCC__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__SYMBIAN32__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__MWERKS__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(_WIN32_WCE) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__MINGW32__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__VMS) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +#elif defined(__OS400__) +# if defined(__ILEC400__) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(__MVS__) +# if defined(__IBMC__) || defined(__IBMCPP__) +# if defined(_ILP32) +# define CARES_SIZEOF_LONG 4 +# elif defined(_LP64) +# define CARES_SIZEOF_LONG 8 +# endif +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(__370__) +# if defined(__IBMC__) || defined(__IBMCPP__) +# if defined(_ILP32) +# define CARES_SIZEOF_LONG 4 +# elif defined(_LP64) +# define CARES_SIZEOF_LONG 8 +# endif +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(TPF) +# define CARES_SIZEOF_LONG 8 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +/* ===================================== */ +/* KEEP MSVC THE PENULTIMATE ENTRY */ +/* ===================================== */ + +#elif defined(_MSC_VER) +# define CARES_SIZEOF_LONG 4 +# define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 + +/* ===================================== */ +/* KEEP GENERIC GCC THE LAST ENTRY */ +/* ===================================== */ + +#elif defined(__GNUC__) +# if defined(__LP64__) || \ + defined(__x86_64__) || defined(__ppc64__) +# define CARES_SIZEOF_LONG 8 +# elif defined(__ILP32__) || \ + defined(__i386__) || defined(__ppc__) || defined(__arm__) +# define CARES_SIZEOF_LONG 4 +# endif +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_SIZEOF_ARES_SOCKLEN_T 4 +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 + +#else +# error "Unknown non-configure build target!" + Error Compilation_aborted_Unknown_non_configure_build_target +#endif + +/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */ +/* sys/types.h is required here to properly make type definitions below. */ +#ifdef CARES_PULL_SYS_TYPES_H +# include <sys/types.h> +#endif + +/* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ +/* sys/socket.h is required here to properly make type definitions below. */ +#ifdef CARES_PULL_SYS_SOCKET_H +# include <sys/socket.h> +#endif + +/* Data type definition of ares_socklen_t. */ + +#ifdef CARES_TYPEOF_ARES_SOCKLEN_T + typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; +#endif + +#endif /* __CARES_BUILD_H */ diff --git a/src/c-ares/config_darwin/ares_config.h b/src/c-ares/config_darwin/ares_config.h new file mode 100644 index 0000000000..0f5bd4b6a5 --- /dev/null +++ b/src/c-ares/config_darwin/ares_config.h @@ -0,0 +1,523 @@ +/* ares_config.h. Generated from ares_config.h.in by configure. */ +/* ares_config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* define this if ares is built for a big endian system */ +/* #undef ARES_BIG_ENDIAN */ + +/* when building as static part of libcurl */ +/* #undef BUILDING_LIBCURL */ + +/* Defined for build that exposes internal static functions for testing. */ +/* #undef CARES_EXPOSE_STATICS */ + +/* Defined for build with symbol hiding. */ +#define CARES_SYMBOL_HIDING 1 + +/* Definition to make a library symbol externally visible. */ +#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((__visibility__ ("default"))) + +/* Use resolver library to configure cares */ +/* #undef CARES_USE_LIBRESOLV */ + +/* if a /etc/inet dir is being used */ +/* #undef ETC_INET */ + +/* Define to the type of arg 2 for gethostname. */ +#define GETHOSTNAME_TYPE_ARG2 size_t + +/* Define to the type qualifier of arg 1 for getnameinfo. */ +#define GETNAMEINFO_QUAL_ARG1 const + +/* Define to the type of arg 1 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * + +/* Define to the type of arg 2 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG2 socklen_t + +/* Define to the type of args 4 and 6 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG46 socklen_t + +/* Define to the type of arg 7 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG7 int + +/* Specifies the number of arguments to getservbyport_r */ +/* #undef GETSERVBYPORT_R_ARGS */ + +/* Specifies the size of the buffer to pass to getservbyport_r */ +/* #undef GETSERVBYPORT_R_BUFSIZE */ + +/* Define to 1 if you have AF_INET6. */ +#define HAVE_AF_INET6 1 + +/* Define to 1 if you have the <arpa/inet.h> header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */ +#define HAVE_ARPA_NAMESER_COMPAT_H 1 + +/* Define to 1 if you have the <arpa/nameser.h> header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the <assert.h> header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `bitncmp' function. */ +/* #undef HAVE_BITNCMP */ + +/* Define to 1 if bool is an available type. */ +#define HAVE_BOOL_T 1 + +/* Define to 1 if you have the clock_gettime function and monotonic timer. */ +/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */ + +/* Define to 1 if you have the closesocket function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the CloseSocket camel case function. */ +/* #undef HAVE_CLOSESOCKET_CAMEL */ + +/* Define to 1 if you have the connect function. */ +#define HAVE_CONNECT 1 + +/* define if the compiler supports basic C++11 syntax */ +#define HAVE_CXX11 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <errno.h> header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the fcntl function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ +#define HAVE_FCNTL_O_NONBLOCK 1 + +/* Define to 1 if you have the freeaddrinfo function. */ +#define HAVE_FREEADDRINFO 1 + +/* Define to 1 if you have a working getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if the getaddrinfo function is threadsafe. */ +#define HAVE_GETADDRINFO_THREADSAFE 1 + +/* Define to 1 if you have the getenv function. */ +#define HAVE_GETENV 1 + +/* Define to 1 if you have the gethostbyaddr function. */ +#define HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the gethostbyname function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define to 1 if you have the gethostname function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the getnameinfo function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the getservbyport_r function. */ +/* #undef HAVE_GETSERVBYPORT_R */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `if_indextoname' function. */ +#define HAVE_IF_INDEXTONAME 1 + +/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ +#define HAVE_INET_NET_PTON 1 + +/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the ioctl function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have the ioctlsocket function. */ +/* #undef HAVE_IOCTLSOCKET */ + +/* Define to 1 if you have the IoctlSocket camel case function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL */ + +/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. + */ +/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */ + +/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ +/* #undef HAVE_IOCTLSOCKET_FIONBIO */ + +/* Define to 1 if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO 1 + +/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ +#define HAVE_IOCTL_SIOCGIFADDR 1 + +/* Define to 1 if you have the `resolve' library (-lresolve). */ +/* #undef HAVE_LIBRESOLVE */ + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* if your compiler supports LL */ +#define HAVE_LL 1 + +/* Define to 1 if the compiler supports the 'long long' data type. */ +#define HAVE_LONGLONG 1 + +/* Define to 1 if you have the malloc.h header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the memory.h header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the MSG_NOSIGNAL flag. */ +/* #undef HAVE_MSG_NOSIGNAL */ + +/* Define to 1 if you have the <netdb.h> header file. */ +#define HAVE_NETDB_H 1 + +/* Define to 1 if you have the <netinet/in.h> header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the <netinet/tcp.h> header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* Define to 1 if you have the <net/if.h> header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have PF_INET6. */ +#define HAVE_PF_INET6 1 + +/* Define to 1 if you have the recv function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the recvfrom function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the send function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the setsockopt function. */ +#define HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ +/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */ + +/* Define to 1 if you have the <signal.h> header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if sig_atomic_t is an available typedef. */ +#define HAVE_SIG_ATOMIC_T 1 + +/* Define to 1 if sig_atomic_t is already defined as volatile. */ +/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */ + +/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */ +#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 + +/* Define to 1 if you have the socket function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if you have the <socket.h> header file. */ +/* #undef HAVE_SOCKET_H */ + +/* Define to 1 if you have the <stdbool.h> header file. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the strcmpi function. */ +/* #undef HAVE_STRCMPI */ + +/* Define to 1 if you have the strdup function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the stricmp function. */ +/* #undef HAVE_STRICMP */ + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the strncasecmp function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the strncmpi function. */ +/* #undef HAVE_STRNCMPI */ + +/* Define to 1 if you have the strnicmp function. */ +/* #undef HAVE_STRNICMP */ + +/* Define to 1 if you have the <stropts.h> header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if you have struct addrinfo. */ +#define HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if you have struct in6_addr. */ +#define HAVE_STRUCT_IN6_ADDR 1 + +/* Define to 1 if you have struct sockaddr_in6. */ +#define HAVE_STRUCT_SOCKADDR_IN6 1 + +/* if struct sockaddr_storage is defined */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the timeval struct. */ +#define HAVE_STRUCT_TIMEVAL 1 + +/* Define to 1 if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/uio.h> header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the windows.h header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the winsock2.h header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the winsock.h header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the writev function. */ +#define HAVE_WRITEV 1 + +/* Define to 1 if you have the ws2tcpip.h header file. */ +/* #undef HAVE_WS2TCPIP_H */ + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if you need the malloc.h header file even with stdlib.h */ +/* #undef NEED_MALLOC_H */ + +/* Define to 1 if you need the memory.h header file even with stdlib.h */ +/* #undef NEED_MEMORY_H */ + +/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ +/* #undef NEED_REENTRANT */ + +/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */ +/* #undef NEED_THREAD_SAFE */ + +/* cpu-machine-OS */ +#define OS "i386-apple-darwin9.8.0" + +/* Name of package */ +#define PACKAGE "c-ares" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "c-ares" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "c-ares -" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "c-ares" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "-" + +/* a suitable file/device to read random data from */ +#define RANDOM_FILE "/dev/urandom" + +/* Define to the type qualifier pointed by arg 5 for recvfrom. */ +#define RECVFROM_QUAL_ARG5 + +/* Define to the type of arg 1 for recvfrom. */ +#define RECVFROM_TYPE_ARG1 int + +/* Define to the type pointed by arg 2 for recvfrom. */ +#define RECVFROM_TYPE_ARG2 void + +/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */ +#define RECVFROM_TYPE_ARG2_IS_VOID 1 + +/* Define to the type of arg 3 for recvfrom. */ +#define RECVFROM_TYPE_ARG3 size_t + +/* Define to the type of arg 4 for recvfrom. */ +#define RECVFROM_TYPE_ARG4 int + +/* Define to the type pointed by arg 5 for recvfrom. */ +#define RECVFROM_TYPE_ARG5 struct sockaddr + +/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */ +/* #undef RECVFROM_TYPE_ARG5_IS_VOID */ + +/* Define to the type pointed by arg 6 for recvfrom. */ +#define RECVFROM_TYPE_ARG6 socklen_t + +/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */ +/* #undef RECVFROM_TYPE_ARG6_IS_VOID */ + +/* Define to the function return type for recvfrom. */ +#define RECVFROM_TYPE_RETV ssize_t + +/* Define to the type of arg 1 for recv. */ +#define RECV_TYPE_ARG1 int + +/* Define to the type of arg 2 for recv. */ +#define RECV_TYPE_ARG2 void * + +/* Define to the type of arg 3 for recv. */ +#define RECV_TYPE_ARG3 size_t + +/* Define to the type of arg 4 for recv. */ +#define RECV_TYPE_ARG4 int + +/* Define to the function return type for recv. */ +#define RECV_TYPE_RETV ssize_t + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type qualifier of arg 2 for send. */ +#define SEND_QUAL_ARG2 const + +/* Define to the type of arg 1 for send. */ +#define SEND_TYPE_ARG1 int + +/* Define to the type of arg 2 for send. */ +#define SEND_TYPE_ARG2 void * + +/* Define to the type of arg 3 for send. */ +#define SEND_TYPE_ARG3 size_t + +/* Define to the type of arg 4 for send. */ +#define SEND_TYPE_ARG4 int + +/* Define to the function return type for send. */ +#define SEND_TYPE_RETV ssize_t + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `struct in6_addr', as computed by sizeof. */ +#define SIZEOF_STRUCT_IN6_ADDR 16 + +/* The size of `struct in_addr', as computed by sizeof. */ +#define SIZEOF_STRUCT_IN_ADDR 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to disable non-blocking sockets. */ +/* #undef USE_BLOCKING_SOCKETS */ + +/* Version number of package */ +#define VERSION "-" + +/* Define to avoid automatic inclusion of winsock.h */ +/* #undef WIN32_LEAN_AND_MEAN */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to 1 if OS is AIX. */ +#ifndef _ALL_SOURCE +/* # undef _ALL_SOURCE */ +#endif + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Type to use in place of in_addr_t when system does not provide it. */ +/* #undef in_addr_t */ + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +/* #undef size_t */ + +/* the signed version of size_t */ +/* #undef ssize_t */ diff --git a/src/c-ares/config_linux/ares_config.h b/src/c-ares/config_linux/ares_config.h new file mode 100644 index 0000000000..8296bb7b17 --- /dev/null +++ b/src/c-ares/config_linux/ares_config.h @@ -0,0 +1,524 @@ +/* ares_config.h. Generated from ares_config.h.in by configure. */ +/* ares_config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* define this if ares is built for a big endian system */ +/* #undef ARES_BIG_ENDIAN */ + +/* when building as static part of libcurl */ +/* #undef BUILDING_LIBCURL */ + +/* Defined for build that exposes internal static functions for testing. */ +/* #undef CARES_EXPOSE_STATICS */ + +/* Defined for build with symbol hiding. */ +#define CARES_SYMBOL_HIDING 1 + +/* Definition to make a library symbol externally visible. */ +#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((__visibility__ ("default"))) + +/* Use resolver library to configure cares */ +/* #undef CARES_USE_LIBRESOLV */ + +/* if a /etc/inet dir is being used */ +/* #undef ETC_INET */ + +/* Define to the type of arg 2 for gethostname. */ +#define GETHOSTNAME_TYPE_ARG2 size_t + +/* Define to the type qualifier of arg 1 for getnameinfo. */ +#define GETNAMEINFO_QUAL_ARG1 const + +/* Define to the type of arg 1 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * + +/* Define to the type of arg 2 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG2 socklen_t + +/* Define to the type of args 4 and 6 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG46 socklen_t + +/* Define to the type of arg 7 for getnameinfo. */ +#define GETNAMEINFO_TYPE_ARG7 int + +/* Specifies the number of arguments to getservbyport_r */ +#define GETSERVBYPORT_R_ARGS 6 + +/* Specifies the size of the buffer to pass to getservbyport_r */ +#define GETSERVBYPORT_R_BUFSIZE 4096 + +/* Define to 1 if you have AF_INET6. */ +#define HAVE_AF_INET6 1 + +/* Define to 1 if you have the <arpa/inet.h> header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */ +#define HAVE_ARPA_NAMESER_COMPAT_H 1 + +/* Define to 1 if you have the <arpa/nameser.h> header file. */ +#define HAVE_ARPA_NAMESER_H 1 + +/* Define to 1 if you have the <assert.h> header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `bitncmp' function. */ +/* #undef HAVE_BITNCMP */ + +/* Define to 1 if bool is an available type. */ +#define HAVE_BOOL_T 1 + +/* Define to 1 if you have the clock_gettime function and monotonic timer. */ +#define HAVE_CLOCK_GETTIME_MONOTONIC 1 + +/* Define to 1 if you have the closesocket function. */ +/* #undef HAVE_CLOSESOCKET */ + +/* Define to 1 if you have the CloseSocket camel case function. */ +/* #undef HAVE_CLOSESOCKET_CAMEL */ + +/* Define to 1 if you have the connect function. */ +#define HAVE_CONNECT 1 + +/* define if the compiler supports basic C++11 syntax */ +#define HAVE_CXX11 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <errno.h> header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the fcntl function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ +#define HAVE_FCNTL_O_NONBLOCK 1 + +/* Define to 1 if you have the freeaddrinfo function. */ +#define HAVE_FREEADDRINFO 1 + +/* Define to 1 if you have a working getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if the getaddrinfo function is threadsafe. */ +#define HAVE_GETADDRINFO_THREADSAFE 1 + +/* Define to 1 if you have the getenv function. */ +#define HAVE_GETENV 1 + +/* Define to 1 if you have the gethostbyaddr function. */ +#define HAVE_GETHOSTBYADDR 1 + +/* Define to 1 if you have the gethostbyname function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define to 1 if you have the gethostname function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the getnameinfo function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the getservbyport_r function. */ +#define HAVE_GETSERVBYPORT_R 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `if_indextoname' function. */ +#define HAVE_IF_INDEXTONAME 1 + +/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ +/* #undef HAVE_INET_NET_PTON */ + +/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +#define HAVE_INET_NTOP 1 + +/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the ioctl function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have the ioctlsocket function. */ +/* #undef HAVE_IOCTLSOCKET */ + +/* Define to 1 if you have the IoctlSocket camel case function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL */ + +/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. + */ +/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */ + +/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ +/* #undef HAVE_IOCTLSOCKET_FIONBIO */ + +/* Define to 1 if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO 1 + +/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ +#define HAVE_IOCTL_SIOCGIFADDR 1 + +/* Define to 1 if you have the `resolve' library (-lresolve). */ +/* #undef HAVE_LIBRESOLVE */ + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* if your compiler supports LL */ +#define HAVE_LL 1 + +/* Define to 1 if the compiler supports the 'long long' data type. */ +#define HAVE_LONGLONG 1 + +/* Define to 1 if you have the malloc.h header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the memory.h header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the MSG_NOSIGNAL flag. */ +#define HAVE_MSG_NOSIGNAL 1 + +/* Define to 1 if you have the <netdb.h> header file. */ +#define HAVE_NETDB_H 1 + +/* Define to 1 if you have the <netinet/in.h> header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the <netinet/tcp.h> header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* Define to 1 if you have the <net/if.h> header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have PF_INET6. */ +#define HAVE_PF_INET6 1 + +/* Define to 1 if you have the recv function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the recvfrom function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the send function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the setsockopt function. */ +#define HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ +/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */ + +/* Define to 1 if you have the <signal.h> header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if sig_atomic_t is an available typedef. */ +#define HAVE_SIG_ATOMIC_T 1 + +/* Define to 1 if sig_atomic_t is already defined as volatile. */ +/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */ + +/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */ +#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 + +/* Define to 1 if you have the socket function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if you have the <socket.h> header file. */ +/* #undef HAVE_SOCKET_H */ + +/* Define to 1 if you have the <stdbool.h> header file. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the strcmpi function. */ +/* #undef HAVE_STRCMPI */ + +/* Define to 1 if you have the strdup function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the stricmp function. */ +/* #undef HAVE_STRICMP */ + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the strncasecmp function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the strncmpi function. */ +/* #undef HAVE_STRNCMPI */ + +/* Define to 1 if you have the strnicmp function. */ +/* #undef HAVE_STRNICMP */ + +/* Define to 1 if you have the <stropts.h> header file. */ +#define HAVE_STROPTS_H 1 + +/* Define to 1 if you have struct addrinfo. */ +#define HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if you have struct in6_addr. */ +#define HAVE_STRUCT_IN6_ADDR 1 + +/* Define to 1 if you have struct sockaddr_in6. */ +#define HAVE_STRUCT_SOCKADDR_IN6 1 + +/* if struct sockaddr_storage is defined */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the timeval struct. */ +#define HAVE_STRUCT_TIMEVAL 1 + +/* Define to 1 if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/uio.h> header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the windows.h header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the winsock2.h header file. */ +/* #undef HAVE_WINSOCK2_H */ + +/* Define to 1 if you have the winsock.h header file. */ +/* #undef HAVE_WINSOCK_H */ + +/* Define to 1 if you have the writev function. */ +#define HAVE_WRITEV 1 + +/* Define to 1 if you have the ws2tcpip.h header file. */ +/* #undef HAVE_WS2TCPIP_H */ + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if you need the malloc.h header file even with stdlib.h */ +/* #undef NEED_MALLOC_H */ + +/* Define to 1 if you need the memory.h header file even with stdlib.h */ +/* #undef NEED_MEMORY_H */ + +/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ +/* #undef NEED_REENTRANT */ + +/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */ +/* #undef NEED_THREAD_SAFE */ + +/* cpu-machine-OS */ +#define OS "x86_64-unknown-linux-gnu" + +/* Name of package */ +#define PACKAGE "c-ares" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "c-ares" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "c-ares -" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "c-ares" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "-" + +/* a suitable file/device to read random data from */ +#define RANDOM_FILE "/dev/urandom" + +/* Define to the type qualifier pointed by arg 5 for recvfrom. */ +#define RECVFROM_QUAL_ARG5 + +/* Define to the type of arg 1 for recvfrom. */ +#define RECVFROM_TYPE_ARG1 int + +/* Define to the type pointed by arg 2 for recvfrom. */ +#define RECVFROM_TYPE_ARG2 void + +/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */ +#define RECVFROM_TYPE_ARG2_IS_VOID 1 + +/* Define to the type of arg 3 for recvfrom. */ +#define RECVFROM_TYPE_ARG3 size_t + +/* Define to the type of arg 4 for recvfrom. */ +#define RECVFROM_TYPE_ARG4 int + +/* Define to the type pointed by arg 5 for recvfrom. */ +#define RECVFROM_TYPE_ARG5 struct sockaddr + +/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */ +/* #undef RECVFROM_TYPE_ARG5_IS_VOID */ + +/* Define to the type pointed by arg 6 for recvfrom. */ +#define RECVFROM_TYPE_ARG6 socklen_t + +/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */ +/* #undef RECVFROM_TYPE_ARG6_IS_VOID */ + +/* Define to the function return type for recvfrom. */ +#define RECVFROM_TYPE_RETV ssize_t + +/* Define to the type of arg 1 for recv. */ +#define RECV_TYPE_ARG1 int + +/* Define to the type of arg 2 for recv. */ +#define RECV_TYPE_ARG2 void * + +/* Define to the type of arg 3 for recv. */ +#define RECV_TYPE_ARG3 size_t + +/* Define to the type of arg 4 for recv. */ +#define RECV_TYPE_ARG4 int + +/* Define to the function return type for recv. */ +#define RECV_TYPE_RETV ssize_t + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type qualifier of arg 2 for send. */ +#define SEND_QUAL_ARG2 const + +/* Define to the type of arg 1 for send. */ +#define SEND_TYPE_ARG1 int + +/* Define to the type of arg 2 for send. */ +#define SEND_TYPE_ARG2 void * + +/* Define to the type of arg 3 for send. */ +#define SEND_TYPE_ARG3 size_t + +/* Define to the type of arg 4 for send. */ +#define SEND_TYPE_ARG4 int + +/* Define to the function return type for send. */ +#define SEND_TYPE_RETV ssize_t + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `struct in6_addr', as computed by sizeof. */ +#define SIZEOF_STRUCT_IN6_ADDR 16 + +/* The size of `struct in_addr', as computed by sizeof. */ +#define SIZEOF_STRUCT_IN_ADDR 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to disable non-blocking sockets. */ +/* #undef USE_BLOCKING_SOCKETS */ + +/* Version number of package */ +#define VERSION "-" + +/* Define to avoid automatic inclusion of winsock.h */ +/* #undef WIN32_LEAN_AND_MEAN */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to 1 if OS is AIX. */ +#ifndef _ALL_SOURCE +/* # undef _ALL_SOURCE */ +#endif + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Type to use in place of in_addr_t when system does not provide it. */ +/* #undef in_addr_t */ + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +/* #undef size_t */ + +/* the signed version of size_t */ +/* #undef ssize_t */ diff --git a/src/c-ares/gen_build_yaml.py b/src/c-ares/gen_build_yaml.py new file mode 100755 index 0000000000..ae61c7856a --- /dev/null +++ b/src/c-ares/gen_build_yaml.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python2.7 + +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import re +import os +import sys +import yaml + +os.chdir(os.path.dirname(sys.argv[0])+'/../..') + +out = {} + +try: + def gen_ares_build(x): + subprocess.call("third_party/c-ares/buildconf", shell=True) + subprocess.call("third_party/c-ares/configure", shell=True) + + def config_platform(x): + if 'linux' in sys.platform: + return 'src/c-ares/config_linux/ares_config.h' + if 'darwin' in sys.platform: + return 'src/c-ares/config_darwin/ares_config.h' + if not os.path.isfile('third_party/c-ares/ares_config.h'): + gen_ares_build(x) + return 'third_party/c-ares/ares_config.h' + + def ares_build(x): + if os.path.isfile('src/c-ares/ares_build.h'): + return 'src/c-ares/ares_build.h' + if not os.path.isfile('third_party/c-ares/ares_build.h'): + gen_ares_build(x) + return 'third_party/c-ares/ares_build.h' + + out['libs'] = [{ + 'name': 'ares', + 'defaults': 'ares', + 'build': 'private', + 'language': 'c', + 'secure': 'no', + 'src': [ + "third_party/c-ares/ares__close_sockets.c", + "third_party/c-ares/ares__get_hostent.c", + "third_party/c-ares/ares__read_line.c", + "third_party/c-ares/ares__timeval.c", + "third_party/c-ares/ares_cancel.c", + "third_party/c-ares/ares_create_query.c", + "third_party/c-ares/ares_data.c", + "third_party/c-ares/ares_destroy.c", + "third_party/c-ares/ares_expand_name.c", + "third_party/c-ares/ares_expand_string.c", + "third_party/c-ares/ares_fds.c", + "third_party/c-ares/ares_free_hostent.c", + "third_party/c-ares/ares_free_string.c", + "third_party/c-ares/ares_getenv.c", + "third_party/c-ares/ares_gethostbyaddr.c", + "third_party/c-ares/ares_gethostbyname.c", + "third_party/c-ares/ares_getnameinfo.c", + "third_party/c-ares/ares_getopt.c", + "third_party/c-ares/ares_getsock.c", + "third_party/c-ares/ares_init.c", + "third_party/c-ares/ares_library_init.c", + "third_party/c-ares/ares_llist.c", + "third_party/c-ares/ares_mkquery.c", + "third_party/c-ares/ares_nowarn.c", + "third_party/c-ares/ares_options.c", + "third_party/c-ares/ares_parse_a_reply.c", + "third_party/c-ares/ares_parse_aaaa_reply.c", + "third_party/c-ares/ares_parse_mx_reply.c", + "third_party/c-ares/ares_parse_naptr_reply.c", + "third_party/c-ares/ares_parse_ns_reply.c", + "third_party/c-ares/ares_parse_ptr_reply.c", + "third_party/c-ares/ares_parse_soa_reply.c", + "third_party/c-ares/ares_parse_srv_reply.c", + "third_party/c-ares/ares_parse_txt_reply.c", + "third_party/c-ares/ares_platform.c", + "third_party/c-ares/ares_process.c", + "third_party/c-ares/ares_query.c", + "third_party/c-ares/ares_search.c", + "third_party/c-ares/ares_send.c", + "third_party/c-ares/ares_strcasecmp.c", + "third_party/c-ares/ares_strdup.c", + "third_party/c-ares/ares_strerror.c", + "third_party/c-ares/ares_timeout.c", + "third_party/c-ares/ares_version.c", + "third_party/c-ares/ares_writev.c", + "third_party/c-ares/bitncmp.c", + "third_party/c-ares/inet_net_pton.c", + "third_party/c-ares/inet_ntop.c", + "third_party/c-ares/windows_port.c", + ], + 'headers': [ + "third_party/c-ares/ares.h", + "third_party/c-ares/ares_data.h", + "third_party/c-ares/ares_dns.h", + "third_party/c-ares/ares_getenv.h", + "third_party/c-ares/ares_getopt.h", + "third_party/c-ares/ares_inet_net_pton.h", + "third_party/c-ares/ares_iphlpapi.h", + "third_party/c-ares/ares_ipv6.h", + "third_party/c-ares/ares_library_init.h", + "third_party/c-ares/ares_llist.h", + "third_party/c-ares/ares_nowarn.h", + "third_party/c-ares/ares_platform.h", + "third_party/c-ares/ares_private.h", + "third_party/c-ares/ares_rules.h", + "third_party/c-ares/ares_setup.h", + "third_party/c-ares/ares_strcasecmp.h", + "third_party/c-ares/ares_strdup.h", + "third_party/c-ares/ares_version.h", + "third_party/c-ares/bitncmp.h", + "third_party/c-ares/config-win32.h", + "third_party/c-ares/setup_once.h", + "src/c-ares/ares_build.h", + "src/c-ares/config_linux/ares_config.h", + "src/c-ares/config_darwin/ares_config.h" + ], + }] +except: + pass + +print yaml.dump(out) diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 2c0c4abffc..2977639db7 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -233,7 +233,7 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, watch_lb_policy(exec_ctx, chand, lb_policy, state); } GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, chand->resolver, + grpc_resolver_next(exec_ctx, chand->resolver, NULL, &chand->incoming_configuration, &chand->on_config_changed); gpr_mu_unlock(&chand->mu_config); @@ -411,7 +411,9 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, if (chand->resolver != NULL && !chand->started_resolving) { chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, chand->resolver, + // grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent, + // chand->interested_parties); + grpc_resolver_next(exec_ctx, chand->resolver, calld->pollent, &chand->incoming_configuration, &chand->on_config_changed); } @@ -523,13 +525,18 @@ void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, GPR_ASSERT(!chand->resolver); chand->resolver = resolver; GRPC_RESOLVER_REF(resolver, "channel"); - if (!grpc_closure_list_empty(chand->waiting_for_config_closures) || - chand->exit_idle_when_lb_policy_arrives) { - chand->started_resolving = 1; - GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, resolver, &chand->incoming_configuration, - &chand->on_config_changed); - } + // TODO(zyc): check if the following part is needed + // if (!grpc_closure_list_empty(chand->waiting_for_config_closures) || + // chand->exit_idle_when_lb_policy_arrives) { + // chand->started_resolving = 1; + // GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); + // grpc_resolver_next(exec_ctx, resolver, &chand->incoming_configuration, + // &chand->on_config_changed); + // gpr_log(GPR_ERROR, "%" PRIuPTR "%" PRIuPTR "%" + // PRIuPTR, chand->interested_parties->pollset_count, + // chand->interested_parties->pollset_set_count, + // chand->interested_parties->fd_count); + // } gpr_mu_unlock(&chand->mu_config); } @@ -547,7 +554,7 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state( if (!chand->started_resolving && chand->resolver != NULL) { GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); chand->started_resolving = 1; - grpc_resolver_next(exec_ctx, chand->resolver, + grpc_resolver_next(exec_ctx, chand->resolver, NULL, &chand->incoming_configuration, &chand->on_config_changed); } diff --git a/src/core/ext/client_config/resolver.c b/src/core/ext/client_config/resolver.c index eb004455bd..ad9d30b302 100644 --- a/src/core/ext/client_config/resolver.c +++ b/src/core/ext/client_config/resolver.c @@ -36,6 +36,7 @@ void grpc_resolver_init(grpc_resolver *resolver, const grpc_resolver_vtable *vtable) { resolver->vtable = vtable; + resolver->pollset_set = grpc_pollset_set_create(); gpr_ref_init(&resolver->refs, 1); } @@ -62,6 +63,7 @@ void grpc_resolver_unref(grpc_resolver *resolver, void grpc_resolver_unref(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) { #endif if (gpr_unref(&resolver->refs)) { + grpc_pollset_set_destroy(resolver->pollset_set); resolver->vtable->destroy(exec_ctx, resolver); } } @@ -75,8 +77,16 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, resolver->vtable->channel_saw_error(exec_ctx, resolver); } +// void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, +// grpc_client_config **target_config, +// grpc_closure *on_complete) { +// resolver->vtable->next(exec_ctx, resolver, target_config, on_complete); +// } + void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, + grpc_polling_entity *pollent, grpc_client_config **target_config, grpc_closure *on_complete) { - resolver->vtable->next(exec_ctx, resolver, target_config, on_complete); + resolver->vtable->next(exec_ctx, resolver, pollent, target_config, + on_complete); } diff --git a/src/core/ext/client_config/resolver.h b/src/core/ext/client_config/resolver.h index 6ecb5d2774..fd907b2049 100644 --- a/src/core/ext/client_config/resolver.h +++ b/src/core/ext/client_config/resolver.h @@ -45,6 +45,7 @@ typedef struct grpc_resolver_vtable grpc_resolver_vtable; objects */ struct grpc_resolver { const grpc_resolver_vtable *vtable; + grpc_pollset_set *pollset_set; gpr_refcount refs; }; @@ -52,8 +53,12 @@ struct grpc_resolver_vtable { void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*channel_saw_error)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); + // void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, + // grpc_client_config **target_config, grpc_closure + // *on_complete); void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, grpc_closure *on_complete); + grpc_polling_entity *pollent, grpc_client_config **target_config, + grpc_closure *on_complete); }; #ifdef GRPC_RESOLVER_REFCOUNT_DEBUG @@ -87,7 +92,12 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, If resolution is fatally broken, set *target_config to NULL and schedule on_complete. */ +// void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, +// grpc_client_config **target_config, +// grpc_closure *on_complete); + void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, + grpc_polling_entity *pollent, grpc_client_config **target_config, grpc_closure *on_complete); diff --git a/src/core/ext/resolver/dns/c_ares/dns_resolver.c b/src/core/ext/resolver/dns/c_ares/dns_resolver.c new file mode 100644 index 0000000000..9f7b15335f --- /dev/null +++ b/src/core/ext/resolver/dns/c_ares/dns_resolver.c @@ -0,0 +1,374 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/support/port_platform.h> +#include <string.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/host_port.h> +#include <grpc/support/string_util.h> + +#include "src/core/ext/client_config/lb_policy_registry.h" +#include "src/core/ext/client_config/resolver_registry.h" +#include "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/lib/iomgr/resolve_address.h" +#include "src/core/lib/iomgr/timer.h" +#include "src/core/lib/support/backoff.h" +#include "src/core/lib/support/string.h" + +#define BACKOFF_MULTIPLIER 1.6 +#define BACKOFF_JITTER 0.2 +#define BACKOFF_MIN_SECONDS 1 +#define BACKOFF_MAX_SECONDS 120 + +typedef struct { + /** base class: must be first */ + grpc_resolver base; + /** refcount */ + gpr_refcount refs; + /** name to resolve */ + char *name; + /** default port to use */ + char *default_port; + /** subchannel factory */ + grpc_client_channel_factory *client_channel_factory; + /** load balancing policy name */ + char *lb_policy_name; + + /** mutex guarding the rest of the state */ + gpr_mu mu; + /** are we currently resolving? */ + int resolving; + /** which version of resolved_config have we published? */ + int published_version; + /** which version of resolved_config is current? */ + int resolved_version; + /** pending next completion, or NULL */ + grpc_closure *next_completion; + /** target config address for next completion */ + grpc_client_config **target_config; + /** current (fully resolved) config */ + grpc_client_config *resolved_config; + /** retry timer */ + bool have_retry_timer; + grpc_timer retry_timer; + /** retry backoff state */ + gpr_backoff backoff_state; + + /** currently resolving addresses */ + grpc_resolved_addresses *addresses; + + grpc_polling_entity *pollent; +} dns_resolver; + +static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r); + +static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx, + dns_resolver *r); +static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, + dns_resolver *r); + +static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); +static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r); +static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, + grpc_polling_entity *pollent, + grpc_client_config **target_config, + grpc_closure *on_complete); + +static const grpc_resolver_vtable dns_resolver_vtable = { + dns_destroy, dns_shutdown, dns_channel_saw_error, dns_next}; + +static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_mu_lock(&r->mu); + if (r->have_retry_timer) { + grpc_timer_cancel(exec_ctx, &r->retry_timer); + } + if (r->next_completion != NULL) { + *r->target_config = NULL; + grpc_exec_ctx_sched(exec_ctx, r->next_completion, + GRPC_ERROR_CREATE("Resolver Shutdown"), NULL); + r->next_completion = NULL; + } + gpr_mu_unlock(&r->mu); +} + +static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, + grpc_resolver *resolver) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_mu_lock(&r->mu); + if (!r->resolving) { + gpr_backoff_reset(&r->backoff_state); + dns_start_resolving_locked(exec_ctx, r); + } + gpr_mu_unlock(&r->mu); +} + +static void dns_on_retry_timer(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { + dns_resolver *r = arg; + + gpr_mu_lock(&r->mu); + r->have_retry_timer = false; + if (error == GRPC_ERROR_NONE) { + if (!r->resolving) { + dns_start_resolving_locked(exec_ctx, r); + } + } + gpr_mu_unlock(&r->mu); + + GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "retry-timer"); +} + +static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { + gpr_log(GPR_ERROR, "dns_on_resolved"); + dns_resolver *r = arg; + grpc_client_config *config = NULL; + grpc_lb_policy *lb_policy; + gpr_log(GPR_ERROR, "before mu"); + gpr_mu_lock(&r->mu); + gpr_log(GPR_ERROR, "after mu"); + GPR_ASSERT(r->resolving); + r->resolving = 0; + grpc_resolved_addresses *addresses = r->addresses; + if (addresses != NULL) { + gpr_log(GPR_ERROR, "addresses != NULL"); + grpc_lb_policy_args lb_policy_args; + config = grpc_client_config_create(); + memset(&lb_policy_args, 0, sizeof(lb_policy_args)); + lb_policy_args.addresses = addresses; + lb_policy_args.client_channel_factory = r->client_channel_factory; + lb_policy = + grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); + if (lb_policy != NULL) { + grpc_client_config_set_lb_policy(config, lb_policy); + GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction"); + } + if (r->pollent) { + grpc_polling_entity_del_from_pollset_set(exec_ctx, r->pollent, + r->base.pollset_set); + r->pollent = NULL; + } + grpc_resolved_addresses_destroy(addresses); + } else { + gpr_log(GPR_ERROR, "addresses == NULL"); + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now); + gpr_timespec timeout = gpr_time_sub(next_try, now); + const char *msg = grpc_error_string(error); + gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg); + grpc_error_free_string(msg); + GPR_ASSERT(!r->have_retry_timer); + r->have_retry_timer = true; + GRPC_RESOLVER_REF(&r->base, "retry-timer"); + if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) <= 0) { + gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec, + timeout.tv_nsec); + } else { + gpr_log(GPR_DEBUG, "retrying immediately"); + } + grpc_timer_init(exec_ctx, &r->retry_timer, next_try, dns_on_retry_timer, r, + now); + } + if (r->resolved_config) { + grpc_client_config_unref(exec_ctx, r->resolved_config); + } + r->resolved_config = config; + r->resolved_version++; + dns_maybe_finish_next_locked(exec_ctx, r); + gpr_mu_unlock(&r->mu); + gpr_log(GPR_ERROR, "mu_unlock"); + GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving"); + gpr_log(GPR_ERROR, "after GRPC_RESOLVER_UNREF"); +} + +static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, + grpc_polling_entity *pollent, + grpc_client_config **target_config, + grpc_closure *on_complete) { + dns_resolver *r = (dns_resolver *)resolver; + gpr_mu_lock(&r->mu); + GPR_ASSERT(!r->next_completion); + r->next_completion = on_complete; + r->target_config = target_config; + if (r->resolved_version == 0 && !r->resolving) { + gpr_backoff_reset(&r->backoff_state); + gpr_log(GPR_ERROR, "dns_start_resolving_locked"); + GRPC_RESOLVER_REF(&r->base, "dns-resolving"); + GPR_ASSERT(!r->resolving); + r->resolving = 1; + r->addresses = NULL; + r->pollent = NULL; +#ifdef GRPC_NATIVE_ADDRESS_RESOLVE + grpc_resolve_address(exec_ctx, r->name, r->default_port, + grpc_closure_create(dns_on_resolved, r), + &r->addresses); +#else + if (pollent) { + r->pollent = pollent; + grpc_polling_entity_add_to_pollset_set(exec_ctx, pollent, + r->base.pollset_set); + } else { + gpr_log(GPR_ERROR, "pollent is NULL"); + } + grpc_resolve_address_ares( + exec_ctx, r->name, r->default_port, r->base.pollset_set, + grpc_closure_create(dns_on_resolved, r), &r->addresses); +#endif + } else { + dns_maybe_finish_next_locked(exec_ctx, r); + } + gpr_mu_unlock(&r->mu); +} + +static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx, + dns_resolver *r) { + gpr_log(GPR_ERROR, "dns_start_resolving_locked"); + GRPC_RESOLVER_REF(&r->base, "dns-resolving"); + GPR_ASSERT(!r->resolving); + r->resolving = 1; + r->addresses = NULL; +#ifdef GRPC_NATIVE_ADDRESS_RESOLVE + grpc_resolve_address(exec_ctx, r->name, r->default_port, + grpc_closure_create(dns_on_resolved, r), &r->addresses); +#else + grpc_resolve_address_ares( + exec_ctx, r->name, r->default_port, r->base.pollset_set, + grpc_closure_create(dns_on_resolved, r), &r->addresses); +#endif + // grpc_resolve_address(exec_ctx, r->name, r->default_port, + // grpc_closure_create(dns_on_resolved, r), &r->addresses); +} + +static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, + dns_resolver *r) { + if (r->next_completion != NULL && + r->resolved_version != r->published_version) { + *r->target_config = r->resolved_config; + if (r->resolved_config) { + grpc_client_config_ref(r->resolved_config); + } + grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); + r->next_completion = NULL; + r->published_version = r->resolved_version; + } +} + +static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { + dns_resolver *r = (dns_resolver *)gr; + gpr_mu_destroy(&r->mu); +#ifndef GRPC_NATIVE_ADDRESS_RESOLVE + grpc_ares_cleanup(); +#endif + if (r->resolved_config) { + grpc_client_config_unref(exec_ctx, r->resolved_config); + } + grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory); + gpr_free(r->name); + gpr_free(r->default_port); + gpr_free(r->lb_policy_name); + gpr_free(r); +} + +static grpc_resolver *dns_create(grpc_resolver_args *args, + const char *default_port, + const char *lb_policy_name) { + dns_resolver *r; + grpc_error *error = GRPC_ERROR_NONE; + const char *path = args->uri->path; + + if (0 != strcmp(args->uri->authority, "")) { + gpr_log(GPR_ERROR, "authority based dns uri's not supported"); + return NULL; + } + +#ifndef GRPC_NATIVE_ADDRESS_RESOLVE + error = grpc_ares_init(); +#endif + if (error != GRPC_ERROR_NONE) { + GRPC_LOG_IF_ERROR("ares_library_init() failed", error); + return NULL; + } + + if (path[0] == '/') ++path; + + r = gpr_malloc(sizeof(dns_resolver)); + memset(r, 0, sizeof(*r)); + gpr_ref_init(&r->refs, 1); + gpr_mu_init(&r->mu); + grpc_resolver_init(&r->base, &dns_resolver_vtable); + r->name = gpr_strdup(path); + r->default_port = gpr_strdup(default_port); + r->client_channel_factory = args->client_channel_factory; + gpr_backoff_init(&r->backoff_state, BACKOFF_MULTIPLIER, BACKOFF_JITTER, + BACKOFF_MIN_SECONDS * 1000, BACKOFF_MAX_SECONDS * 1000); + grpc_client_channel_factory_ref(r->client_channel_factory); + r->lb_policy_name = gpr_strdup(lb_policy_name); + return &r->base; +} + +/* + * FACTORY + */ + +static void dns_factory_ref(grpc_resolver_factory *factory) {} + +static void dns_factory_unref(grpc_resolver_factory *factory) {} + +static grpc_resolver *dns_factory_create_resolver( + grpc_resolver_factory *factory, grpc_resolver_args *args) { + return dns_create(args, "https", "pick_first"); +} + +static char *dns_factory_get_default_host_name(grpc_resolver_factory *factory, + grpc_uri *uri) { + const char *path = uri->path; + if (path[0] == '/') ++path; + return gpr_strdup(path); +} + +static const grpc_resolver_factory_vtable dns_factory_vtable = { + dns_factory_ref, dns_factory_unref, dns_factory_create_resolver, + dns_factory_get_default_host_name, "dns"}; +static grpc_resolver_factory dns_resolver_factory = {&dns_factory_vtable}; + +static grpc_resolver_factory *dns_resolver_factory_create() { + return &dns_resolver_factory; +} + +void grpc_resolver_dns_ares_init(void) { + grpc_register_resolver_type(dns_resolver_factory_create()); +} + +void grpc_resolver_dns_ares_shutdown(void) {} diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c new file mode 100644 index 0000000000..cd8dfbc326 --- /dev/null +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h" diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h new file mode 100644 index 0000000000..25ba5e59de --- /dev/null +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H +#define GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H + +#include <grpc/support/port_platform.h> +#ifndef GRPC_NATIVE_ADDRESS_RESOLVE + +#include <ares.h> + +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/pollset_set.h" + +typedef struct grpc_ares_ev_driver grpc_ares_ev_driver; + +void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx, + grpc_ares_ev_driver *ev_driver); +void grpc_ares_gethostbyname(grpc_ares_ev_driver *ev_driver, const char *host, + ares_host_callback on_done_cb, void *arg); +ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver); + +grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver, + grpc_pollset_set *pollset_set); +void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver); + +#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */ + +#endif /* GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H */ diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c new file mode 100644 index 0000000000..b65974e1bb --- /dev/null +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c @@ -0,0 +1,205 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include <grpc/support/port_platform.h> +#ifndef GRPC_NATIVE_ADDRESS_RESOLVE +#ifdef GPR_POSIX_SOCKET + +#include "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h" + +#include "src/core/lib/iomgr/ev_posix.h" +#include "src/core/lib/iomgr/sockaddr.h" + +#include <ares.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include <grpc/support/time.h> +#include <grpc/support/useful.h> +#include "src/core/lib/iomgr/iomgr_internal.h" +#include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/unix_sockets_posix.h" +#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/support/string.h" + +typedef struct fd_pair { + grpc_fd *grpc_fd; + int fd; + struct fd_pair *next; +} fd_pair; + +struct grpc_ares_ev_driver { + bool closing; + ares_socket_t socks[ARES_GETSOCK_MAXNUM]; + int bitmask; + grpc_closure driver_closure; + grpc_pollset_set *pollset_set; + ares_channel channel; + fd_pair *fds; +}; + +grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver, + grpc_pollset_set *pollset_set) { + int status; + *ev_driver = gpr_malloc(sizeof(grpc_ares_ev_driver)); + status = ares_init(&(*ev_driver)->channel); + if (status != ARES_SUCCESS) { + gpr_free(*ev_driver); + return GRPC_ERROR_CREATE("Failed to init ares channel"); + } + (*ev_driver)->pollset_set = pollset_set; + (*ev_driver)->fds = NULL; + (*ev_driver)->closing = false; + return GRPC_ERROR_NONE; +} + +void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver) { + // ev_driver->pollset_set = NULL; + ev_driver->closing = true; +} + +static fd_pair *get_fd(fd_pair **head, int fd) { + fd_pair dummy_head; + fd_pair *node; + fd_pair *ret; + dummy_head.next = *head; + node = &dummy_head; + while (node->next != NULL) { + if (node->next->fd == fd) { + ret = node->next; + node->next = node->next->next; + *head = dummy_head.next; + return ret; + } + } + return NULL; +} + +static void driver_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + grpc_ares_ev_driver *d = arg; + size_t i; + gpr_log(GPR_ERROR, "driver_cb"); + if (error == GRPC_ERROR_NONE) { + gpr_log(GPR_ERROR, "GRPC_ERROR_NONE"); + for (i = 0; i < ARES_GETSOCK_MAXNUM; i++) { + ares_process_fd( + d->channel, + ARES_GETSOCK_READABLE(d->bitmask, i) ? d->socks[i] : ARES_SOCKET_BAD, + ARES_GETSOCK_WRITABLE(d->bitmask, i) ? d->socks[i] : ARES_SOCKET_BAD); + } + } + grpc_ares_notify_on_event(exec_ctx, d); + grpc_exec_ctx_flush(exec_ctx); +} + +void grpc_ares_gethostbyname(grpc_ares_ev_driver *ev_driver, const char *host, + ares_host_callback on_done_cb, void *arg) { + ares_gethostbyname(ev_driver->channel, host, AF_UNSPEC, on_done_cb, arg); +} + +ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver) { + return &ev_driver->channel; +} + +void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx, + grpc_ares_ev_driver *ev_driver) { + size_t i; + fd_pair *new_list = NULL; + gpr_log(GPR_ERROR, "\n\n notify_on_event"); + if (!ev_driver->closing) { + ev_driver->bitmask = + ares_getsock(ev_driver->channel, ev_driver->socks, ARES_GETSOCK_MAXNUM); + grpc_closure_init(&ev_driver->driver_closure, driver_cb, ev_driver); + for (i = 0; i < ARES_GETSOCK_MAXNUM; i++) { + char *final_name; + gpr_asprintf(&final_name, "ares_ev_driver-%" PRIuPTR, i); + + if (ARES_GETSOCK_READABLE(ev_driver->bitmask, i) || + ARES_GETSOCK_WRITABLE(ev_driver->bitmask, i)) { + gpr_log(GPR_ERROR, "%d", ev_driver->socks[i]); + fd_pair *fdp = get_fd(&ev_driver->fds, ev_driver->socks[i]); + if (!fdp) { + gpr_log(GPR_ERROR, "new fd"); + fdp = gpr_malloc(sizeof(fd_pair)); + fdp->grpc_fd = grpc_fd_create(ev_driver->socks[i], final_name); + fdp->fd = ev_driver->socks[i]; + grpc_pollset_set_add_fd(exec_ctx, ev_driver->pollset_set, + fdp->grpc_fd); + // new_fd_pair->grpc_fd = fd; + // new_fd_pair->next = ev_driver->fds; + } + fdp->next = new_list; + new_list = fdp; + + if (ARES_GETSOCK_READABLE(ev_driver->bitmask, i)) { + gpr_log(GPR_ERROR, "READABLE"); + + grpc_fd_notify_on_read(exec_ctx, fdp->grpc_fd, + &ev_driver->driver_closure); + } + if (ARES_GETSOCK_WRITABLE(ev_driver->bitmask, i)) { + gpr_log(GPR_ERROR, "writable"); + + grpc_fd_notify_on_write(exec_ctx, fdp->grpc_fd, + &ev_driver->driver_closure); + } + } + gpr_free(final_name); + } + } + + while (ev_driver->fds != NULL) { + fd_pair *cur; + // int fd;s + cur = ev_driver->fds; + ev_driver->fds = ev_driver->fds->next; + gpr_log(GPR_ERROR, "fd in ev_driver: %d\n", cur->fd); + grpc_pollset_set_del_fd(exec_ctx, ev_driver->pollset_set, cur->grpc_fd); + gpr_log(GPR_ERROR, "grpc_pollset_set_del_fd"); + grpc_fd_shutdown(exec_ctx, cur->grpc_fd); + gpr_log(GPR_ERROR, "grpc_fd_shutdown"); + grpc_fd_orphan(exec_ctx, cur->grpc_fd, NULL, NULL, "come on.."); + gpr_log(GPR_ERROR, "grpc_fd_orphan"); + gpr_free(cur); + } + + ev_driver->fds = new_list; + if (ev_driver->closing) { + ares_destroy(ev_driver->channel); + gpr_free(ev_driver); + } + + gpr_log(GPR_ERROR, "eof notify_on_event"); +} + +#endif /* GPR_POSIX_SOCKET */ +#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */ diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c new file mode 100644 index 0000000000..1c03351b75 --- /dev/null +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c @@ -0,0 +1,327 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/support/port_platform.h> +#ifndef GRPC_NATIVE_ADDRESS_RESOLVE + +#include "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/lib/iomgr/sockaddr.h" + +#include <string.h> +#include <sys/types.h> + +#include <ares.h> +#include <grpc/support/alloc.h> +#include <grpc/support/host_port.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include <grpc/support/thd.h> +#include <grpc/support/time.h> +#include <grpc/support/useful.h> +#include "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h" +#include "src/core/lib/iomgr/executor.h" +#include "src/core/lib/iomgr/iomgr_internal.h" +#include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/unix_sockets_posix.h" +#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/support/string.h" + +static gpr_once g_basic_init = GPR_ONCE_INIT; +static gpr_mu g_init_mu; + +typedef struct grpc_ares_request { + char *name; + char *host; + char *port; + char *default_port; + grpc_polling_entity *pollent; + grpc_closure *on_done; + grpc_resolved_addresses **addrs_out; + grpc_closure request_closure; + void *arg; + int pending_quries; + int success; + grpc_ares_ev_driver *ev_driver; +} grpc_ares_request; + +static void do_basic_init(void) { gpr_mu_init(&g_init_mu); } + +static void destroy_request(grpc_ares_request *request) { + grpc_ares_ev_driver_destroy(request->ev_driver); + + // ares_cancel(request->channel); + // ares_destroy(request->channel); + gpr_free(request->name); + gpr_free(request->host); + gpr_free(request->port); + gpr_free(request->default_port); +} + +static uint16_t strhtons(const char *port) { + if (strcmp(port, "http") == 0) { + return htons(80); + } else if (strcmp(port, "https") == 0) { + return htons(443); + } + return htons((unsigned short)atoi(port)); +} + +static void on_done_cb(void *arg, int status, int timeouts, + struct hostent *hostent) { + gpr_log(GPR_ERROR, "status: %d", status); + grpc_ares_request *r = (grpc_ares_request *)arg; + grpc_error *err = GRPC_ERROR_NONE; + gpr_log(GPR_ERROR, "status: %s", r->name); + grpc_resolved_addresses **addresses = r->addrs_out; + size_t i; + size_t prev_naddr; + + if (status == ARES_SUCCESS) { + gpr_log(GPR_ERROR, "status ARES_SUCCESS"); + GRPC_ERROR_UNREF(err); + err = GRPC_ERROR_NONE; + r->success = 1; + if (*addresses == NULL) { + *addresses = gpr_malloc(sizeof(grpc_resolved_addresses)); + (*addresses)->naddrs = 0; + (*addresses)->addrs = NULL; + } + + prev_naddr = (*addresses)->naddrs; + for (i = 0; hostent->h_addr_list[i] != NULL; i++) { + } + (*addresses)->naddrs += i; + + gpr_log(GPR_ERROR, "naddr: %" PRIuPTR, (*addresses)->naddrs); + (*addresses)->addrs = + gpr_realloc((*addresses)->addrs, + sizeof(grpc_resolved_address) * (*addresses)->naddrs); + + for (i = prev_naddr; i < (*addresses)->naddrs; i++) { + if (hostent->h_addrtype == AF_INET6) { + char output[INET6_ADDRSTRLEN]; + gpr_log(GPR_ERROR, "AF_INET6"); + struct sockaddr_in6 *addr; + + (*addresses)->addrs[i].len = sizeof(struct sockaddr_in6); + addr = (struct sockaddr_in6 *)&(*addresses)->addrs[i].addr; + + memcpy(&addr->sin6_addr, hostent->h_addr_list[i - prev_naddr], + sizeof(struct in6_addr)); + ares_inet_ntop(AF_INET6, &addr->sin6_addr, output, INET6_ADDRSTRLEN); + gpr_log(GPR_ERROR, "addr: %s", output); + gpr_log(GPR_ERROR, "port: %s", r->port); + addr->sin6_family = (sa_family_t)hostent->h_addrtype; + addr->sin6_port = strhtons(r->port); + } else { + char output[INET_ADDRSTRLEN]; + gpr_log(GPR_ERROR, "AF_INET"); + struct sockaddr_in *addr; + + (*addresses)->addrs[i].len = sizeof(struct sockaddr_in); + addr = (struct sockaddr_in *)&(*addresses)->addrs[i].addr; + + memcpy(&addr->sin_addr, hostent->h_addr_list[i - prev_naddr], + sizeof(struct in_addr)); + ares_inet_ntop(AF_INET, &addr->sin_addr, output, INET_ADDRSTRLEN); + gpr_log(GPR_ERROR, "addr: %s", output); + gpr_log(GPR_ERROR, "port: %s", r->port); + addr->sin_family = (sa_family_t)hostent->h_addrtype; + addr->sin_port = strhtons(r->port); + } + } + // ares_destroy(r->channel); + } else if (!r->success) { + gpr_log(GPR_ERROR, "status not ARES_SUCCESS"); + // TODO(zyc): add more error detail + if (err == GRPC_ERROR_NONE) { + err = GRPC_ERROR_CREATE("C-ares query error"); + } + } + if (--r->pending_quries == 0) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_exec_ctx_sched(&exec_ctx, r->on_done, err, NULL); + grpc_exec_ctx_flush(&exec_ctx); + grpc_exec_ctx_finish(&exec_ctx); + + destroy_request(r); + gpr_free(r); + } +} + +static void request_resolving_address(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { + grpc_ares_request *r = (grpc_ares_request *)arg; + grpc_ares_ev_driver *ev_driver = r->ev_driver; + ares_channel *channel = grpc_ares_ev_driver_get_channel(ev_driver); + gpr_log(GPR_ERROR, "before ares_gethostbyname %s", r->host); + r->pending_quries = 2; + ares_gethostbyname(*channel, r->host, AF_INET, on_done_cb, r); + ares_gethostbyname(*channel, r->host, AF_INET6, on_done_cb, r); + // grpc_ares_gethostbyname(r->ev_driver, r->host, on_dones_cb, r); + gpr_log(GPR_ERROR, "before ares_getsock"); + grpc_ares_notify_on_event(exec_ctx, ev_driver); + gpr_log(GPR_ERROR, "eof resolve_address_impl"); +} + +static int try_fake_resolve(const char *name, const char *port, + grpc_resolved_addresses **addresses) { + struct sockaddr_in sa; + struct sockaddr_in6 sa6; + memset(&sa, 0, sizeof(struct sockaddr_in)); + memset(&sa6, 0, sizeof(struct sockaddr_in6)); + if (0 != ares_inet_pton(AF_INET, name, &(sa.sin_addr))) { + gpr_log(GPR_ERROR, "AF_INET"); + *addresses = gpr_malloc(sizeof(grpc_resolved_addresses)); + (*addresses)->naddrs = 1; + (*addresses)->addrs = + gpr_malloc(sizeof(grpc_resolved_address) * (*addresses)->naddrs); + (*addresses)->addrs[0].len = sizeof(struct sockaddr_in); + sa.sin_family = AF_INET; + sa.sin_port = strhtons(port); + memcpy(&(*addresses)->addrs[0].addr, &sa, sizeof(struct sockaddr_in)); + return 1; + } + if (0 != ares_inet_pton(AF_INET6, name, &(sa6.sin6_addr))) { + char output[INET6_ADDRSTRLEN]; + gpr_log(GPR_ERROR, "AF_INET6"); + *addresses = gpr_malloc(sizeof(grpc_resolved_addresses)); + (*addresses)->naddrs = 1; + (*addresses)->addrs = + gpr_malloc(sizeof(grpc_resolved_address) * (*addresses)->naddrs); + (*addresses)->addrs[0].len = sizeof(struct sockaddr_in6); + sa6.sin6_family = AF_INET6; + sa6.sin6_port = strhtons(port); + memcpy(&(*addresses)->addrs[0].addr, &sa6, sizeof(struct sockaddr_in6)); + ares_inet_ntop(AF_INET6, &sa6.sin6_addr, output, INET6_ADDRSTRLEN); + gpr_log(GPR_ERROR, "addr: %s", output); + gpr_log(GPR_ERROR, "port: %s", port); + + return 1; + } + return 0; +} + +void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name, + const char *default_port, + grpc_pollset_set *pollset_set, + grpc_closure *on_done, + grpc_resolved_addresses **addrs) { + char *host; + char *port; + grpc_error *err; + grpc_ares_request *r = NULL; + grpc_ares_ev_driver *ev_driver; + + if ((err = grpc_customized_resolve_address(name, default_port, addrs)) != + GRPC_ERROR_CANCELLED) { + grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); + return; + } + + if (name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'x' && + name[4] == ':' && name[5] != 0) { + grpc_exec_ctx_sched(exec_ctx, on_done, + grpc_resolve_unix_domain_address(name + 5, addrs), + NULL); + return; + } + + /* parse name, splitting it into host and port parts */ + gpr_split_host_port(name, &host, &port); + if (host == NULL) { + err = grpc_error_set_str(GRPC_ERROR_CREATE("unparseable host:port"), + GRPC_ERROR_STR_TARGET_ADDRESS, name); + grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); + goto done; + } else if (port == NULL) { + if (default_port == NULL) { + err = grpc_error_set_str(GRPC_ERROR_CREATE("no port in name"), + GRPC_ERROR_STR_TARGET_ADDRESS, name); + grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); + goto done; + } + port = gpr_strdup(default_port); + } + + if (try_fake_resolve(host, port, addrs)) { + grpc_exec_ctx_sched(exec_ctx, on_done, GRPC_ERROR_NONE, NULL); + } else { + err = grpc_ares_ev_driver_create(&ev_driver, pollset_set); + if (err != GRPC_ERROR_NONE) { + grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); + return; + } + r = gpr_malloc(sizeof(grpc_ares_request)); + r->ev_driver = ev_driver; + r->on_done = on_done; + r->addrs_out = addrs; + r->name = gpr_strdup(name); + r->default_port = gpr_strdup(default_port); + r->port = gpr_strdup(port); + r->host = gpr_strdup(host); + r->pending_quries = 0; + r->success = 0; + grpc_closure_init(&r->request_closure, request_resolving_address, r); + grpc_exec_ctx_sched(exec_ctx, &r->request_closure, GRPC_ERROR_NONE, NULL); + } + +done: + gpr_free(host); + gpr_free(port); +} + +void (*grpc_resolve_address_ares)( + grpc_exec_ctx *exec_ctx, const char *name, const char *default_port, + grpc_pollset_set *pollset_set, grpc_closure *on_done, + grpc_resolved_addresses **addrs) = grpc_resolve_address_ares_impl; + +grpc_error *grpc_ares_init(void) { + gpr_once_init(&g_basic_init, do_basic_init); + gpr_mu_lock(&g_init_mu); + int status = ares_library_init(ARES_LIB_INIT_ALL); + gpr_mu_unlock(&g_init_mu); + + if (status != ARES_SUCCESS) { + return GRPC_ERROR_CREATE("ares_library_init failed"); + } + return GRPC_ERROR_NONE; +} + +void grpc_ares_cleanup(void) { + gpr_mu_lock(&g_init_mu); + ares_library_cleanup(); + gpr_mu_unlock(&g_init_mu); +} + +#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */ diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h new file mode 100644 index 0000000000..753eb12b96 --- /dev/null +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -0,0 +1,61 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H +#define GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H + +#include <grpc/support/port_platform.h> +#ifndef GRPC_NATIVE_ADDRESS_RESOLVE + +#include <stddef.h> +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/iomgr.h" +#include "src/core/lib/iomgr/polling_entity.h" +#include "src/core/lib/iomgr/resolve_address.h" + +// typedef struct grpc_ares_request grpc_ares_request; + +extern void (*grpc_resolve_address_ares)(grpc_exec_ctx *exec_ctx, + const char *addr, + const char *default_port, + grpc_pollset_set *pollset_set, + grpc_closure *on_done, + grpc_resolved_addresses **addresses); + +grpc_error *grpc_ares_init(void); + +void grpc_ares_cleanup(void); + +#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */ + +#endif /* GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H */ diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 1f7cce2f43..792e2c3c02 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -79,6 +79,7 @@ static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, + grpc_polling_entity *pollent, grpc_client_config **target_config, grpc_closure *on_complete); @@ -108,6 +109,7 @@ static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, } static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, + grpc_polling_entity *pollent, grpc_client_config **target_config, grpc_closure *on_complete) { sockaddr_resolver *r = (sockaddr_resolver *)resolver; diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index ddbe375755..7a770662cc 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -66,4 +66,11 @@ extern grpc_error *(*grpc_blocking_resolve_address)( const char *name, const char *default_port, grpc_resolved_addresses **addresses); +/* Returns GRPC_ERROR_CANCELLED by default. If it's overriden and returns + error other than GRPC_ERROR_CANCELLED, grpc_resolve_address will use its + result. Result must be freed with grpc_resolved_addresses_destroy. */ +extern grpc_error *(*grpc_customized_resolve_address)( + const char *name, const char *default_port, + grpc_resolved_addresses **addresses); + #endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ diff --git a/src/core/lib/iomgr/resolve_address_posix.c b/src/core/lib/iomgr/resolve_address_posix.c index 4e9f978584..4012dcc61f 100644 --- a/src/core/lib/iomgr/resolve_address_posix.c +++ b/src/core/lib/iomgr/resolve_address_posix.c @@ -149,6 +149,17 @@ grpc_error *(*grpc_blocking_resolve_address)( const char *name, const char *default_port, grpc_resolved_addresses **addresses) = blocking_resolve_address_impl; +static grpc_error *default_customized_resolve_address_impl( + const char *name, const char *default_port, + grpc_resolved_addresses **addresses) { + return GRPC_ERROR_CANCELLED; +} + +grpc_error *(*grpc_customized_resolve_address)( + const char *name, const char *default_port, + grpc_resolved_addresses **addresses) = + default_customized_resolve_address_impl; + typedef struct { char *name; char *default_port; @@ -183,7 +194,16 @@ static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name, const char *default_port, grpc_closure *on_done, grpc_resolved_addresses **addrs) { - request *r = gpr_malloc(sizeof(request)); + request *r; + grpc_error *err; + + if ((err = grpc_customized_resolve_address(name, default_port, addrs)) != + GRPC_ERROR_CANCELLED) { + grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); + return; + } + + r = gpr_malloc(sizeof(request)); grpc_closure_init(&r->request_closure, do_request_thread, r); r->name = gpr_strdup(name); r->default_port = gpr_strdup(default_port); diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.c index 2af8af82dc..f7f331aa94 100644 --- a/src/core/lib/iomgr/resolve_address_windows.c +++ b/src/core/lib/iomgr/resolve_address_windows.c @@ -143,6 +143,17 @@ grpc_error *(*grpc_blocking_resolve_address)( const char *name, const char *default_port, grpc_resolved_addresses **addresses) = blocking_resolve_address_impl; +static grpc_error *default_customized_resolve_address_impl( + const char *name, const char *default_port, + grpc_resolved_addresses **addresses) { + return GRPC_ERROR_CANCELLED; +} + +grpc_error *(*grpc_customized_resolve_address)( + const char *name, const char *default_port, + grpc_resolved_addresses **addresses) = + default_customized_resolve_address_impl; + /* Callback to be passed to grpc_executor to asynch-ify * grpc_blocking_resolve_address */ static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp, @@ -171,7 +182,16 @@ static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name, const char *default_port, grpc_closure *on_done, grpc_resolved_addresses **addresses) { - request *r = gpr_malloc(sizeof(request)); + request *r; + grpc_error *err; + + if ((err = grpc_customized_resolve_address(name, default_port, addresses)) != + GRPC_ERROR_CANCELLED) { + grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL); + return; + } + + r = gpr_malloc(sizeof(request)); grpc_closure_init(&r->request_closure, do_request_thread, r); r->name = gpr_strdup(name); r->default_port = gpr_strdup(default_port); diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.c index 7a7a9ce477..7ebd312b5a 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.c +++ b/src/core/plugin_registry/grpc_plugin_registry.c @@ -43,8 +43,8 @@ extern void grpc_lb_policy_pick_first_init(void); extern void grpc_lb_policy_pick_first_shutdown(void); extern void grpc_lb_policy_round_robin_init(void); extern void grpc_lb_policy_round_robin_shutdown(void); -extern void grpc_resolver_dns_native_init(void); -extern void grpc_resolver_dns_native_shutdown(void); +extern void grpc_resolver_dns_ares_init(void); +extern void grpc_resolver_dns_ares_shutdown(void); extern void grpc_resolver_sockaddr_init(void); extern void grpc_resolver_sockaddr_shutdown(void); extern void grpc_load_reporting_plugin_init(void); @@ -63,8 +63,8 @@ void grpc_register_built_in_plugins(void) { grpc_lb_policy_pick_first_shutdown); grpc_register_plugin(grpc_lb_policy_round_robin_init, grpc_lb_policy_round_robin_shutdown); - grpc_register_plugin(grpc_resolver_dns_native_init, - grpc_resolver_dns_native_shutdown); + grpc_register_plugin(grpc_resolver_dns_ares_init, + grpc_resolver_dns_ares_shutdown); grpc_register_plugin(grpc_resolver_sockaddr_init, grpc_resolver_sockaddr_shutdown); grpc_register_plugin(grpc_load_reporting_plugin_init, diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c index ad4ddf0ff4..72dc10e77f 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c @@ -37,8 +37,8 @@ extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); extern void grpc_client_config_init(void); extern void grpc_client_config_shutdown(void); -extern void grpc_resolver_dns_native_init(void); -extern void grpc_resolver_dns_native_shutdown(void); +extern void grpc_resolver_dns_ares_init(void); +extern void grpc_resolver_dns_ares_shutdown(void); extern void grpc_resolver_sockaddr_init(void); extern void grpc_resolver_sockaddr_shutdown(void); extern void grpc_load_reporting_plugin_init(void); @@ -57,8 +57,8 @@ void grpc_register_built_in_plugins(void) { grpc_chttp2_plugin_shutdown); grpc_register_plugin(grpc_client_config_init, grpc_client_config_shutdown); - grpc_register_plugin(grpc_resolver_dns_native_init, - grpc_resolver_dns_native_shutdown); + grpc_register_plugin(grpc_resolver_dns_ares_init, + grpc_resolver_dns_ares_shutdown); grpc_register_plugin(grpc_resolver_sockaddr_init, grpc_resolver_sockaddr_shutdown); grpc_register_plugin(grpc_load_reporting_plugin_init, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 7ae76f52c1..c5e57477e0 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -248,7 +248,9 @@ CORE_SOURCE_FILES = [ 'third_party/nanopb/pb_encode.c', 'src/core/ext/lb_policy/pick_first/pick_first.c', 'src/core/ext/lb_policy/round_robin/round_robin.c', - 'src/core/ext/resolver/dns/native/dns_resolver.c', + 'src/core/ext/resolver/dns/c_ares/dns_resolver.c', + 'src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c', + 'src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c', 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c', 'src/core/ext/load_reporting/load_reporting.c', 'src/core/ext/load_reporting/load_reporting_filter.c', @@ -577,4 +579,53 @@ CORE_SOURCE_FILES = [ 'third_party/zlib/trees.c', 'third_party/zlib/uncompr.c', 'third_party/zlib/zutil.c', + 'third_party/c-ares/ares__close_sockets.c', + 'third_party/c-ares/ares__get_hostent.c', + 'third_party/c-ares/ares__read_line.c', + 'third_party/c-ares/ares__timeval.c', + 'third_party/c-ares/ares_cancel.c', + 'third_party/c-ares/ares_create_query.c', + 'third_party/c-ares/ares_data.c', + 'third_party/c-ares/ares_destroy.c', + 'third_party/c-ares/ares_expand_name.c', + 'third_party/c-ares/ares_expand_string.c', + 'third_party/c-ares/ares_fds.c', + 'third_party/c-ares/ares_free_hostent.c', + 'third_party/c-ares/ares_free_string.c', + 'third_party/c-ares/ares_getenv.c', + 'third_party/c-ares/ares_gethostbyaddr.c', + 'third_party/c-ares/ares_gethostbyname.c', + 'third_party/c-ares/ares_getnameinfo.c', + 'third_party/c-ares/ares_getopt.c', + 'third_party/c-ares/ares_getsock.c', + 'third_party/c-ares/ares_init.c', + 'third_party/c-ares/ares_library_init.c', + 'third_party/c-ares/ares_llist.c', + 'third_party/c-ares/ares_mkquery.c', + 'third_party/c-ares/ares_nowarn.c', + 'third_party/c-ares/ares_options.c', + 'third_party/c-ares/ares_parse_a_reply.c', + 'third_party/c-ares/ares_parse_aaaa_reply.c', + 'third_party/c-ares/ares_parse_mx_reply.c', + 'third_party/c-ares/ares_parse_naptr_reply.c', + 'third_party/c-ares/ares_parse_ns_reply.c', + 'third_party/c-ares/ares_parse_ptr_reply.c', + 'third_party/c-ares/ares_parse_soa_reply.c', + 'third_party/c-ares/ares_parse_srv_reply.c', + 'third_party/c-ares/ares_parse_txt_reply.c', + 'third_party/c-ares/ares_platform.c', + 'third_party/c-ares/ares_process.c', + 'third_party/c-ares/ares_query.c', + 'third_party/c-ares/ares_search.c', + 'third_party/c-ares/ares_send.c', + 'third_party/c-ares/ares_strcasecmp.c', + 'third_party/c-ares/ares_strdup.c', + 'third_party/c-ares/ares_strerror.c', + 'third_party/c-ares/ares_timeout.c', + 'third_party/c-ares/ares_version.c', + 'third_party/c-ares/ares_writev.c', + 'third_party/c-ares/bitncmp.c', + 'third_party/c-ares/inet_net_pton.c', + 'third_party/c-ares/inet_ntop.c', + 'third_party/c-ares/windows_port.c', ] diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 6d65db8306..4be7e58c96 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -70,6 +70,7 @@ ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/ ENV['EMBED_OPENSSL'] = 'true' ENV['EMBED_ZLIB'] = 'true' +ENV['EMBED_CARES'] = 'true' ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG'] ENV['ARCH_FLAGS'] = '-arch i386 -arch x86_64' if RUBY_PLATFORM =~ /darwin/ ENV['CFLAGS'] = '-DGPR_BACKWARDS_COMPATIBILITY_MODE' |