From e16d506a58d46619c05b08f3f8ef4d5491b18b69 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 20 Jul 2012 10:01:46 -0700 Subject: [PATCH] uv: Upgrade to ad382bca --- deps/uv/AUTHORS | 16 + deps/uv/Makefile | 4 +- deps/uv/include/ares.h | 33 +- deps/uv/include/ares_version.h | 8 +- deps/uv/include/uv-private/uv-unix.h | 16 +- deps/uv/include/uv.h | 71 +- deps/uv/src/ares/CHANGES | 1221 +-------------------- deps/uv/src/ares/CMakeLists.txt | 22 - deps/uv/src/ares/README.node | 21 - deps/uv/src/ares/RELEASE-NOTES | 28 +- deps/uv/src/ares/ares__get_hostent.c | 7 +- deps/uv/src/ares/ares_data.c | 45 +- deps/uv/src/ares/ares_data.h | 14 +- deps/uv/src/ares/ares_destroy.c | 8 +- deps/uv/src/ares/ares_dns.h | 27 +- deps/uv/src/ares/ares_expand_name.c | 11 +- deps/uv/src/ares/ares_gethostbyname.c | 5 +- deps/uv/src/ares/ares_getnameinfo.c | 4 +- deps/uv/src/ares/ares_init.c | 886 +++++++++------ deps/uv/src/ares/ares_library_init.h | 2 +- deps/uv/src/ares/ares_nowarn.c | 94 +- deps/uv/src/ares/ares_nowarn.h | 10 +- deps/uv/src/ares/ares_parse_aaaa_reply.c | 4 +- deps/uv/src/ares/ares_parse_naptr_reply.c | 188 ++++ deps/uv/src/ares/ares_parse_ptr_reply.c | 5 +- deps/uv/src/ares/ares_parse_soa_reply.c | 135 +++ deps/uv/src/ares/ares_private.h | 2 +- deps/uv/src/ares/ares_process.c | 23 +- deps/uv/src/ares/ares_send.c | 2 +- deps/uv/src/ares/ares_setup.h | 26 +- deps/uv/src/ares/ares_timeout.c | 21 +- deps/uv/src/ares/setup_once.h | 42 +- deps/uv/src/unix/async.c | 33 +- deps/uv/src/unix/core.c | 135 ++- deps/uv/src/unix/darwin.c | 3 +- deps/uv/src/unix/freebsd.c | 18 +- deps/uv/src/unix/internal.h | 2 + deps/uv/src/unix/linux/syscalls.c | 108 ++ deps/uv/src/unix/linux/syscalls.h | 31 + deps/uv/src/unix/pipe.c | 35 +- deps/uv/src/unix/stream.c | 62 ++ deps/uv/src/unix/sunos.c | 20 +- deps/uv/src/unix/tcp.c | 154 +-- deps/uv/src/unix/thread.c | 40 - deps/uv/test/benchmark-ares.c | 2 +- deps/uv/test/benchmark-async-pummel.c | 97 ++ deps/uv/test/benchmark-async.c | 137 +++ deps/uv/test/benchmark-fs-stat.c | 29 - deps/uv/test/benchmark-list.h | 17 + deps/uv/test/runner-unix.c | 5 + deps/uv/test/runner.c | 29 + deps/uv/test/task.h | 3 + deps/uv/test/test-hrtime.c | 2 +- deps/uv/test/test-list.h | 2 - deps/uv/test/test-poll-close.c | 5 - deps/uv/test/test-process-title.c | 13 +- deps/uv/test/test-spawn.c | 14 +- deps/uv/test/test-tcp-unexpected-read.c | 111 -- deps/uv/uv.gyp | 6 +- 59 files changed, 1970 insertions(+), 2144 deletions(-) delete mode 100644 deps/uv/src/ares/CMakeLists.txt delete mode 100644 deps/uv/src/ares/README.node create mode 100644 deps/uv/src/ares/ares_parse_naptr_reply.c create mode 100644 deps/uv/src/ares/ares_parse_soa_reply.c create mode 100644 deps/uv/test/benchmark-async-pummel.c create mode 100644 deps/uv/test/benchmark-async.c delete mode 100644 deps/uv/test/test-tcp-unexpected-read.c diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 37452ac892..d28143bbf7 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -43,3 +43,19 @@ Paddy Byers Dan VerWeire Brandon Benvie Brandon Philips +Nathan Rajlich +Brandon Philips +Charlie McConnell +Vladimir Dronnikov +Aaron Bieber +Bulat Shakirzyanov +Brian White +Erik Dubbelboer +Keno Fischer +Ira Cooper +Andrius Bentkus +Brian White +Iñaki Baz Castillo +Mark Cavage +George Yohng +Xidorn Quan diff --git a/deps/uv/Makefile b/deps/uv/Makefile index cf1e7880bf..e79b7a0c31 100644 --- a/deps/uv/Makefile +++ b/deps/uv/Makefile @@ -24,7 +24,7 @@ ifdef MSVC uname_S := MINGW endif -CPPFLAGS += -Iinclude -Iinclude/uv-private +CPPFLAGS += -Iinclude -Iinclude/uv-private -Isrc/ares CARES_OBJS = CARES_OBJS += src/ares/ares__close_sockets.o @@ -53,8 +53,10 @@ CARES_OBJS += src/ares/ares_options.o CARES_OBJS += src/ares/ares_parse_a_reply.o CARES_OBJS += src/ares/ares_parse_aaaa_reply.o CARES_OBJS += src/ares/ares_parse_mx_reply.o +CARES_OBJS += src/ares/ares_parse_naptr_reply.o CARES_OBJS += src/ares/ares_parse_ns_reply.o CARES_OBJS += src/ares/ares_parse_ptr_reply.o +CARES_OBJS += src/ares/ares_parse_soa_reply.o CARES_OBJS += src/ares/ares_parse_srv_reply.o CARES_OBJS += src/ares/ares_parse_txt_reply.o CARES_OBJS += src/ares/ares_process.o diff --git a/deps/uv/include/ares.h b/deps/uv/include/ares.h index 53ac861b2c..96eccabdae 100644 --- a/deps/uv/include/ares.h +++ b/deps/uv/include/ares.h @@ -85,7 +85,8 @@ typedef int ares_socklen_t; libc5-based Linux systems. Only include it on system that are known to require it! */ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ - defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) + defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ + defined(ANDROID) || defined(__ANDROID__) #include #endif #if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) @@ -513,6 +514,26 @@ struct ares_txt_reply { size_t length; /* length excludes null termination */ }; +struct ares_naptr_reply { + struct ares_naptr_reply *next; + unsigned char *flags; + unsigned char *service; + unsigned char *regexp; + char *replacement; + unsigned short order; + unsigned short preference; +}; + +struct ares_soa_reply { + char *nsname; + char *hostmaster; + unsigned int serial; + unsigned int refresh; + unsigned int retry; + unsigned int expire; + unsigned int minttl; +}; + /* ** Parse the buffer, starting at *abuf and of length alen bytes, previously ** obtained from an ares_search call. Put the results in *host, if nonnull. @@ -556,10 +577,20 @@ CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf, int alen, struct ares_txt_reply** txt_out); +CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf, + int alen, + struct ares_naptr_reply** naptr_out); + +CARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf, + int alen, + struct ares_soa_reply** soa_out); + CARES_EXTERN void ares_free_string(void *str); CARES_EXTERN void ares_free_hostent(struct hostent *host); +CARES_EXTERN void ares_free_soa(struct ares_soa_reply *soa); + CARES_EXTERN void ares_free_data(void *dataptr); CARES_EXTERN const char *ares_strerror(int code); diff --git a/deps/uv/include/ares_version.h b/deps/uv/include/ares_version.h index efd0156dd1..84b97cd085 100644 --- a/deps/uv/include/ares_version.h +++ b/deps/uv/include/ares_version.h @@ -3,15 +3,15 @@ #define ARES__VERSION_H /* This is the global package copyright */ -#define ARES_COPYRIGHT "2004 - 2010 Daniel Stenberg, ." +#define ARES_COPYRIGHT "2004 - 2012 Daniel Stenberg, ." #define ARES_VERSION_MAJOR 1 -#define ARES_VERSION_MINOR 7 -#define ARES_VERSION_PATCH 5 +#define ARES_VERSION_MINOR 9 +#define ARES_VERSION_PATCH 0 #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ (ARES_VERSION_MINOR<<8)|\ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.7.5-DEV" +#define ARES_VERSION_STR "1.9.0-DEV" #if (ARES_VERSION >= 0x010700) # define CARES_HAVE_ARES_LIBRARY_INIT 1 diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h index 7b86c0ea6d..91c0d20ccd 100644 --- a/deps/uv/include/uv-private/uv-unix.h +++ b/deps/uv/include/uv-private/uv-unix.h @@ -40,17 +40,10 @@ #include #include +#include #include #include -#if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include -#else -# include -#endif - #if __sun # include # include @@ -74,11 +67,7 @@ typedef pthread_once_t uv_once_t; typedef pthread_t uv_thread_t; typedef pthread_mutex_t uv_mutex_t; typedef pthread_rwlock_t uv_rwlock_t; -#if defined(__APPLE__) && defined(__MACH__) -typedef semaphore_t uv_sem_t; -#else typedef sem_t uv_sem_t; -#endif /* Platform-specific definitions for uv_spawn support. */ typedef gid_t uv_gid_t; @@ -113,7 +102,7 @@ struct uv__io_s { int inotify_fd; #elif defined(PORT_SOURCE_FILE) # define UV_LOOP_PRIVATE_PLATFORM_FIELDS \ - ev_io fs_event_watcher; \ + uv__io_t fs_event_watcher; \ int fs_fd; #else # define UV_LOOP_PRIVATE_PLATFORM_FIELDS @@ -303,7 +292,6 @@ struct uv__io_s { #ifdef PORT_SOURCE_FILE # define UV_FS_EVENT_PRIVATE_FIELDS \ - ev_io event_watcher; \ uv_fs_event_cb cb; \ file_obj_t fo; \ int fd; diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index dbea113a3e..bf95fdef7b 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -49,7 +49,7 @@ extern "C" { #define UV_VERSION_MAJOR 0 -#define UV_VERSION_MINOR 8 +#define UV_VERSION_MINOR 9 #include /* int64_t */ @@ -181,7 +181,7 @@ typedef enum { } uv_req_type; - +/* Handle types. */ typedef struct uv_loop_s uv_loop_t; typedef struct uv_ares_task_s uv_ares_task_t; typedef struct uv_err_s uv_err_t; @@ -197,23 +197,25 @@ typedef struct uv_prepare_s uv_prepare_t; typedef struct uv_check_s uv_check_t; typedef struct uv_idle_s uv_idle_t; typedef struct uv_async_s uv_async_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; typedef struct uv_process_s uv_process_t; -typedef struct uv_counters_s uv_counters_t; -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -/* Request types */ +typedef struct uv_fs_event_s uv_fs_event_t; +typedef struct uv_fs_poll_s uv_fs_poll_t; + +/* Request types. */ typedef struct uv_req_s uv_req_t; +typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; typedef struct uv_shutdown_s uv_shutdown_t; typedef struct uv_write_s uv_write_t; typedef struct uv_connect_s uv_connect_t; typedef struct uv_udp_send_s uv_udp_send_t; typedef struct uv_fs_s uv_fs_t; -/* uv_fs_event_t is a subclass of uv_handle_t. */ -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; typedef struct uv_work_s uv_work_t; +/* None of the above. */ +typedef struct uv_counters_s uv_counters_t; +typedef struct uv_cpu_info_s uv_cpu_info_t; +typedef struct uv_interface_address_s uv_interface_address_t; + /* * This function must be called before any other functions in libuv. @@ -298,13 +300,14 @@ typedef void (*uv_async_cb)(uv_async_t* handle, int status); typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status); typedef void (*uv_check_cb)(uv_check_t* handle, int status); typedef void (*uv_idle_cb)(uv_idle_t* handle, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* handle, int status, - struct addrinfo* res); typedef void (*uv_exit_cb)(uv_process_t*, int exit_status, int term_signal); +typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); typedef void (*uv_fs_cb)(uv_fs_t* req); typedef void (*uv_work_cb)(uv_work_t* req); typedef void (*uv_after_work_cb)(uv_work_t* req); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); +typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, + int status, + struct addrinfo* res); /* * This will be called repeatedly after the uv_fs_event_t is initialized. @@ -1156,19 +1159,33 @@ struct uv_getaddrinfo_s { /* * Asynchronous getaddrinfo(3). * - * Return code 0 means that request is accepted and callback will be called - * with result. Other return codes mean that there will not be a callback. - * Input arguments may be released after return from this call. + * Either node or service may be NULL but not both. + * + * hints is a pointer to a struct addrinfo with additional address type + * constraints, or NULL. Consult `man -s 3 getaddrinfo` for details. * - * uv_freeaddrinfo() must be called after completion to free the addrinfo - * structure. + * Returns 0 on success, -1 on error. Call uv_last_error() to get the error. * - * On error NXDOMAIN the status code will be non-zero and UV_ENOENT returned. + * If successful, your callback gets called sometime in the future with the + * lookup result, which is either: + * + * a) status == 0, the res argument points to a valid struct addrinfo, or + * b) status == -1, the res argument is NULL. + * + * On NXDOMAIN, the status code is -1 and uv_last_error() returns UV_ENOENT. + * + * Call uv_freeaddrinfo() to free the addrinfo structure. */ -UV_EXTERN int uv_getaddrinfo(uv_loop_t*, uv_getaddrinfo_t* handle, - uv_getaddrinfo_cb getaddrinfo_cb, const char* node, const char* service, - const struct addrinfo* hints); +UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, + uv_getaddrinfo_t* req, + uv_getaddrinfo_cb getaddrinfo_cb, + const char* node, + const char* service, + const struct addrinfo* hints); +/* + * Free the struct addrinfo. Passing NULL is allowed and is a no-op. + */ UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); /* uv_spawn() options */ @@ -1709,6 +1726,8 @@ UV_EXTERN int uv_thread_join(uv_thread_t *tid); /* the presence of these unions force similar struct layout */ union uv_any_handle { + uv_handle_t handle; + uv_stream_t stream; uv_tcp_t tcp; uv_pipe_t pipe; uv_prepare_t prepare; @@ -1716,8 +1735,12 @@ union uv_any_handle { uv_idle_t idle; uv_async_t async; uv_timer_t timer; - uv_getaddrinfo_t getaddrinfo; uv_fs_event_t fs_event; + uv_fs_poll_t fs_poll; + uv_poll_t poll; + uv_process_t process; + uv_tty_t tty; + uv_udp_t udp; }; union uv_any_req { @@ -1727,6 +1750,8 @@ union uv_any_req { uv_shutdown_t shutdown; uv_fs_t fs_req; uv_work_t work_req; + uv_udp_send_t udp_send_req; + uv_getaddrinfo_t getaddrinfo_req; }; diff --git a/deps/uv/src/ares/CHANGES b/deps/uv/src/ares/CHANGES index 73fe8c7710..f1426fda79 100644 --- a/deps/uv/src/ares/CHANGES +++ b/deps/uv/src/ares/CHANGES @@ -1,1218 +1,7 @@ - Changelog for the c-ares project +This file no longer holds the changelog. Now you can generate it yourself +like this: -Version 1.7.5 (August 16, 2011) + $ git log --pretty=fuller --no-color --date=short --decorate=full -1000 | + ./git2changes.pl -Fixed: - - o detection of semicolon comments in resolv.conf - o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory - o replacement ares_inet_net_pton affected by the WLB-2008080064 advisory - o replacement ares_inet_ntop affected by potential out of bounds write - o added install target to Makefile.msvc - o only fall back to AF_INET searches when looking for AF_UNSPEC addresses - o fixed ares_parse_*_reply memory leaks - o Use correct sizeof in ares_getnameinfo() - o IPv6-on-windows: find DNS servers correctly - o man pages: docs for the c-ares utility programs - o getservbyport replacement for Win CE - o config_sortlist: (win32) missing else - o advance_tcp_send_queue: avoid NULL ptr dereference - o configure: fix a bashism - o ares_expand_name: Fix encoded length for indirect root - -Version 1.7.4 (December 9, 2010) - -Changed: - - o local-bind: Support binding to local interface/IPs, see - ares_set_local_ip4, ares_set_local_ip6, ares_set_local_dev - -Fixed: - - o memory leak in ares_getnameinfo - o add missing break that caused get_ares_servers to fail - o ares_parse_a_reply: fix CNAME response parsing - o init_by_options: don't copy an empty sortlist - o Replaced uint32_t with unsigned int to fix broken builds - on a couple of platforms - o Fix lookup with HOSTALIASES set - o adig: fix NAPTR parsing - o compiler warning cleanups - -Version 1.7.3 (June 11, 2010) - -Fixed: - - o builds on Android - o now includes all files necessary to build it (1.7.2 lacked a file) - -Version 1.7.2 (June 10, 2010) - -Changed: - - o Added ares_parse_mx_reply() - -Fixed: - - o ares_init: Last, not first instance of domain or search should win - o improve alternative definition of bool - o fix VS2010 compiler warnings - - -Version 1.7.1 (Mar 23, 2010) - -* May 31, 2010 (Jakub Hrozek) -- Use the last instance of domain/search, not the first one - -* March 23, 2010 (Daniel Stenberg) -- We switched from CVS to git. See http://github.com/bagder/c-ares - -* March 5, 2010 (Daniel Stenberg) -- Daniel Johnson provided fixes for building with the clang compiler. - -* March 5, 2010 (Yang Tse) -- Added IPv6 name servers support. Implementation has been based on code, - comments and feedback provided November and December of 2008 by Daniel - Stenberg, Gregor Jasny, Phil Blundell and myself, December 2009 by Cedric - Bail, and February 2010 by Jakub Hrozek on the c-ares mailing list. On - March I reviewed all that, selected the best of each, and adjusted or - extended parts of it to make the best fit. - - The external and visible result of all this is that two new functions are - added to the external API, ares_get_servers() and ares_set_servers(), which - becomes now the preferred way of getting and setting name servers for any - ares channel as these support both IPv4 and IPv6 name servers. - - In order to not break ABI compatibility, ares_init_options() with option - mask ARES_OPT_SERVERS and ares_save_options() may still be used in code - which is intended to run on IPv4-only stacks. But remember that these - functions do not support IPv6 name servers. This implies that if the user - is capable of defining or providing an IPv6 name server, and the app is - using ares_init_options() or ares_save_options() at some point to handle - the name servers, the app will likely lose IPv6 name servers. - -* January 28, 2010 (Daniel Stenberg) -- Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't - check for broken connections like ares_process() did. Based on that, I - merged the two functions into a single generic one with two front-ends. - -* December 29, 2009 (Yang Tse) -- Laszlo Tamas Szabo adjusted Makefile.msvc compiler options so that where - run-time error checks enabling compiler option /GZ was used it is replaced - with equivalent /RTCsu for Visual Studio 2003 and newer versions. Option - /GX is replaced with equivalent /EHsc for all versions. Also fixed socket - data type for internal configure_socket function. - -* December 21, 2009 (Yang Tse) -- Ingmar Runge noticed that Windows config-win32.h configuration file - did not include a definition for HAVE_CLOSESOCKET which resulted in - function close() being inappropriately used to close sockets. - -Version 1.7.0 (Nov 30, 2009) - -* November 26, 2009 (Yang Tse) -- Larry Lansing fixed ares_parse_srv_reply to properly parse replies - which might contain non-SRV answers, skipping over potential non-SRV - ones such as CNAMEs. - -* November 23, 2009 (Yang Tse) -- Changed naming convention for c-ares libraries built with MSVC, details - and build instructions provided in README.msvc file. - -* November 22, 2009 (Yang Tse) -- Jakub Hrozek fixed more function prototypes in man pages to sync them - with the ones declared in ares.h - -- Jakub Hrozek renamed addrttl and addr6ttl structs to ares_addrttl and - ares_addr6ttl in order to prevent name space pollution, along with - necessary changes to code base and man pages.This change does not break - ABI, there is no need to recompile existing applications. But existing - applications using these structs with the old name will need source code - adjustments when recompiled using c-ares 1.7.0. - -* November 21, 2009 (Yang Tse) -- Added manifest stuff to Makefile.msvc. - -* November 20, 2009 (Yang Tse) -- Fixed several function prototypes in man pages that were out of sync - with the ones declared in ares.h. Added ares_free_data() along with - man page. Updated ares_parse_srv_reply() and ares_parse_txt_reply() - with changes from Jakub Hrozek making these now return linked lists - instead of arrays, and merging the ares_free_data() adjustments. - -* November 10, 2009 (Yang Tse) -- Updated MSVC 6.0 project files to match settings from Makefile.msvc. - -* November 9, 2009 (Yang Tse) -- Makefile.msvc is now the reference method to build c-ares and sample - programs with any MSVC compiler or MS Visual Studio version. If no - option or target are specified it builds dynamic and static c-ares - libraries in debug and release flavours and also builds all sample - programs using each of the different c-ares libraries. - -* November 2, 2009 (Yang Tse) -- Renamed c-ares setup.h to ares_setup.h - -* October 31, 2009 (Yang Tse) -- Symbol hiding configure options are named now --enable-symbol-hiding - and --disable-symbol-hiding in an attempt to make them less ambiguous. - -* October 30, 2009 (Yang Tse) -- Many fixes for ares_parse_txt_reply() - -* October 29, 2009 (Daniel Stenberg) -- Jakub Hrozek added ares_parse_txt_reply() for TXT parsing - -* October 29, 2009 (Yang Tse) -- Updated MSVC 6.0 workspace and project files that allows building - dynamic and static c-ares libraries in debug and release flavours. - Additionally each of the three sample programs is built against - each of the four possible c-ares libraries, generating all this - a total number of 12 executables and 4 libraries. - -* October 28, 2009 (Yang Tse) -- Initial step towards the ability to reduce c-ares exported symbols - when built as a shared library based on the 'visibility' attribute - for GNUC and Intel compilers and based on __global for Sun compilers, - taking also in account __declspec function decoration for Win32 and - Symbian DLL's. - -* October 27, 2009 (Yang Tse) -- Fixed Pelles C Win32 target compilation issues. - -* October 23, 2009 (Yang Tse) -- John Engelhart noticed an unreleased problem relative to a duplicate - ARES_ECANCELLED error code value and missing error code description. - -* October 7, 2009 (Yang Tse) -- Overhauled ares__get_hostent() Fixing out of bounds memory overwrite - triggered with malformed /etc/hosts file. Improving parsing of /etc/hosts - file. Validating requested address family. Ensuring that failures always - return a NULL pointer. Adjusting header inclusions. - -* October 6, 2009 (Yang Tse) -- Fix ssize_t redefinition errors on WIN64 reported by Alexey Simak. - -* September 29, 2009 (Yang Tse) -- Make configure script also check if _REENTRANT definition is required to - make errno available as a preprocessor macro. - -* September 7, 2009 (Yang Tse) -- Add T_SRV portability check to ares_parse_srv_reply.c - -* 4 Sep 2009 (Daniel Stenberg) -- Jakub Hrozek added ares_parse_srv_reply() for SRV parsing - -* 3 Aug 2009 (Daniel Stenberg) -- Joshua Kwan fixed the init routine to fill in the defaults for stuff that - fails to get inited by other means. This fixes a case of when the c-ares - init fails when internet access is fone. - -- Timo Teras changed the reason code used in the resolve callback done when - ares_cancel() is used, to be ARES_ECANCELLED instead of ARES_ETIMEOUT to - better allow the callback to know what's happening. - -* 14 Jul 2009 (Guenter Knauf) -- renamed generated config.h to ares_config.h to avoid any future clashes - with config.h from other projects. - -* June 20 2009 (Yang Tse) -- Refactor how libraries are checked for connect() function in configure - script and check for connect() as it is done for other functions. - -* June 19 2009 (Yang Tse) -- Make sclose() function-like macro definition used to close a socket, - now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL - config file preprocessor definitions - -* June 18 2009 (Yang Tse) -- Add CloseSocket camel case function check for configure script. - -* June 17 2009 (Yang Tse) -- Check for socket() and closesocket() as it is done for other functions - in configure script. - -* June 11 2009 (Yang Tse) -- Modified buildconf so that when automake runs it copies missing files - instead of symlinking them. - -* June 8 2009 (Yang Tse) -- Removed buildconf.bat from release and daily snapshot archives. This - file is only for CVS tree checkout builds. - -* May 26 2009 (Yang Tse) -- Added --enable-curldebug configure option to enable and disable building - with the low-level curl debug memory tracking 'feature' to allow decoupled - setting from --enable-debug, allowing again to build c-ares independently - out of the CVS tree. - - For the c-ares library option --enable-debug enables debug build features - which are _not_ related with memory tracking. For the c-ares library when - --enable-debug is given it does not enable the memory tracking feature. If - you wish to enable the curl debug memory tracking you must use configure - option --enable-curldebug explicitily to do so. - - Internally, definition of preprocessor symbol DEBUGBUILD restricts code - which is only compiled for debug enabled builds. And symbol CURLDEBUG is - used to differentiate code which is _only_ used for memory tracking. - - Make ares_init(), ares_dup() and ares_init_options() fail returning - ARES_ENOTINITIALIZED if library initialization has not been performed - calling ares_library_init(). - -* May 20 2009 (Yang Tse) -- Added ares_library_init() and ares_library_cleanup() man pages. - -* May 19 2009 (Yang Tse) -- Introduced ares_library_init() and ares_library_cleanup() functions. - - This is an API and ABI break for Win32/64 systems. Non-Win32/64 build targets - using c-ares 1.7.0 can still survive without calling these functions. Read all - the details on ares_library_init(3) and ares_library_cleanup(3) man pages that - are included. - - curl/libcurl 7.19.5 is fully compatible with c-ares 1.7.0 on all systems. - - In order to use c-ares 1.7.0 with curl/libcurl on Win32/64 systems it is - required that curl/libcurl is 7.19.5 or newer. In other words, it is not - possible on Win32/64 to use c-ares 1.7.0 with a curl/libcurl version less - than 7.19.5 - -* May 11 2009 (Daniel Stenberg) -- Gregor Jasny made c-ares link with libtool 's -export-symbols-regex option to - only expose functions starting with ares_. - -* May 7 2009 (Yang Tse) -- Fix an m4 overquoting triggering a spurious 'AS_TR_CPP' symbol definition - attempt in generated config.h - -* May 2 2009 (Yang Tse) -- Use a build-time configured ares_socklen_t data type instead of socklen_t. - -* April 21 2009 (Yang Tse) -- Moved potential inclusion of system's malloc.h and memory.h header files to - setup_once.h. Inclusion of each header file is based on the definition of - NEED_MALLOC_H and NEED_MEMORY_H respectively. - -* March 11 2009 (Yang Tse) -- Japheth Cleaver fixed acountry.c replacing u_long with unsigned long. - -* February 20 2009 (Yang Tse) -- Do not halt compilation when using VS2008 to build a Windows 2000 target. - -* February 3 2009 (Phil Blundell) -- If the server returns garbage or nothing at all in response to an AAAA query, - go on and ask for A records anyway. - -* January 31 2009 (Daniel Stenberg) -- ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving - either AF_INET6 or AF_INET. It works by accepting any of the looksups in the - hosts file, and it resolves the AAAA field with a fallback to A. - -* January 14 2009 (Daniel Stenberg) -- ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it - now declares the private struct ares_in6_addr for all systems instead of - relying on one possibly not present in the system. - -* January 13 2009 (Phil Blundell) -- ares__send_query() now varies the retry timeout pseudo-randomly to avoid - packet storms when several queries were started at the same time. - -* January 11 2009 (Daniel Stenberg) -- Phil Blundell added the internal function ares__expand_name_for_response() - that is now used by the ares_parse_*_reply() functions instead of the - ares_expand_name() simply to easier return ARES_EBADRESP for the cases where - the name expansion fails as in responses that really isn't expected. - -Version 1.6.0 (Dec 9, 2008) - -* December 9 2008 (Gisle Vanem) - - Fixes for Win32 targets using the Watt-32 tcp/ip stack. - -* Dec 4 2008 (Daniel Stenberg) - - Gregor Jasny provided the patch that introduces ares_set_socket_callback(), - and I edited it to also get duped by ares_dup(). - -* Dec 3 2008 (Daniel Stenberg) - - API changes: - - I made sure the public ares_config struct looks like before and yet it - supports the ROTATE option thanks to c-ares now storing the "optmask" - internally. Thus we should be ABI compatible with the past release(s) - now. My efforts mentioned below should not break backwards ABI compliance. - - Here's how I suggest we proceed with the API: - - ares_init() will be primary "channel creator" function. - - ares_init_options() will continue to work exactly like now and before. For - starters, it will be the (only) way to set the existing options. - - ares_save_options() will continue to work like today, but will ONLY save - options that you can set today (including ARES_OPT_ROTATE actually) but new - options that we add may not be saved with this. - - Instead we introduce: - - ares_dup() that instead can make a new channel and clone the config used - from an existing channel. It will then clone all config options, including - future new things we add. - - ares_set_*() style functions that set (new) config options. As a start we - simply add these for new functionality, but over time we can also introduce - them for existing "struct ares_options" so that we can eventually deprecate - the two ares_*_options() functions. - - ares_get_*() style functions for extracting info from a channel handle that - should be used instead of ares_save_options(). - -* Nov 26 2008 (Yang Tse) -- Brad Spencer provided changes to allow buildconf to work on OS X. - -- Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a - buffer to shrink instead of expand if a reply contained 8 or more records. - -* Nov 25 2008 (Yang Tse) -- In preparation for the upcomming IPv6 nameservers patch, the internal - ares_addr union is now changed into an internal struct which also holds - the address family. - -* Nov 19 2008 (Daniel Stenberg) -- Brad Spencer brought the new function ares_gethostbyname_file() which simply - resolves a host name from the given file, using the regular hosts syntax. - -* Nov 1 2008 (Daniel Stenberg) -- Carlo Contavalli added support for the glibc "rotate" option, as documented - in man resolv.conf: - - causes round robin selection of nameservers from among those listed. This - has the effect of spreading the query load among all listed servers, rather - than having all clients try the first listed server first every time. - - You can enable it with ARES_OPT_ROTATE - -* Oct 21 2008 (Yang Tse) - Charles Hardin added handling of EINPROGRESS for UDP connects. - -* Oct 18 2008 (Daniel Stenberg) - Charles Hardin made adig support a regular numerical dotted IP address for the - -s option as well. - -* Oct 7 2008 (Yang Tse) -- Added --enable-optimize configure option to enable and disable compiler - optimizations to allow decoupled setting from --enable-debug. - -* Oct 2 2008 (Yang Tse) -- Added --enable-warnings configure option to enable and disable strict - compiler warnings to allow decoupled setting from --enable-debug. - -* Sep 17 2008 (Yang Tse) -- Code reorganization to allow internal/private use of "nameser.h" to any - system that lacks arpa/nameser.h or arpa/nameser_compat.h header files. - -* Sep 16 2008 (Yang Tse) -- Code reorganization to allow internal/private use of ares_writev to any - system that lacks the writev function. - -* Sep 15 2008 (Yang Tse) -- Code reorganization to allow internal/private use of ares_strcasecmp to any - system that lacks the strcasecmp function. - -- Improve configure detection of some string functions. - -* Sep 11 2008 (Yang Tse) -- Code reorganization to allow internal/private use of ares_strdup to any - system that lacks the strdup function. - -Version 1.5.3 (Aug 29, 2008) - -* Aug 25 2008 (Yang Tse) -- Improvement by Brad House: - - This patch addresses an issue in which a response could be sent back to the - source port of a client from a different address than the request was made to. - This is one form of a DNS cache poisoning attack. - - The patch simply uses recvfrom() rather than recv() and validates that the - address returned from recvfrom() matches the address of the server we have - connected to. Only necessary on UDP sockets as they are connection-less, TCP - is unaffected. - -- Fix by George Neill: - Fixed compilation of acountry sample application failure on some systems. - -* Aug 4 2008 (Daniel Stenberg) -- Fix by Tofu Linden: - - The symptom: - * Users (usually, but not always) on 2-Wire routers and the Comcast service - and a wired connection to their router would find that the second and - subsequent DNS lookups from fresh processes using c-ares to resolve the same - address would cause the process to never see a reply (it keeps polling for - around 1m15s before giving up). - - The repro: - * On such a machine (and yeah, it took us a lot of QA to find the systems - that reproduce such a specific problem!), do 'ahost www.secondlife.com', - then do it again. The first process's lookup will work, subsequent lookups - will time-out and fail. - - The cause: - * init_id_key() was calling randomize_key() *before* it initialized - key->state, meaning that the randomness generated by randomize_key() is - immediately overwritten with deterministic values. (/dev/urandom was also - being read incorrectly in the c-ares version we were using, but this was - fixed in a later version.) - * This makes the stream of generated query-IDs from any new c-ares process - be an identical and predictable sequence of IDs. - * This makes the 2-Wire's default built-in DNS server detect these queries - as probable-duplicates and (erroneously) not respond at all. - - -* Aug 4 2008 (Yang Tse) -- Autoconf 2.62 has changed the behaviour of the AC_AIX macro which we use. - Prior versions of autoconf defined _ALL_SOURCE if _AIX was defined. 2.62 - version of AC_AIX defines _ALL_SOURCE and other four preprocessor symbols - no matter if the system is AIX or not. To keep the traditional behaviour, - and an uniform one across autoconf versions AC_AIX is replaced with our - own internal macro CARES_CHECK_AIX_ALL_SOURCE. - -* Aug 1 2008 (Yang Tse) -- Configure process now checks if the preprocessor _REENTRANT symbol is already - defined. If it isn't currently defined a set of checks are performed to test - if its definition is required to make visible to the compiler a set of *_r - functions. Finally, if _REENTRANT is already defined or needed it takes care - of making adjustments necessary to ensure that it is defined equally for the - configure process tests and generated config file. - -* Jul 20 2008 (Yang Tse) -- When recvfrom prototype uses a void pointer for arguments 2, 5 or 6 this will - now cause the definition, as appropriate, of RECVFROM_TYPE_ARG2_IS_VOID, - RECVFROM_TYPE_ARG5_IS_VOID or RECVFROM_TYPE_ARG6_IS_VOID. - -* Jul 17 2008 (Yang Tse) -- RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined - to the data type pointed by its respective argument and not the pointer type. - -* Jul 16 2008 (Yang Tse) -- Improved configure detection of number of arguments for getservbyport_r. - Detection is now based on compilation checks instead of linker ones. - -- Configure process now checks availability of recvfrom() socket function and - finds out its return type and the types of its arguments. Added definitions - for non-configure systems config files, and introduced macro sreadfrom which - will be used on udp sockets as a recvfrom() wrapper in the future. - -* Jul 15 2008 (Yang Tse) -- Introduce definition of _REENTRANT symbol in setup.h to improve library - usability. Previously the configure process only used the AC_SYS_LARGEFILE - macro for debug builds, now it is also used for non-debug ones enabling the - use of configure options --enable-largefile and --disable-largefile which - might be needed for library compatibility. Remove checking the size of - curl_off_t, it is no longer needed. - -* Jul 3 2008 (Daniel Stenberg) -- Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and - the target host has only A records, it automatically falls back to an - AF_INET lookup and gives you the A results. However, if the target host has - a CNAME record, this behaviour is defeated since the original query does - return some data even though ares_parse_aaa_reply() doesn't consider it - relevant. Here's a small patch to make it behave the same with and without - the CNAME. - -* Jul 2 2008 (Yang Tse) -- Fallback to gettimeofday when monotonic clock is unavailable at run-time. - -* Jun 30 2008 (Daniel Stenberg) - -- As was pointed out to me by Andreas Schuldei, the MAXHOSTNAMELEN define is - not posix or anything and thus c-ares failed to build on hurd (and possibly - elsewhere). The define was also somewhat artificially used in the windows - port. Now, I instead rewrote the use of gethostbyname to enlarge the host - name buffer in case of need and totally avoid the use of the MAXHOSTNAMELEN - define. I thus also removed the defien from the namser.h file where it was - once added for the windows build. - - I also fixed init_by_defaults() function to not leak memory in case if - error. - -* Jun 9 2008 (Yang Tse) - -- Make libcares.pc generated file for pkg-config include information relative - to the libraries needed for the static linking of c-ares. - -* May 30 2008 (Yang Tse) - -- Brad House fixed a missing header file inclusion in adig sample program. - -Version 1.5.2 (May 29, 2008) - -* May 13 2008 (Daniel Stenberg) - -- Introducing millisecond resolution support for the timeout option. See - ares_init_options()'s ARES_OPT_TIMEOUTMS. - -* May 9 2008 (Yang Tse) - -- Use monotonic time source if available, for private function ares__tvnow() - -* May 7 2008 (Daniel Stenberg) - -- Sebastian made c-ares able to return all PTR-records when doing reverse - lookups. It is not common practice to have multiple PTR-Records for a single - IP, but its perfectly legal and some sites have those. - -- Doug Goldstein provided a configure patch: updates autoconf 2.13 usage to - autoconf 2.57 usage (which is the version you have specified as the minimum - version). It's a minor change but it does clean up some warnings with newer - autoconf (specifically 2.62). - -* May 5 2008 (Yang Tse) - -- Improved parsing of resolver configuration files. - -* April 4 2008 (Daniel Stenberg) - -- Eino Tuominen improved the code when a file is used to seed the randomizer. - -- Alexey Simak made adig support NAPTR records - -- Alexey Simak fixed the VC dsp file by adding the missing source file - ares_expand_string.c - -* December 11 2007 (Gisle Vanem) - -- Added another sample application; acountry.c which converts an - IPv4-address(es) and/or host-name(s) to country-name and country-code. - This uses the service of the DNSBL at countries.nerd.dk. - -* December 3 2007 (Daniel Stenberg) - -- Brad Spencer fixed the configure script to assume that there's no - /dev/urandom when built cross-compiled as then the script cannot check for - it. - -- Erik Kline cleaned up ares_gethostbyaddr.c:next_lookup() somewhat - -Version 1.5.1 (Nov 21, 2007) - -* November 21 2007 (Daniel Stenberg) - -- Robin Cornelius pointed out that ares_llist.h was missing in the release - archive for 1.5.0 - -Version 1.5.0 (Nov 21, 2007) - -* October 2 2007 (Daniel Stenberg) - -- ares_strerror() segfaulted if the input error number was out of the currently - supported range. - -- Yang Tse: Avoid a segfault when generating a DNS "Transaction ID" in - internal function init_id_key() under low memory conditions. - -* September 28 2007 (Daniel Stenberg) - -- Bumped version to 1.5.0 for next release and soname bumped to 2 due to ABI - and API changes in the progress callback (and possibly more coming up from - Steinar) - -* September 28 2007 (Steinar H. Gunderson) - -- Don't skip a server if it's the only one. (Bugfix from the Google tree.) - -- Made the query callbacks receive the number of timeouts that happened during - the execution of a query, and updated documentation accordingly. (Patch from - the Google tree.) - -- Support a few more socket options: ARES_OPT_SOCK_SNDBUF and - ARES_OPT_SOCK_RCVBUF - -- Always register for TCP events even if there are no outstanding queries, as - the other side could always close the connection, which is a valid event - which should be responded to. - -* September 22 2007 (Daniel Stenberg) - -- Steinar H. Gunderson fixed: Correctly clear sockets from the fd_set on in - several functions (write_tcp_data, read_tcp_data, read_udp_packets) so that - if it fails and the socket is closed the following code doesn't try to use - the file descriptor. - -- Steinar H. Gunderson modified c-ares to now also do to DNS retries even when - TCP is used since there are several edge cases where it still makes sense. - -- Brad House provided a fix for ares_save_options(): - - Apparently I overlooked something with the ares_save_options() where it - would try to do a malloc(0) when no options of that type needed to be saved. - On most platforms, this was fine because malloc(0) doesn't actually return - NULL, but on AIX it does, so ares_save_options would return ARES_ENOMEM. - -* July 14 2007 (Daniel Stenberg) - -- Vlad Dinulescu fixed two outstanding valgrind reports: - - 1. In ares_query.c , in find_query_by_id we compare q->qid (which is a short - int variable) with qid, which is declared as an int variable. Moreover, - DNS_HEADER_SET_QID is used to set the value of qid, but DNS_HEADER_SET_QID - sets only the first two bytes of qid. I think that qid should be declared as - "unsigned short" in this function. - - 2. The same problem occurs in ares_process.c, process_answer() . query->qid - (an unsigned short integer variable) is compared with id, which is an - integer variable. Moreover, id is initialized from DNS_HEADER_QID which sets - only the first two bytes of id. I think that the id variable should be - declared as "unsigned short" in this function. - - Even after declaring these variables as "unsigned short", the valgrind - errors are still there. Which brings us to the third problem. - - 3. The third problem is that Valgrind assumes that query->qid is not - initialised correctly. And it does that because query->qid is set from - DNS_HEADER_QID(qbuf); Valgrind says that qbuf has unitialised bytes. And - qbuf has uninitialised bytes because of channel->next_id . And next_id is - set by ares_init.c:ares__generate_new_id() . I found that putting short r=0 - in this function (instead of short r) makes all Valgrind warnings go away. - I have studied ares__rc4() too, and this is the offending line: - - buffer_ptr[counter] ^= state[xorIndex]; (ares_query.c:62) - - This is what triggers Valgrind.. buffer_ptr is unitialised in this function, - and by applying ^= on it, it remains unitialised. - -Version 1.4.0 (June 8, 2007) - -* June 4 2007 (Daniel Stenberg) - -- James Bursa reported a major memory problem when resolving multi-IP names - and I found and fixed the problem. It was added by Ashish Sharma's patch - two days ago. - - When I then tried to verify multiple entries in /etc/hosts after my fix, I - got another segfault and decided this code was not ripe for inclusion and I - reverted the patch. - -* June 2 2007 - -- Brad Spencer found and fixed three flaws in the code, found with the new - gcc 4.2.0 warning: -Waddress - -- Brad House fixed VS2005 compiler warnings due to time_t being 64bit. - He also made recent Microsoft compilers use _strdup() instead of strdup(). - -- Brad House's man pages for ares_save_options() and ares_destroy_options() - were added. - -- Ashish Sharma provided a patch for supporting multiple entries in the - /etc/hosts file. Patch edited for coding style and functionality by me - (Daniel). - -* May 30 2007 - -- Shmulik Regev brought cryptographically secure transaction IDs: - - The c-ares library implementation uses a DNS "Transaction ID" field that is - seeded with a pseudo random number (based on gettimeofday) which is - incremented (++) between consecutive calls and is therefore rather - predictable. In general, predictability of DNS Transaction ID is a well - known security problem (e.g. - http://bak.spc.org/dms/archive/dns_id_attack.txt) and makes a c-ares based - implementation vulnerable to DNS poisoning. Credit goes to Amit Klein - (Trusteer) for identifying this problem. - - The patch I wrote changes the implementation to use a more secure way of - generating unique IDs. It starts by obtaining a key with reasonable entropy - which is used with an RC4 stream to generate the cryptographically secure - transaction IDs. - - Note that the key generation code (in ares_init:randomize_key) has two - versions, the Windows specific one uses a cryptographically safe function - provided (but undocumented :) by the operating system (described at - http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx). The - default implementation is a bit naive and uses the standard 'rand' - function. Surely a better way to generate random keys exists for other - platforms. - - The patch can be tested by using the adig utility and using the '-s' option. - -- Brad House added ares_save_options() and ares_destroy_options() that can be - used to keep options for later re-usal when ares_init_options() is used. - - Problem: Calling ares_init() for each lookup can be unnecessarily resource - intensive. On windows, it must LoadLibrary() or search the registry - on each call to ares_init(). On unix, it must read and parse - multiple files to obtain the necessary configuration information. In - a single-threaded environment, it would make sense to only - ares_init() once, but in a heavily multi-threaded environment, it is - undesirable to ares_init() and ares_destroy() for each thread created - and track that. - - Solution: Create ares_save_options() and ares_destroy_options() functions to - retrieve and free options obtained from an initialized channel. The - options populated can be used to pass back into ares_init_options(), - it should populate all needed fields and not retrieve any information - from the system. Probably wise to destroy the cache every minute or - so to prevent the data from becoming stale. - -- Daniel S added ares_process_fd() to allow applications to ask for processing - on specific sockets and thus avoiding select() and associated - functions/macros. This function will be used by upcoming libcurl releases - for this very reason. It also made me export the ares_socket_t type in the - public ares.h header file, since ares_process_fd() uses that type for two of - the arguments. - -* May 25 2007 - -- Ravi Pratap fixed a flaw in the init_by_resolv_conf() function for windows - that could cause it to return a bad return code. - -* April 16 2007 - -- Yang Tse: Provide ares_getopt() command-line parser function as a source - code helper function, not belonging to the actual c-ares library. - -* February 19 2007 - -- Vlad Dinulescu added ares_parse_ns_reply(). - -* February 13 2007 - -- Yang Tse: Fix failure to get the search sequence of /etc/hosts and - DNS from /etc/nsswitch.conf, /etc/host.conf or /etc/svc.conf when - /etc/resolv.conf did not exist or was unable to read it. - -* November 22 2006 - -- Install ares_dns.h too - -- Michael Wallner fixed this problem: When I set domains in the options - struct, and there are domain/search entries in /etc/resolv.conf, the domains - of the options struct will be overridden. - -* November 6 2006 - -- Yang Tse removed a couple of potential zero size memory allocations. - -- Andreas Rieke fixed the line endings in the areslib.dsp file that I (Daniel) - broke in the 1.3.2 release. We should switch to a system where that file is - auto-generated. We could rip some code for that from curl... - -Version 1.3.2 (November 3, 2006) - -* October 12 2006 - -- Prevent ares_getsock() to overflow if more than 16 sockets are used. - -* September 11 2006 - -- Guilherme Balena Versiani: I noted a strange BUG in Win32 port - (ares_init.c/get_iphlpapi_dns_info() function): when I disable the network - by hand or disconnect the network cable in Windows 2000 or Windows XP, my - application gets 127.0.0.1 as the only name server. The problem comes from - 'GetNetworkParams' function, that returns the empty string "" as the only - name server in that case. Moreover, the Windows implementation of - inet_addr() returns INADDR_LOOPBACK instead of INADDR_NONE. - -* August 29 2006 - -- Brad Spencer did - - o made ares_version.h use extern "C" for c++ compilers - o fixed compiler warnings in ares_getnameinfo.c - o fixed a buffer position init for TCP reads - -* August 3 2006 - -- Ravi Pratap fixed ares_getsock() to actually return the proper bitmap and - not always zero! - -Version 1.3.1 (June 24, 2006) - -* July 23, 2006 - -- Gisle Vanem added getopt() to the ahost program. Currently accepts - only [-t {a|aaaa}] to specify address family in ares_gethostbyname(). - -* June 19, 2006 - -- (wahern) Removed "big endian" DNS section and RR data integer parser - macros from ares_dns.h, which break c-ares on my Sparc64. Bit-wise - operations in C operate on logical values. And in any event the octets are - already in big-endian (aka network) byte order so they're being reversed - (thus the source of the breakage). - -* June 18, 2006 - -- William Ahern handles EAGAIN/EWOULDBLOCK errors in most of the I/O calls - from area_process.c. - - TODO: Handle one last EAGAIN for a UDP socket send(2) in - ares__send_query(). - -* May 10, 2006 - -- Bram Matthys brought my attention to a libtool peculiarity where detecting - things such as C++ compiler actually is a bad thing and since we don't need - that detection I added a work-around, much inspired by a previous patch by - Paolo Bonzini. This also shortens the configure script quite a lot. - -* May 3, 2006 - -- Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set makes - c-ares call a callback on socket state changes. A better way than the - ares_getsock() to get full control over the socket state. - -* January 9, 2006 - -- Alexander Lazic improved the getservbyport_r() configure check. - -* January 6, 2006 - -- Alexander Lazic pointed out that the buildconf should use the ACLOCAL_FLAGS - variable for easier controlling what it does and how it runs. - -* January 5, 2006 - -- James Bursa fixed c-ares to find the hosts file on RISC OS, and made it - build with newer gcc versions that no longer defines "riscos". - -* December 22 - -- Daniel Stenberg added ares_getsock() that extracts the set of sockets to - wait for action on. Similar to ares_fds() but not restricted to using - select() for the waiting. - -* November 25 - -- Yang Tse fixed some send() / recv() compiler warnings - -* September 18 - -- Added constants that will be used by ares_getaddrinfo - -- Made ares_getnameinfo use the reentrant getservbyport (getservbyport_r) if it - is available to ensure it works properly in a threaded environment. - -* September 10 - -- configure fix for detecting a member in the sockaddr_in6 struct which failed - on ipv6-enabled HP-UX 11.00 - -Version 1.3.0 (August 29, 2005) - -* August 21 - -- Alfredo Tupone provided a fix for the Windows code in get_iphlpapi_dns_info() - when getting the DNS server etc. - -* June 19 - -- Added some checks for the addrinfo structure. - -* June 2 - -- William Ahern: - - Make UDP sockets non-blocking. I've confirmed that at least on Linux 2.4 a - read event can come back from poll() on a valid SOCK_DGRAM socket but - recv(2) will still block. This patch doesn't ignore EAGAIN in - read_udp_packets(), though maybe it should. (This patch was edited by Daniel - Stenberg and a new configure test was added (imported from curl's configure) - to properly detect what non-blocking socket approach to use.) - - I'm not quite sure how this was happening, but I've been seeing PTR queries - which seem to return empty responses. At least, they were empty when calling - ares_expand_name() on the record. Here's a patch which guarantees to - NUL-terminate the expanded name. The old behavior failed to NUL-terminate if - len was 0, and this was causing strlen() to run past the end of the buffer - after calling ares_expand_name() and getting ARES_SUCCESS as the return - value. If q is not greater than *s then it's equal and *s is always - allocated with at least one byte. - -* May 16 - -- Added ares_getnameinfo which mimics the getnameinfo API (another feature - that could use testing). - -* May 14 - -- Added an inet_ntop function from BIND for systems that do not have it. - -* April 9 - -- Made sortlist support IPv6 (this can probably use some testing). - -- Made sortlist support CIDR matching for IPv4. - -* April 8 - -- Added preliminary IPv6 support to ares_gethostbyname. Currently, sortlist - does not work with IPv6. Also provided an implementation of bitncmp from - BIND for systems that do not supply this function. This will be used to add - IPv6 support to sortlist. - -- Made ares_gethostbyaddr support IPv6 by specifying AF_INET6 as the family. - The function can lookup IPv6 addresses both from files (/etc/hosts) and - DNS lookups. - -* April 7 - -- Tupone Alfredo fixed includes of arpa/nameser_compat.h to build fine on Mac - OS X. - -* April 5 - -- Dominick Meglio: Provided implementations of inet_net_pton and inet_pton - from BIND for systems that do not include these functions. - -* March 11, 2005 - -- Dominick Meglio added ares_parse_aaaa_reply.c and did various - adjustments. The first little steps towards IPv6 support! - -* November 7 - -- Fixed the VC project and makefile to use ares_cancel and ares_version - -* October 24 - -- The released ares_version.h from 1.2.1 says 1.2.0 due to a maketgz flaw. - This is now fixed. - -Version 1.2.1 (October 20, 2004) - -* September 29 - -- Henrik Stoerner fix: got a report that Tru64 Unix (the unix from Digital - when they made Alpha's) uses /etc/svc.conf for the purpose fixed below for - other OSes. He made c-ares check for and understand it if present. - -- Now c-ares will use local host name lookup _before_ DNS resolving by default - if nothing else is told. - -* September 26 - -- Henrik Stoerner: found out that c-ares does not look at the /etc/host.conf - file to determine the sequence in which to search /etc/hosts and DNS. So on - systems where this order is defined by /etc/host.conf instead of a "lookup" - entry in /etc/resolv.conf, c-ares will always default to looking in DNS - first, and /etc/hosts second. - - c-ares now looks at - - 1) resolv.conf (for the "lookup" line); - 2) nsswitch.fon (for the "hosts:" line); - 3) host.conf (for the "order" line). - - First match wins. - -- Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is - located in a static location. It assumed - C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact, - the location of the HOSTS file can be changed via a registry setting. - - There is a key called DatabasePath which specifies the path to the HOSTS - file: - http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx - - The patch will make c-ares correctly consult the registry for the location - of this file. - -* August 29 - -- Gisle Vanem fixed the MSVC build files. - -* August 20 - -- Gisle Vanem made c-ares build and work with his Watt-32 TCP/IP stack. - -* August 13 - -- Harshal Pradhan made a minor syntax change in ares_init.c to make it build - fine with MSVC 7.1 - -* July 24 - -- Made the lib get built static only if --enable-debug is used. - -- Gisle Vanem fixed: - - Basically in loops like handle_errors(), 'query->next' was assigned a local - variable and then query was referenced after the memory was freed by - next_server(). I've changed that so next_server() and end_query() returns - the next query. So callers should use this ret-value. - - The next problem was that 'server->tcp_buffer_pos' had a random value at - entry to 1st recv() (luckily causing Winsock to return ENOBUFS). - - I've also added a ares_writev() for Windows to streamline the code a bit - more. - -* July 20 -- Fixed a few variable return types for some system calls. Made configure - check for ssize_t to make it possible to use that when receiving the send() - error code. This is necessary to prevent compiler warnings on some systems. - -- Made configure create config.h, and all source files now include setup.h that - might include the proper config.h (or a handicrafted alternative). - -- Switched to 'ares_socket_t' type for sockets in ares, since Windows don't - use 'int' for that. - -- automake-ified and libool-ified c-ares. Now it builds libcares as a shared - lib on most platforms if wanted. (This bloated the size of the release - archive with another 200K!) - -- Makefile.am now uses Makefile.inc for the c sources, h headers and man - pages, to make it easier for other makefiles to use the exact same set of - files. - -- Adjusted 'maketgz' to use the new automake magic when building distribution - archives. - -- Anyone desires HTML and/or PDF versions of the man pages in the release - archives? - -* July 3 -- Günter Knauf made c-ares build and run on Novell Netware. - -* July 1 -- Gisle Vanem provided Makefile.dj to build with djgpp, added a few more djgpp - fixes and made ares not use 'errno' to provide further info on Windows. - -* June 30 -- Gisle Vanem made it build with djgpp and run fine with the Watt-32 stack. - -* June 10 -- Gisle Vanem's init patch for Windows: - - The init_by_resolv_conf() function fetches the DNS-server(s) - from a series of registry branches. - - This can be wrong in the case where DHCP has assigned nameservers, but the - user has overridden these servers with other prefered settings. Then it's - wrong to use the DHCPNAMESERVER setting in registry. - - In the case of no global DHCP-assigned or fixed servers, but DNS server(s) - per adapter, one has to query the adapter branches. But how can c-ares know - which adapter is valid for use? AFAICS it can't. There could be one adapter - that is down (e.g. a VPN adapter). - - So it's better to leave this to the IP Helper API (iphlapi) available in - Win-98/2000 and later. My patch falls-back to the old way if not available. - -* June 8 -- James Bursa fixed an init issue for RISC OS. - -* May 11 -- Nico Stappenbelt reported that when processing domain and search lines in - the resolv.conf file, the first entry encountered is processed and used as - the search list. According to the manual pages for both Linux, Solaris and - Tru64, the last entry of either a domain or a search field is used. - - This is now adjusted in the code - -Version 1.2.0 (April 13, 2004) - -* April 2, 2004 -- Updated various man pages to look nicer when converted to HTML on the web - site. - -* April 1, 2004 -- Dirk Manske provided a new function that is now named ares_cancel(). It is - used to cancel/cleanup a resolve/request made using ares functions on the - given ares channel. It does not destroy/kill the ares channel itself. - -- Dominick Meglio cleaned up the formatting in several man pages. - -* March 30, 2004 -- Dominick Meglio's new ares_expand_string. A helper function when decoding - incoming DNS packages. - -- Daniel Stenberg modified the Makefile.in to use a for loop for the man page - installation to improve overview and make it easier to add man pages. - -Version 1.1.0 (March 11, 2004) - -* March 9, 2004 -- Gisle Vanem improved build on Windows. - -* February 25, 2004 -- Dan Fandrich found a flaw in the Feb 22 fix. - -- Added better configure --enable-debug logic (taken from the curl configure - script). Added acinclude.m4 to the tarball. - -* February 23, 2004 -- Removed ares_free_errmem(), the function, the file and the man page. It was - not used and it did nothing. - -- Fixed a lot of code that wasn't "64bit clean" and thus caused a lot of - compiler warnings on picky compilers. - -* February 22, 2004 -- Dominick Meglio made ares init support multiple name servers in the - NameServer key on Windows. - -* February 16, 2004 -- Modified ares_private.h to include libcurl's memory debug header if - CURLDEBUG is set. This makes all the ares-functions supervised properly by - the curl test suite. This also forced me to add inclusion of the - ares_private.h header in a few more files that are using some kind of - memory-related resources. - -- Made the makefile only build ahost and adig if 'make demos' is used. - -* February 10, 2004 -- Dirk Manske made ares_version.h installed with 'make install' - -* February 4, 2004 -- ares_free_errmem() is subject for removal, it is simply present for future - purposes, and since we removed the extra parameter in strerror() it won't - be used by c-ares! -- configure --enable-debug now enables picky compiler options if gcc is used -- fixed several compiler warnings --enable-debug showed and Joerg Mueller-Tolk - reported - -Version 1.0.0 (February 3, 2004) - -* February 3, 2004 -- now we produce the libcares.a library instead of the previous libares.a - since we are no longer compatible - -* February 2, 2004 - -- ares_strerror() has one argument less. This is the first official - modification of the existing provided ares API. - -* January 29, 2004 - -- Dirk Manske fixed how the socket is set non-blocking. - -* January 4, 2004 - -- Dominick Meglio made the private gettimeofday() become ares_gettimeofday() - instead in order to not pollute the name space and risk colliding with - other libraries' versions of this function. - -* October 24, 2003. Daniel Stenberg - - Added ares_version(). - -Version 1.0-pre1 (8 October 2003) - -- James Bursa made it run on RISC OS - -- Dominick Meglio made it run fine on NT4 - -- Duncan Wilcox made it work fine on Mac OS X - -- Daniel Stenberg adjusted the windows port - -- liren at vivisimo.com made the initial windows port - -* Imported the sources from ares 1.1.1 +The older, manually edited, changelog is found in git named CHANGES.0 diff --git a/deps/uv/src/ares/CMakeLists.txt b/deps/uv/src/ares/CMakeLists.txt deleted file mode 100644 index 7bbb95b879..0000000000 --- a/deps/uv/src/ares/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${node_platform}-${cares_arch}) -add_definitions(-DHAVE_CONFIG_H=1) - -include(CheckLibraryExists) -check_library_exists(socket socket "" HAVE_SOCKET_LIB) -check_library_exists(nsl gethostbyname "" HAVE_NSL_LIB) - -file(GLOB lib_sources *.c) -add_library(cares ${lib_sources}) - -if(${HAVE_SOCKET_LIB}) - set(cares_libs ${cares_libs} socket) -endif() - -if(${HAVE_NSL_LIB}) - set(cares_libs ${cares_libs} nsl) -endif() - -if(cares_libs) - target_link_libraries(cares ${cares_libs}) -endif() diff --git a/deps/uv/src/ares/README.node b/deps/uv/src/ares/README.node deleted file mode 100644 index 17503096fd..0000000000 --- a/deps/uv/src/ares/README.node +++ /dev/null @@ -1,21 +0,0 @@ -Library: c-ares, DNS resolver - -Version: 1.7.3 (11 June, 2010) - -Authors: Greg Hudson, Daniel Stenberg - -License: MIT - -Notes: - -Just use waf instead of the autoconf based configure script. Delete most of -the documentation and other files distributed with it. To upgrade, run -./configure on linux, macintosh, solaris (and other supported platforms) and -copy -- ares_config.h -- ares_setup.h -- ares_build.h -into the appropriate directory. - - - diff --git a/deps/uv/src/ares/RELEASE-NOTES b/deps/uv/src/ares/RELEASE-NOTES index 06d7856bc7..3c437308fb 100644 --- a/deps/uv/src/ares/RELEASE-NOTES +++ b/deps/uv/src/ares/RELEASE-NOTES @@ -1,26 +1,16 @@ -c-ares version 1.7.5 +c-ares version 1.9.0 -Fixed: +Changed: + + o Added ares_parse_soa_reply - o detection of semicolon comments in resolv.conf - o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory - o replacement ares_inet_net_pton affected by the WLB-2008080064 advisory - o replacement ares_inet_ntop affected by potential out of bounds write - o added install target to Makefile.msvc - o only fall back to AF_INET searches when looking for AF_UNSPEC addresses - o fixed ares_parse_*_reply memory leaks - o Use correct sizeof in ares_getnameinfo() - o IPv6-on-windows: find DNS servers correctly - o man pages: docs for the c-ares utility programs - o getservbyport replacement for Win CE - o config_sortlist: (win32) missing else - o advance_tcp_send_queue: avoid NULL ptr dereference - o configure: fix a bashism - o ares_expand_name: Fix encoded length for indirect root +Fixed: + o libcares.pc generation for static MingW* cross builds + o ares_dup: UDP and TCP port byte order in saved options + Thanks go to these friendly people for their efforts and contributions: - Yang Tse, Jakub Hrozek, Gisle Vanem, Tom Hughes, David Stuart, Dima Tisnek, - Peter Pentchev, Stefan Buhler + Yang Tse, Nick Alcock, Marko Kreen Have fun! diff --git a/deps/uv/src/ares/ares__get_hostent.c b/deps/uv/src/ares/ares__get_hostent.c index 298df09182..94428ee95c 100644 --- a/deps/uv/src/ares/ares__get_hostent.c +++ b/deps/uv/src/ares/ares__get_hostent.c @@ -1,5 +1,5 @@ -/* Copyright 1998, 2010 by the Massachusetts Institute of Technology. +/* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -31,6 +31,7 @@ #include "ares.h" #include "inet_net_pton.h" +#include "ares_nowarn.h" #include "ares_private.h" int ares__get_hostent(FILE *fp, int family, struct hostent **host) @@ -219,8 +220,8 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) break; /* Copy actual network address family and length. */ - hostent->h_addrtype = addr.family; - hostent->h_length = (int)addrlen; + hostent->h_addrtype = aresx_sitoss(addr.family); + hostent->h_length = aresx_uztoss(addrlen); /* Free line buffer. */ free(line); diff --git a/deps/uv/src/ares/ares_data.c b/deps/uv/src/ares/ares_data.c index a2477be192..7c0465073f 100644 --- a/deps/uv/src/ares/ares_data.c +++ b/deps/uv/src/ares/ares_data.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2009-2010 by Daniel Stenberg +/* Copyright (C) 2009-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -92,6 +92,27 @@ void ares_free_data(void *dataptr) ares_free_data(ptr->data.addr_node.next); break; + case ARES_DATATYPE_NAPTR_REPLY: + + if (ptr->data.naptr_reply.next) + ares_free_data(ptr->data.naptr_reply.next); + if (ptr->data.naptr_reply.flags) + free(ptr->data.naptr_reply.flags); + if (ptr->data.naptr_reply.service) + free(ptr->data.naptr_reply.service); + if (ptr->data.naptr_reply.regexp) + free(ptr->data.naptr_reply.regexp); + if (ptr->data.naptr_reply.replacement) + free(ptr->data.naptr_reply.replacement); + break; + + case ARES_DATATYPE_SOA_REPLY: + if (ptr->data.soa_reply.nsname) + free(ptr->data.soa_reply.nsname); + if (ptr->data.soa_reply.hostmaster) + free(ptr->data.soa_reply.hostmaster); + break; + default: return; } @@ -138,7 +159,7 @@ void *ares_malloc_data(ares_datatype type) case ARES_DATATYPE_TXT_REPLY: ptr->data.txt_reply.next = NULL; ptr->data.txt_reply.txt = NULL; - ptr->data.txt_reply.length = 0; + ptr->data.txt_reply.length = 0; break; case ARES_DATATYPE_ADDR_NODE: @@ -148,6 +169,26 @@ void *ares_malloc_data(ares_datatype type) sizeof(ptr->data.addr_node.addrV6)); break; + case ARES_DATATYPE_NAPTR_REPLY: + ptr->data.naptr_reply.next = NULL; + ptr->data.naptr_reply.flags = NULL; + ptr->data.naptr_reply.service = NULL; + ptr->data.naptr_reply.regexp = NULL; + ptr->data.naptr_reply.replacement = NULL; + ptr->data.naptr_reply.order = 0; + ptr->data.naptr_reply.preference = 0; + break; + + case ARES_DATATYPE_SOA_REPLY: + ptr->data.soa_reply.nsname = NULL; + ptr->data.soa_reply.hostmaster = NULL; + ptr->data.soa_reply.serial = 0; + ptr->data.soa_reply.refresh = 0; + ptr->data.soa_reply.retry = 0; + ptr->data.soa_reply.expire = 0; + ptr->data.soa_reply.minttl = 0; + break; + default: free(ptr); return NULL; diff --git a/deps/uv/src/ares/ares_data.h b/deps/uv/src/ares/ares_data.h index de1608be5b..8974295fb7 100644 --- a/deps/uv/src/ares/ares_data.h +++ b/deps/uv/src/ares/ares_data.h @@ -1,5 +1,5 @@ -/* Copyright (C) 2009-2010 by Daniel Stenberg +/* Copyright (C) 2009-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -20,6 +20,8 @@ typedef enum { ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */ ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */ ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */ + ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */ + ARES_DATATYPE_SOA_REPLY, /* struct ares_soa_reply - introduced in 1.9.0 */ #if 0 ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */ ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */ @@ -53,10 +55,12 @@ struct ares_data { ares_datatype type; /* Actual data type identifier. */ unsigned int mark; /* Private ares_data signature. */ union { - struct ares_txt_reply txt_reply; - struct ares_srv_reply srv_reply; - struct ares_addr_node addr_node; - struct ares_mx_reply mx_reply; + struct ares_txt_reply txt_reply; + struct ares_srv_reply srv_reply; + struct ares_addr_node addr_node; + struct ares_mx_reply mx_reply; + struct ares_naptr_reply naptr_reply; + struct ares_soa_reply soa_reply; } data; }; diff --git a/deps/uv/src/ares/ares_destroy.c b/deps/uv/src/ares/ares_destroy.c index 5e274daeef..a3f6ea200e 100644 --- a/deps/uv/src/ares/ares_destroy.c +++ b/deps/uv/src/ares/ares_destroy.c @@ -1,6 +1,6 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. - * Copyright (C) 2004-2010 by Daniel Stenberg + * Copyright (C) 2004-2011 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -29,10 +29,12 @@ void ares_destroy_options(struct ares_options *options) free(options->servers); for (i = 0; i < options->ndomains; i++) free(options->domains[i]); - free(options->domains); + if(options->domains) + free(options->domains); if(options->sortlist) free(options->sortlist); - free(options->lookups); + if(options->lookups) + free(options->lookups); } void ares_destroy(ares_channel channel) diff --git a/deps/uv/src/ares/ares_dns.h b/deps/uv/src/ares/ares_dns.h index 6893c024c8..34cf790df7 100644 --- a/deps/uv/src/ares/ares_dns.h +++ b/deps/uv/src/ares/ares_dns.h @@ -1,5 +1,7 @@ +#ifndef HEADER_CARES_DNS_H +#define HEADER_CARES_DNS_H -/* Copyright 1998 by the Massachusetts Institute of Technology. +/* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -14,12 +16,23 @@ * without express or implied warranty. */ -#ifndef ARES__DNS_H -#define ARES__DNS_H +/* + * Macro DNS__16BIT reads a network short (16 bit) given in network + * byte order, and returns its value as an unsigned short. + */ +#define DNS__16BIT(p) ((unsigned short)((unsigned int) 0xffff & \ + (((unsigned int)((unsigned char)(p)[0]) << 8U) | \ + ((unsigned int)((unsigned char)(p)[1]))))) -#define DNS__16BIT(p) (((p)[0] << 8) | (p)[1]) -#define DNS__32BIT(p) (((p)[0] << 24) | ((p)[1] << 16) | \ - ((p)[2] << 8) | (p)[3]) +/* + * Macro DNS__32BIT reads a network long (32 bit) given in network + * byte order, and returns its value as an unsigned int. + */ +#define DNS__32BIT(p) ((unsigned int) \ + (((unsigned int)((unsigned char)(p)[0]) << 24U) | \ + ((unsigned int)((unsigned char)(p)[1]) << 16U) | \ + ((unsigned int)((unsigned char)(p)[2]) << 8U) | \ + ((unsigned int)((unsigned char)(p)[3])))) #define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \ ((p)[1] = (unsigned char)((v) & 0xff))) @@ -87,4 +100,4 @@ #define DNS_RR_SET_TTL(r) DNS__SET32BIT((r) + 4, v) #define DNS_RR_SET_LEN(r) DNS__SET16BIT((r) + 8, v) -#endif /* ARES__DNS_H */ +#endif /* HEADER_CARES_DNS_H */ diff --git a/deps/uv/src/ares/ares_expand_name.c b/deps/uv/src/ares/ares_expand_name.c index e3eccd2f74..71ff0dae0a 100644 --- a/deps/uv/src/ares/ares_expand_name.c +++ b/deps/uv/src/ares/ares_expand_name.c @@ -1,5 +1,5 @@ -/* Copyright 1998 by the Massachusetts Institute of Technology. +/* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -33,6 +33,7 @@ #include #include "ares.h" +#include "ares_nowarn.h" #include "ares_private.h" /* for the memdebug */ static int name_length(const unsigned char *encoded, const unsigned char *abuf, @@ -91,9 +92,9 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, /* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but valid) */ if ((*encoded & INDIR_MASK) == INDIR_MASK) - *enclen = 2; + *enclen = 2L; else - *enclen = 1; /* the caller should move one byte to get past this */ + *enclen = 1L; /* the caller should move one byte to get past this */ return ARES_SUCCESS; } @@ -106,7 +107,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, { if (!indir) { - *enclen = p + 2 - encoded; + *enclen = aresx_uztosl(p + 2U - encoded); indir = 1; } p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1)); @@ -126,7 +127,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, } } if (!indir) - *enclen = p + 1 - encoded; + *enclen = aresx_uztosl(p + 1U - encoded); /* Nuke the trailing period if we wrote one. */ if (q > *s) diff --git a/deps/uv/src/ares/ares_gethostbyname.c b/deps/uv/src/ares/ares_gethostbyname.c index ad89dc27bf..4869402ba9 100644 --- a/deps/uv/src/ares/ares_gethostbyname.c +++ b/deps/uv/src/ares/ares_gethostbyname.c @@ -1,5 +1,5 @@ -/* Copyright 1998 by the Massachusetts Institute of Technology. +/* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -49,6 +49,7 @@ #include "inet_net_pton.h" #include "bitncmp.h" #include "ares_platform.h" +#include "ares_nowarn.h" #include "ares_private.h" #ifdef WATT32 @@ -300,7 +301,7 @@ static int fake_hostent(const char *name, int family, /* Fill in the rest of the host structure and terminate the query. */ addrs[1] = NULL; hostent.h_aliases = aliases; - hostent.h_addrtype = family; + hostent.h_addrtype = aresx_sitoss(family); hostent.h_addr_list = addrs; callback(arg, ARES_SUCCESS, 0, &hostent); diff --git a/deps/uv/src/ares/ares_getnameinfo.c b/deps/uv/src/ares/ares_getnameinfo.c index 82e261dae4..cdcd516494 100644 --- a/deps/uv/src/ares/ares_getnameinfo.c +++ b/deps/uv/src/ares/ares_getnameinfo.c @@ -188,7 +188,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, if (sa->sa_family == AF_INET) { niquery->family = AF_INET; - memcpy(&niquery->addr.addr4, addr, sizeof(struct in_addr)); + memcpy(&niquery->addr.addr4, addr, sizeof(niquery->addr.addr4)); ares_gethostbyaddr(channel, &addr->sin_addr, sizeof(struct in_addr), AF_INET, nameinfo_callback, niquery); @@ -196,7 +196,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, else { niquery->family = AF_INET6; - memcpy(&niquery->addr.addr6, addr6, sizeof(struct ares_in6_addr)); + memcpy(&niquery->addr.addr6, addr6, sizeof(niquery->addr.addr6)); ares_gethostbyaddr(channel, &addr6->sin6_addr, sizeof(struct ares_in6_addr), AF_INET6, nameinfo_callback, niquery); diff --git a/deps/uv/src/ares/ares_init.c b/deps/uv/src/ares/ares_init.c index 52bb4d6c89..4aef21ad47 100644 --- a/deps/uv/src/ares/ares_init.c +++ b/deps/uv/src/ares/ares_init.c @@ -1,6 +1,6 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. - * Copyright (C) 2007-2011 by Daniel Stenberg + * Copyright (C) 2007-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -60,23 +60,27 @@ #include #include -#ifdef ANDROID +#if defined(ANDROID) || defined(__ANDROID__) #include +/* From the Bionic sources */ +#define DNS_PROP_NAME_PREFIX "net.dns" +#define MAX_DNS_PROPERTIES 8 #endif #include "ares.h" +#include "inet_ntop.h" #include "inet_net_pton.h" #include "ares_library_init.h" #include "ares_nowarn.h" #include "ares_platform.h" -#include "inet_ntop.h" #include "ares_private.h" #ifdef WATT32 #undef WIN32 /* Redefined in MingW/MSVC headers */ #endif -static int init_by_options(ares_channel channel, const struct ares_options *options, +static int init_by_options(ares_channel channel, + const struct ares_options *options, int optmask); static int init_by_environment(ares_channel channel); static int init_by_resolv_conf(ares_channel channel); @@ -91,8 +95,10 @@ static int set_options(ares_channel channel, const char *str); static const char *try_option(const char *p, const char *q, const char *opt); static int init_id_key(rc4_key* key,int key_data_len); -#if !defined(WIN32) && !defined(WATT32) -static int sortlist_alloc(struct apattern **sortlist, int *nsort, struct apattern *pat); +#if !defined(WIN32) && !defined(WATT32) && \ + !defined(ANDROID) && !defined(__ANDROID__) +static int sortlist_alloc(struct apattern **sortlist, int *nsort, + struct apattern *pat); static int ip_addr(const char *s, ssize_t len, struct in_addr *addr); static void natural_mask(struct apattern *pat); static int config_domain(ares_channel channel, char *str); @@ -293,7 +299,8 @@ int ares_dup(ares_channel *dest, ares_channel src) (*dest)->sock_create_cb = src->sock_create_cb; (*dest)->sock_create_cb_data = src->sock_create_cb_data; - strncpy((*dest)->local_dev_name, src->local_dev_name, sizeof(src->local_dev_name)); + strncpy((*dest)->local_dev_name, src->local_dev_name, + sizeof(src->local_dev_name)); (*dest)->local_ip4 = src->local_ip4; memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6)); @@ -348,8 +355,8 @@ int ares_save_options(ares_channel channel, struct ares_options *options, options->timeout = channel->timeout; options->tries = channel->tries; options->ndots = channel->ndots; - options->udp_port = (unsigned short)channel->udp_port; - options->tcp_port = (unsigned short)channel->tcp_port; + options->udp_port = ntohs(aresx_sitous(channel->udp_port)); + options->tcp_port = ntohs(aresx_sitous(channel->tcp_port)); options->sock_state_cb = channel->sock_state_cb; options->sock_state_cb_data = channel->sock_state_cb_data; @@ -431,9 +438,9 @@ static int init_by_options(ares_channel channel, if ((optmask & ARES_OPT_ROTATE) && channel->rotate == -1) channel->rotate = 1; if ((optmask & ARES_OPT_UDP_PORT) && channel->udp_port == -1) - channel->udp_port = options->udp_port; + channel->udp_port = htons(options->udp_port); if ((optmask & ARES_OPT_TCP_PORT) && channel->tcp_port == -1) - channel->tcp_port = options->tcp_port; + channel->tcp_port = htons(options->tcp_port); if ((optmask & ARES_OPT_SOCK_STATE_CB) && channel->sock_state_cb == NULL) { channel->sock_state_cb = options->sock_state_cb; @@ -539,258 +546,536 @@ static int init_by_environment(ares_channel channel) #ifdef WIN32 /* - * Warning: returns a dynamically allocated buffer, the user MUST - * use free() if the function returns 1 + * get_REG_SZ() + * + * Given a 'hKey' handle to an open registry key and a 'leafKeyName' pointer + * to the name of the registry leaf key to be queried, fetch it's string + * value and return a pointer in *outptr to a newly allocated memory area + * holding it as a null-terminated string. + * + * Returns 0 and nullifies *outptr upon inability to return a string value. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + * + * Supported on Windows NT 3.5 and newer. */ -static int get_res_nt(HKEY hKey, const char *subkey, char **obuf) +static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) { - /* Test for the size we need */ DWORD size = 0; - int result; + int res; + + *outptr = NULL; - result = RegQueryValueEx(hKey, subkey, 0, NULL, NULL, &size); - if ((result != ERROR_SUCCESS && result != ERROR_MORE_DATA) || !size) + /* Find out size of string stored in registry */ + res = RegQueryValueEx(hKey, leafKeyName, 0, NULL, NULL, &size); + if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) return 0; - *obuf = malloc(size+1); - if (!*obuf) + + /* Allocate buffer of indicated size plus one given that string + might have been stored without null termination */ + *outptr = malloc(size+1); + if (!*outptr) return 0; - if (RegQueryValueEx(hKey, subkey, 0, NULL, - (LPBYTE)*obuf, &size) != ERROR_SUCCESS) + /* Get the value for real */ + res = RegQueryValueEx(hKey, leafKeyName, 0, NULL, + (unsigned char *)*outptr, &size); + if ((res != ERROR_SUCCESS) || (size == 1)) { - free(*obuf); + free(*outptr); + *outptr = NULL; return 0; } - if (size == 1) + + /* Null terminate buffer allways */ + *(*outptr + size) = '\0'; + + return 1; +} + +/* + * get_REG_SZ_9X() + * + * Functionally identical to get_REG_SZ() + * + * Supported on Windows 95, 98 and ME. + */ +static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr) +{ + DWORD dataType = 0; + DWORD size = 0; + int res; + + *outptr = NULL; + + /* Find out size of string stored in registry */ + res = RegQueryValueEx(hKey, leafKeyName, 0, &dataType, NULL, &size); + if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) + return 0; + + /* Allocate buffer of indicated size plus one given that string + might have been stored without null termination */ + *outptr = malloc(size+1); + if (!*outptr) + return 0; + + /* Get the value for real */ + res = RegQueryValueEx(hKey, leafKeyName, 0, &dataType, + (unsigned char *)*outptr, &size); + if ((res != ERROR_SUCCESS) || (size == 1)) { - free(*obuf); + free(*outptr); + *outptr = NULL; return 0; } + + /* Null terminate buffer allways */ + *(*outptr + size) = '\0'; + return 1; } -static int get_res_interfaces_nt(HKEY hKey, const char *subkey, char **obuf) +/* + * get_enum_REG_SZ() + * + * Given a 'hKeyParent' handle to an open registry key and a 'leafKeyName' + * pointer to the name of the registry leaf key to be queried, parent key + * is enumerated searching in child keys for given leaf key name and its + * associated string value. When located, this returns a pointer in *outptr + * to a newly allocated memory area holding it as a null-terminated string. + * + * Returns 0 and nullifies *outptr upon inability to return a string value. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + * + * Supported on Windows NT 3.5 and newer. + */ +static int get_enum_REG_SZ(HKEY hKeyParent, const char *leafKeyName, + char **outptr) { - char enumbuf[39]; /* GUIDs are 38 chars + 1 for NULL */ - DWORD enum_size = 39; - int idx = 0; - HKEY hVal; + char enumKeyName[256]; + DWORD enumKeyNameBuffSize; + DWORD enumKeyIdx = 0; + HKEY hKeyEnum; + int gotString; + int res; - while (RegEnumKeyEx(hKey, idx++, enumbuf, &enum_size, 0, - NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS) - { - int rc; + *outptr = NULL; - enum_size = 39; - if (RegOpenKeyEx(hKey, enumbuf, 0, KEY_QUERY_VALUE, &hVal) != - ERROR_SUCCESS) + for(;;) + { + enumKeyNameBuffSize = sizeof(enumKeyName); + res = RegEnumKeyEx(hKeyParent, enumKeyIdx++, enumKeyName, + &enumKeyNameBuffSize, 0, NULL, NULL, NULL); + if (res != ERROR_SUCCESS) + break; + res = RegOpenKeyEx(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE, + &hKeyEnum); + if (res != ERROR_SUCCESS) continue; - rc = get_res_nt(hVal, subkey, obuf); - RegCloseKey(hVal); - if (rc) - return 1; - } - return 0; + gotString = get_REG_SZ(hKeyEnum, leafKeyName, outptr); + RegCloseKey(hKeyEnum); + if (gotString) + break; + } + + if (!*outptr) + return 0; + + return 1; } -/** - * The desired output for this method is that we set "ret_buf" to - * something like: +/* + * get_DNS_Registry_9X() * - * 192.168.0.1,dns01.my.domain,fe80::200:f8ff:fe21:67cf + * Functionally identical to get_DNS_Registry() * - * The only ordering requirement is that primary servers are listed - * before secondary. There is no requirement that IPv4 addresses should - * necessarily be before IPv6. + * Implementation supports Windows 95, 98 and ME. + */ +static int get_DNS_Registry_9X(char **outptr) +{ + HKEY hKey_VxD_MStcp; + int gotString; + int res; + + *outptr = NULL; + + res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ, + &hKey_VxD_MStcp); + if (res != ERROR_SUCCESS) + return 0; + + gotString = get_REG_SZ_9X(hKey_VxD_MStcp, NAMESERVER, outptr); + RegCloseKey(hKey_VxD_MStcp); + + if (!gotString || !*outptr) + return 0; + + return 1; +} + +/* + * get_DNS_Registry_NT() + * + * Functionally identical to get_DNS_Registry() * - * Note that ret_size should ideally be big enough to hold around - * 2-3 IPv4 and 2-3 IPv6 addresses. + * Refs: Microsoft Knowledge Base articles KB120642 and KB314053. * - * Finally, we need to return the total number of DNS servers located. + * Implementation supports Windows NT 3.5 and newer. */ -static int get_iphlpapi_dns_info (char *ret_buf, size_t ret_size) +static int get_DNS_Registry_NT(char **outptr) { - const size_t ipv4_size = INET_ADDRSTRLEN + 1; /* +1 for ',' at end */ - const size_t ipv6_size = INET6_ADDRSTRLEN + 12; /* +12 for "%0123456789," at end */ - size_t left = ret_size; - char *ret = ret_buf; - int count = 0; - - /* Use the GetAdaptersAddresses method if it's available, otherwise - fall back to GetNetworkParams. */ - if (ares_fpGetAdaptersAddresses != ZERO_NULL) + HKEY hKey_Interfaces = NULL; + HKEY hKey_Tcpip_Parameters; + int gotString; + int res; + + *outptr = NULL; + + res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, + &hKey_Tcpip_Parameters); + if (res != ERROR_SUCCESS) + return 0; + + /* + ** Global DNS settings override adapter specific parameters when both + ** are set. Additionally static DNS settings override DHCP-configured + ** parameters when both are set. + */ + + /* Global DNS static parameters */ + gotString = get_REG_SZ(hKey_Tcpip_Parameters, NAMESERVER, outptr); + if (gotString) + goto done; + + /* Global DNS DHCP-configured parameters */ + gotString = get_REG_SZ(hKey_Tcpip_Parameters, DHCPNAMESERVER, outptr); + if (gotString) + goto done; + + /* Try adapter specific parameters */ + res = RegOpenKeyEx(hKey_Tcpip_Parameters, "Interfaces", 0, + KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, + &hKey_Interfaces); + if (res != ERROR_SUCCESS) { - const ULONG working_buf_size = 15000; - IP_ADAPTER_ADDRESSES *pFirstEntry = NULL; - IP_ADAPTER_ADDRESSES *pEntry = NULL; - ULONG bufSize = 0; - ULONG result = 0; - - /* According to MSDN, the recommended way to do this is to use a temporary - buffer of 15K, to "dramatically reduce the chance that the GetAdaptersAddresses - method returns ERROR_BUFFER_OVERFLOW" */ - pFirstEntry = ( IP_ADAPTER_ADDRESSES * ) malloc( working_buf_size ); - bufSize = working_buf_size; - if( !pFirstEntry ) - return 0; - - /* Call the method one time */ - result = ( *ares_fpGetAdaptersAddresses )( AF_UNSPEC, 0, 0, pFirstEntry, &bufSize ); - if( result == ERROR_BUFFER_OVERFLOW ) - { - /* Reallocate, bufSize should now be set to the required size */ - pFirstEntry = ( IP_ADAPTER_ADDRESSES * ) realloc( pFirstEntry, bufSize ); - if( !pFirstEntry ) - return 0; - - /* Call the method a second time */ - result = ( *ares_fpGetAdaptersAddresses )( AF_UNSPEC, 0, 0, pFirstEntry, &bufSize ); - if( result == ERROR_BUFFER_OVERFLOW ) - { - /* Reallocate, bufSize should now be set to the required size */ - pFirstEntry = ( IP_ADAPTER_ADDRESSES * ) realloc( pFirstEntry, bufSize ); - if( !pFirstEntry ) - return 0; - - /* Call the method a third time. The maximum number of times we're going to do - this is 3. Three shall be the number thou shalt count, and the number of the - counting shall be three. Five is right out. */ - result = ( *ares_fpGetAdaptersAddresses )( AF_UNSPEC, 0, 0, pFirstEntry, &bufSize ); - } - } + hKey_Interfaces = NULL; + goto done; + } - /* Check the current result for failure */ - if( result != ERROR_SUCCESS ) - { - free( pFirstEntry ); - return 0; - } + /* Adapter specific DNS static parameters */ + gotString = get_enum_REG_SZ(hKey_Interfaces, NAMESERVER, outptr); + if (gotString) + goto done; - /* process the results */ - for( pEntry = pFirstEntry ; pEntry != NULL ; pEntry = pEntry->Next ) - { - IP_ADAPTER_DNS_SERVER_ADDRESS* pDNSAddr = pEntry->FirstDnsServerAddress; - for( ; pDNSAddr != NULL ; pDNSAddr = pDNSAddr->Next ) - { - struct sockaddr *pGenericAddr = pDNSAddr->Address.lpSockaddr; - size_t stringlen = 0; + /* Adapter specific DNS DHCP-configured parameters */ + gotString = get_enum_REG_SZ(hKey_Interfaces, DHCPNAMESERVER, outptr); - if( pGenericAddr->sa_family == AF_INET && left > ipv4_size ) - { - /* Handle the v4 case */ - struct sockaddr_in *pIPv4Addr = ( struct sockaddr_in * ) pGenericAddr; - ares_inet_ntop( AF_INET, &pIPv4Addr->sin_addr, ret, ipv4_size - 1 ); /* -1 for comma */ - - /* Append a comma to the end, THEN NULL. Should be OK because we - already tested the size at the top of the if statement. */ - stringlen = strlen( ret ); - ret[ stringlen ] = ','; - ret[ stringlen + 1 ] = '\0'; - ret += stringlen + 1; - left -= ret - ret_buf; - ++count; - } - else if( pGenericAddr->sa_family == AF_INET6 && left > ipv6_size ) - { - /* Handle the v6 case */ - struct sockaddr_in6 *pIPv6Addr = ( struct sockaddr_in6 * ) pGenericAddr; - ares_inet_ntop( AF_INET6, &pIPv6Addr->sin6_addr, ret, ipv6_size - 1 ); /* -1 for comma */ - - stringlen = strlen( ret ); - - /* Windows apparently always reports some IPv6 DNS servers that - prefixed with fec0:0:0:ffff. These ususally do not point to - working DNS servers, so we ignore them. */ - if (strncmp(ret, "fec0:0:0:ffff:", 14) != 0) { - /* Append a comma to the end, THEN NULL. Should be OK because we - already tested the size at the top of the if statement. */ - ret[ stringlen ] = ','; - ret[ stringlen + 1 ] = '\0'; - ret += stringlen + 1; - left -= ret - ret_buf; - ++count; - } - } - } - } +done: + if (hKey_Interfaces) + RegCloseKey(hKey_Interfaces); - if( pFirstEntry ) - free( pFirstEntry ); - if (ret > ret_buf) - ret[-1] = '\0'; - return count; + RegCloseKey(hKey_Tcpip_Parameters); + + if (!gotString || !*outptr) + return 0; + + return 1; +} + +/* + * get_DNS_Registry() + * + * Locates DNS info in the registry. When located, this returns a pointer + * in *outptr to a newly allocated memory area holding a null-terminated + * string with a space or comma seperated list of DNS IP addresses. + * + * Returns 0 and nullifies *outptr upon inability to return DNSes string. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + */ +static int get_DNS_Registry(char **outptr) +{ + win_platform platform; + int gotString = 0; + + *outptr = NULL; + + platform = ares__getplatform(); + + if (platform == WIN_NT) + gotString = get_DNS_Registry_NT(outptr); + else if (platform == WIN_9X) + gotString = get_DNS_Registry_9X(outptr); + + if (!gotString) + return 0; + + return 1; +} + +/* + * commajoin() + * + * RTF code. + */ +static void commajoin(char **dst, const char *src) +{ + char *tmp; + + if (*dst) + { + tmp = malloc(strlen(*dst) + strlen(src) + 2); + if (!tmp) + return; + sprintf(tmp, "%s,%s", *dst, src); + free(*dst); + *dst = tmp; } else { - FIXED_INFO *fi, *newfi; - DWORD size = sizeof (*fi); - IP_ADDR_STRING *ipAddr; - int i; - int debug = 0; - HRESULT res; - - fi = malloc(size); - if (!fi) - return 0; - - res = (*ares_fpGetNetworkParams) (fi, &size); - if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) - goto quit; - - newfi = realloc(fi, size); - if (!newfi) - goto quit; - - fi = newfi; - res = (*ares_fpGetNetworkParams) (fi, &size); - if (res != ERROR_SUCCESS) - goto quit; + *dst = malloc(strlen(src) + 1); + if (!*dst) + return; + strcpy(*dst, src); + } +} + +/* + * get_DNS_NetworkParams() + * + * Locates DNS info using GetNetworkParams() function from the Internet + * Protocol Helper (IP Helper) API. When located, this returns a pointer + * in *outptr to a newly allocated memory area holding a null-terminated + * string with a space or comma seperated list of DNS IP addresses. + * + * Returns 0 and nullifies *outptr upon inability to return DNSes string. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + * + * Implementation supports Windows 98 and newer. + * + * Note: Ancient PSDK required in order to build a W98 target. + */ +static int get_DNS_NetworkParams(char **outptr) +{ + FIXED_INFO *fi, *newfi; + struct ares_addr namesrvr; + char *txtaddr; + IP_ADDR_STRING *ipAddr; + int res; + DWORD size = sizeof (*fi); + + *outptr = NULL; + + /* Verify run-time availability of GetNetworkParams() */ + if (ares_fpGetNetworkParams == ZERO_NULL) + return 0; + + fi = malloc(size); + if (!fi) + return 0; + + res = (*ares_fpGetNetworkParams) (fi, &size); + if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) + goto done; + + newfi = realloc(fi, size); + if (!newfi) + goto done; + + fi = newfi; + res = (*ares_fpGetNetworkParams) (fi, &size); + if (res != ERROR_SUCCESS) + goto done; - if (debug) + for (ipAddr = &fi->DnsServerList; ipAddr; ipAddr = ipAddr->Next) + { + txtaddr = &ipAddr->IpAddress.String[0]; + + /* Validate converting textual address to binary format. */ + if (ares_inet_pton(AF_INET, txtaddr, &namesrvr.addrV4) == 1) + { + if ((namesrvr.addrV4.S_un.S_addr == INADDR_ANY) || + (namesrvr.addrV4.S_un.S_addr == INADDR_NONE)) + continue; + } + else if (ares_inet_pton(AF_INET6, txtaddr, &namesrvr.addrV6) == 1) { - printf ("Host Name: %s\n", fi->HostName); - printf ("Domain Name: %s\n", fi->DomainName); - printf ("DNS Servers:\n" - " %s (primary)\n", fi->DnsServerList.IpAddress.String); + if (memcmp(&namesrvr.addrV6, &ares_in6addr_any, + sizeof(namesrvr.addrV6)) == 0) + continue; } - if (strlen(fi->DnsServerList.IpAddress.String) > 0 && - inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE && - left > ipv4_size) + else + continue; + + commajoin(outptr, txtaddr); + + if (!*outptr) + break; + } + +done: + if (fi) + free(fi); + + if (!*outptr) + return 0; + + return 1; +} + +/* + * get_DNS_AdaptersAddresses() + * + * Locates DNS info using GetAdaptersAddresses() function from the Internet + * Protocol Helper (IP Helper) API. When located, this returns a pointer + * in *outptr to a newly allocated memory area holding a null-terminated + * string with a space or comma seperated list of DNS IP addresses. + * + * Returns 0 and nullifies *outptr upon inability to return DNSes string. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + * + * Implementation supports Windows XP and newer. + */ +#define IPAA_INITIAL_BUF_SZ 15 * 1024 +#define IPAA_MAX_TRIES 3 +static int get_DNS_AdaptersAddresses(char **outptr) +{ + IP_ADAPTER_DNS_SERVER_ADDRESS *ipaDNSAddr; + IP_ADAPTER_ADDRESSES *ipaa, *newipaa, *ipaaEntry; + ULONG ReqBufsz = IPAA_INITIAL_BUF_SZ; + ULONG Bufsz = IPAA_INITIAL_BUF_SZ; + ULONG AddrFlags = 0; + int trying = IPAA_MAX_TRIES; + int res; + + union { + struct sockaddr *sa; + struct sockaddr_in *sa4; + struct sockaddr_in6 *sa6; + } namesrvr; + + char txtaddr[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; + + *outptr = NULL; + + /* Verify run-time availability of GetAdaptersAddresses() */ + if (ares_fpGetAdaptersAddresses == ZERO_NULL) + return 0; + + ipaa = malloc(Bufsz); + if (!ipaa) + return 0; + + /* Usually this call suceeds with initial buffer size */ + res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, + ipaa, &ReqBufsz); + if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) + goto done; + + while ((res == ERROR_BUFFER_OVERFLOW) && (--trying)) + { + if (Bufsz < ReqBufsz) { - ret += sprintf (ret, "%s,", fi->DnsServerList.IpAddress.String); - left -= ret - ret_buf; - ++count; + newipaa = realloc(ipaa, ReqBufsz); + if (!newipaa) + goto done; + Bufsz = ReqBufsz; + ipaa = newipaa; } + res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, + ipaa, &ReqBufsz); + if (res == ERROR_SUCCESS) + break; + } + if (res != ERROR_SUCCESS) + goto done; - for (i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ipv4_size; - ipAddr = ipAddr->Next, i++) + for (ipaaEntry = ipaa; ipaaEntry; ipaaEntry = ipaaEntry->Next) + { + for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; + ipaDNSAddr; + ipaDNSAddr = ipaDNSAddr->Next) { - if (inet_addr(ipAddr->IpAddress.String) != INADDR_NONE) + namesrvr.sa = ipaDNSAddr->Address.lpSockaddr; + + if (namesrvr.sa->sa_family == AF_INET) { - ret += sprintf (ret, "%s,", ipAddr->IpAddress.String); - left -= ret - ret_buf; - ++count; + if ((namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_ANY) || + (namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_NONE)) + continue; + if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, + txtaddr, sizeof(txtaddr))) + continue; } - if (debug) - printf (" %s (secondary %d)\n", ipAddr->IpAddress.String, i+1); - } + else if (namesrvr.sa->sa_family == AF_INET6) + { + /* Windows apparently always reports some IPv6 DNS servers that + * prefixed with fec0:0:0:ffff. These ususally do not point to + * working DNS servers, so we ignore them. */ + if (strncmp(txtaddr, "fec0:0:0:ffff:", 14) == 0) + continue; + if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any, + sizeof(namesrvr.sa6->sin6_addr)) == 0) + continue; + if (! ares_inet_ntop(AF_INET, &namesrvr.sa6->sin6_addr, + txtaddr, sizeof(txtaddr))) + continue; + } + else + continue; -quit: - if (fi) - free(fi); + commajoin(outptr, txtaddr); - if (debug && left <= ipv4_size) - printf ("Too many nameservers. Truncating to %d addressess", count); - if (ret > ret_buf) - ret[-1] = '\0'; - return count; + if (!*outptr) + goto done; + } } + +done: + if (ipaa) + free(ipaa); + + if (!*outptr) + return 0; + + return 1; +} + +/* + * get_DNS_Windows() + * + * Locates DNS info from Windows employing most suitable methods available at + * run-time no matter which Windows version it is. When located, this returns + * a pointer in *outptr to a newly allocated memory area holding a string with + * a space or comma seperated list of DNS IP addresses, null-terminated. + * + * Returns 0 and nullifies *outptr upon inability to return DNSes string. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + * + * Implementation supports Windows 95 and newer. + */ +static int get_DNS_Windows(char **outptr) +{ + /* Try using IP helper API GetAdaptersAddresses() */ + if (get_DNS_AdaptersAddresses(outptr)) + return 1; + + /* Try using IP helper API GetNetworkParams() */ + if (get_DNS_NetworkParams(outptr)) + return 1; + + /* Fall-back to registry information */ + return get_DNS_Registry(outptr); } #endif static int init_by_resolv_conf(ares_channel channel) { -#ifndef WATT32 +#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(WATT32) char *line = NULL; #endif int status = -1, nservers = 0, nsort = 0; @@ -799,111 +1084,13 @@ static int init_by_resolv_conf(ares_channel channel) #ifdef WIN32 - /* - NameServer info via IPHLPAPI (IP helper API): - GetNetworkParams() should be the trusted source for this. - Available in Win-98/2000 and later. If that fail, fall-back to - registry information. - - NameServer Registry: - - On Windows 9X, the DNS server can be found in: -HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP\NameServer - - On Windows NT/2000/XP/2003: -HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NameServer - or -HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DhcpNameServer - or -HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\{AdapterID}\ -NameServer - or -HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\{AdapterID}\ -DhcpNameServer - */ - - HKEY mykey; - HKEY subkey; - DWORD data_type; - DWORD bytes; - DWORD result; - char buf[512]; - win_platform platform; - if (channel->nservers > -1) /* don't override ARES_OPT_SERVER */ return ARES_SUCCESS; - if (get_iphlpapi_dns_info(buf,sizeof(buf)) > 0) + if (get_DNS_Windows(&line)) { - status = config_nameserver(&servers, &nservers, buf); - if (status == ARES_SUCCESS) - goto okay; - } - - platform = ares__getplatform(); - - if (platform == WIN_NT) - { - if (RegOpenKeyEx( - HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, - KEY_READ, &mykey - ) == ERROR_SUCCESS) - { - RegOpenKeyEx(mykey, "Interfaces", 0, - KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &subkey); - if (get_res_nt(mykey, NAMESERVER, &line)) - { - status = config_nameserver(&servers, &nservers, line); - free(line); - } - else if (get_res_nt(mykey, DHCPNAMESERVER, &line)) - { - status = config_nameserver(&servers, &nservers, line); - free(line); - } - /* Try the interfaces */ - else if (get_res_interfaces_nt(subkey, NAMESERVER, &line)) - { - status = config_nameserver(&servers, &nservers, line); - free(line); - } - else if (get_res_interfaces_nt(subkey, DHCPNAMESERVER, &line)) - { - status = config_nameserver(&servers, &nservers, line); - free(line); - } - RegCloseKey(subkey); - RegCloseKey(mykey); - } - } - else if (platform == WIN_9X) - { - if (RegOpenKeyEx( - HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, - KEY_READ, &mykey - ) == ERROR_SUCCESS) - { - if ((result = RegQueryValueEx( - mykey, NAMESERVER, NULL, &data_type, - NULL, &bytes - ) - ) == ERROR_SUCCESS || - result == ERROR_MORE_DATA) - { - if (bytes) - { - line = malloc(bytes+1); - if (RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type, - (unsigned char *)line, &bytes) == - ERROR_SUCCESS) - { - status = config_nameserver(&servers, &nservers, line); - } - free(line); - } - } - } - RegCloseKey(mykey); + status = config_nameserver(&servers, &nservers, line); + free(line); } if (status == ARES_SUCCESS) @@ -964,12 +1151,22 @@ DhcpNameServer } status = ARES_EOF; -#elif defined(ANDROID) - char value[PROP_VALUE_MAX]=""; - __system_property_get("net.dns1", value); - status = config_nameserver(&servers, &nservers, value); - if (status == ARES_SUCCESS) +#elif defined(ANDROID) || defined(__ANDROID__) + unsigned int i; + char propname[PROP_NAME_MAX]; + char propvalue[PROP_VALUE_MAX]=""; + + for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { + snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); + if (__system_property_get(propname, propvalue) < 1) { + status = ARES_EOF; + break; + } + status = config_nameserver(&servers, &nservers, propvalue); + if (status != ARES_SUCCESS) + break; status = ARES_EOF; + } #else { char *p; @@ -1025,7 +1222,8 @@ DhcpNameServer /* Many systems (Solaris, Linux, BSD's) use nsswitch.conf */ fp = fopen("/etc/nsswitch.conf", "r"); if (fp) { - while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) + while ((status = ares__read_line(fp, &line, &linesize)) == + ARES_SUCCESS) { if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups) /* ignore errors */ @@ -1043,7 +1241,8 @@ DhcpNameServer default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); - DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/nsswitch.conf")); + DEBUGF(fprintf(stderr, "Error opening file: %s\n", + "/etc/nsswitch.conf")); status = ARES_EFILE; } } @@ -1053,7 +1252,8 @@ DhcpNameServer /* Linux / GNU libc 2.x and possibly others have host.conf */ fp = fopen("/etc/host.conf", "r"); if (fp) { - while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) + while ((status = ares__read_line(fp, &line, &linesize)) == + ARES_SUCCESS) { if ((p = try_config(line, "order", '\0')) && !channel->lookups) /* ignore errors */ @@ -1071,7 +1271,8 @@ DhcpNameServer default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error))); - DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/host.conf")); + DEBUGF(fprintf(stderr, "Error opening file: %s\n", + "/etc/host.conf")); status = ARES_EFILE; } } @@ -1081,7 +1282,8 @@ DhcpNameServer /* Tru64 uses /etc/svc.conf */ fp = fopen("/etc/svc.conf", "r"); if (fp) { - while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) + while ((status = ares__read_line(fp, &line, &linesize)) == + ARES_SUCCESS) { if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups) /* ignore errors */ @@ -1122,9 +1324,6 @@ DhcpNameServer } /* If we got any name server entries, fill them in. */ -#ifdef WIN32 -okay: -#endif if (servers) { channel->servers = servers; @@ -1189,11 +1388,14 @@ static int init_by_defaults(ares_channel channel) /* Derive a default domain search list from the kernel hostname, * or set it to empty if the hostname isn't helpful. */ +#ifndef HAVE_GETHOSTNAME + channel->ndomains = 0; /* default to none */ +#else + GETHOSTNAME_TYPE_ARG2 lenv = 64; size_t len = 64; int res; channel->ndomains = 0; /* default to none */ -#ifdef HAVE_GETHOSTNAME hostname = malloc(len); if(!hostname) { rc = ARES_ENOMEM; @@ -1201,11 +1403,12 @@ static int init_by_defaults(ares_channel channel) } do { - res = gethostname(hostname, len); + res = gethostname(hostname, lenv); if(toolong(res)) { char *p; len *= 2; + lenv *= 2; p = realloc(hostname, len); if(!p) { rc = ARES_ENOMEM; @@ -1219,7 +1422,7 @@ static int init_by_defaults(ares_channel channel) goto error; } - } while(0); + } WHILE_FALSE; dot = strchr(hostname, '.'); if (dot) { @@ -1252,15 +1455,22 @@ static int init_by_defaults(ares_channel channel) error: if(rc) { - if(channel->servers) + if(channel->servers) { free(channel->servers); + channel->servers = NULL; + } if(channel->domains && channel->domains[0]) free(channel->domains[0]); - if(channel->domains) + if(channel->domains) { free(channel->domains); - if(channel->lookups) + channel->domains = NULL; + } + + if(channel->lookups) { free(channel->lookups); + channel->lookups = NULL; + } } if(hostname) @@ -1269,7 +1479,8 @@ static int init_by_defaults(ares_channel channel) return rc; } -#if !defined(WIN32) && !defined(WATT32) +#if !defined(WIN32) && !defined(WATT32) && \ + !defined(ANDROID) && !defined(__ANDROID__) static int config_domain(ares_channel channel, char *str) { char *q; @@ -1317,7 +1528,7 @@ static int config_lookup(ares_channel channel, const char *str, channel->lookups = strdup(lookups); return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM; } -#endif /* !WIN32 & !WATT32 */ +#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */ #ifndef WATT32 static int config_nameserver(struct server_state **servers, int *nservers, @@ -1382,7 +1593,7 @@ static int config_nameserver(struct server_state **servers, int *nservers, return ARES_SUCCESS; } -#ifndef WIN32 +#if !defined(WIN32) && !defined(ANDROID) && !defined(__ANDROID__) static int config_sortlist(struct apattern **sortlist, int *nsort, const char *str) { @@ -1463,7 +1674,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, return ARES_SUCCESS; } -#endif /* !WIN32 */ +#endif /* !WIN32 & !ANDROID & !__ANDROID__ */ #endif /* !WATT32 */ static int set_search(ares_channel channel, const char *str) @@ -1562,7 +1773,8 @@ static const char *try_option(const char *p, const char *q, const char *opt) return ((size_t)(q - p) >= len && !strncmp(p, opt, len)) ? &p[len] : NULL; } -#if !defined(WIN32) && !defined(WATT32) +#if !defined(WIN32) && !defined(WATT32) && \ + !defined(ANDROID) && !defined(__ANDROID__) static char *try_config(char *s, const char *opt, char scc) { size_t len; @@ -1678,7 +1890,7 @@ static void natural_mask(struct apattern *pat) else pat->mask.addr4.s_addr = htonl(IN_CLASSC_NET); } -#endif /* !WIN32 && !WATT32 */ +#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */ /* initialize an rc4 key. If possible a cryptographically secure random key is generated using a suitable function (for example win32's RtlGenRandom as @@ -1709,7 +1921,7 @@ static void randomize_key(unsigned char* key,int key_data_len) #endif #endif /* WIN32 */ - if ( !randomized ) { + if (!randomized) { for (;counter -#include "ares_iphlpapi.h" +#include typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*); typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG); diff --git a/deps/uv/src/ares/ares_nowarn.c b/deps/uv/src/ares/ares_nowarn.c index 701add58c6..e29efd3337 100644 --- a/deps/uv/src/ares/ares_nowarn.c +++ b/deps/uv/src/ares/ares_nowarn.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2010-2011 by Daniel Stenberg +/* Copyright (C) 2010-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -39,20 +39,32 @@ #include "ares_nowarn.h" -#if (SIZEOF_INT == 2) -# define CARES_MASK_SINT 0x7FFF -# define CARES_MASK_UINT 0xFFFF -#elif (SIZEOF_INT == 4) -# define CARES_MASK_SINT 0x7FFFFFFF -# define CARES_MASK_UINT 0xFFFFFFFF -#elif (SIZEOF_INT == 8) -# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF -# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF -#elif (SIZEOF_INT == 16) -# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +#define CARES_MASK_USHORT (~(unsigned short) 0) +#define CARES_MASK_UINT (~(unsigned int) 0) +#define CARES_MASK_ULONG (~(unsigned long) 0) + +#define CARES_MASK_SSHORT (CARES_MASK_USHORT >> 1) +#define CARES_MASK_SINT (CARES_MASK_UINT >> 1) +#define CARES_MASK_SLONG (CARES_MASK_ULONG >> 1) + +/* +** unsigned size_t to signed long +*/ + +long aresx_uztosl(size_t uznum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ #endif + return (long)(uznum & (size_t) CARES_MASK_SLONG); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + /* ** unsigned size_t to signed int */ @@ -71,6 +83,43 @@ int aresx_uztosi(size_t uznum) #endif } +/* +** unsigned size_t to signed short +*/ + +short aresx_uztoss(size_t uznum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + return (short)(uznum & (size_t) CARES_MASK_SSHORT); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + +/* +** signed int to signed short +*/ + +short aresx_sitoss(int sinum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + DEBUGASSERT(sinum >= 0); + return (short)(sinum & (int) CARES_MASK_SSHORT); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + /* ** signed long to signed int */ @@ -128,6 +177,25 @@ unsigned int aresx_sztoui(ssize_t sznum) #endif } +/* +** signed int to unsigned short +*/ + +unsigned short aresx_sitous(int sinum) +{ +#ifdef __INTEL_COMPILER +# pragma warning(push) +# pragma warning(disable:810) /* conversion may lose significant bits */ +#endif + + DEBUGASSERT(sinum >= 0); + return (unsigned short)(sinum & (int) CARES_MASK_USHORT); + +#ifdef __INTEL_COMPILER +# pragma warning(pop) +#endif +} + #if defined(__INTEL_COMPILER) && defined(__unix__) int aresx_FD_ISSET(int fd, fd_set *fdset) diff --git a/deps/uv/src/ares/ares_nowarn.h b/deps/uv/src/ares/ares_nowarn.h index bcaa22721f..9b76d66325 100644 --- a/deps/uv/src/ares/ares_nowarn.h +++ b/deps/uv/src/ares/ares_nowarn.h @@ -2,7 +2,7 @@ #define HEADER_CARES_NOWARN_H -/* Copyright (C) 2010-2011 by Daniel Stenberg +/* Copyright (C) 2010-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -17,7 +17,11 @@ * without express or implied warranty. */ -int aresx_uztosi(size_t uznum); +long aresx_uztosl(size_t uznum); +int aresx_uztosi(size_t uznum); +short aresx_uztoss(size_t uznum); + +short aresx_sitoss(int sinum); int aresx_sltosi(long slnum); @@ -25,6 +29,8 @@ int aresx_sztosi(ssize_t sznum); unsigned int aresx_sztoui(ssize_t sznum); +unsigned short aresx_sitous(int sinum); + #if defined(__INTEL_COMPILER) && defined(__unix__) int aresx_FD_ISSET(int fd, fd_set *fdset); diff --git a/deps/uv/src/ares/ares_parse_aaaa_reply.c b/deps/uv/src/ares/ares_parse_aaaa_reply.c index 1fbe8389f7..b11df52495 100644 --- a/deps/uv/src/ares/ares_parse_aaaa_reply.c +++ b/deps/uv/src/ares/ares_parse_aaaa_reply.c @@ -204,7 +204,9 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, } } - if (status == ARES_SUCCESS && naddrs == 0) + /* the check for naliases to be zero is to make sure CNAME responses + don't get caught here */ + if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0) status = ARES_ENODATA; if (status == ARES_SUCCESS) { diff --git a/deps/uv/src/ares/ares_parse_naptr_reply.c b/deps/uv/src/ares/ares_parse_naptr_reply.c new file mode 100644 index 0000000000..6a9d09ecb9 --- /dev/null +++ b/deps/uv/src/ares/ares_parse_naptr_reply.c @@ -0,0 +1,188 @@ + +/* Copyright 1998 by the Massachusetts Institute of Technology. + * Copyright (C) 2009 by Jakub Hrozek + * + * 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. + */ + +#include "ares_setup.h" + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#else +# include "nameser.h" +#endif +#ifdef HAVE_ARPA_NAMESER_COMPAT_H +# include +#endif + +#include +#include +#include "ares.h" +#include "ares_dns.h" +#include "ares_data.h" +#include "ares_private.h" + +/* AIX portability check */ +#ifndef T_NAPTR + #define T_NAPTR 35 /* naming authority pointer */ +#endif + +int +ares_parse_naptr_reply (const unsigned char *abuf, int alen, + struct ares_naptr_reply **naptr_out) +{ + unsigned int qdcount, ancount, i; + const unsigned char *aptr, *vptr; + int status, rr_type, rr_class, rr_len; + long len; + char *hostname = NULL, *rr_name = NULL; + struct ares_naptr_reply *naptr_head = NULL; + struct ares_naptr_reply *naptr_last = NULL; + struct ares_naptr_reply *naptr_curr; + + /* Set *naptr_out to NULL for all failure cases. */ + *naptr_out = NULL; + + /* Give up if abuf doesn't have room for a header. */ + if (alen < HFIXEDSZ) + return ARES_EBADRESP; + + /* Fetch the question and answer count from the header. */ + qdcount = DNS_HEADER_QDCOUNT (abuf); + ancount = DNS_HEADER_ANCOUNT (abuf); + if (qdcount != 1) + return ARES_EBADRESP; + if (ancount == 0) + return ARES_ENODATA; + + /* Expand the name from the question, and skip past the question. */ + aptr = abuf + HFIXEDSZ; + status = ares_expand_name (aptr, abuf, alen, &hostname, &len); + if (status != ARES_SUCCESS) + return status; + + if (aptr + len + QFIXEDSZ > abuf + alen) + { + free (hostname); + return ARES_EBADRESP; + } + aptr += len + QFIXEDSZ; + + /* Examine each answer resource record (RR) in turn. */ + for (i = 0; i < ancount; i++) + { + /* Decode the RR up to the data field. */ + status = ares_expand_name (aptr, abuf, alen, &rr_name, &len); + if (status != ARES_SUCCESS) + { + break; + } + aptr += len; + if (aptr + RRFIXEDSZ > abuf + alen) + { + status = ARES_EBADRESP; + break; + } + rr_type = DNS_RR_TYPE (aptr); + rr_class = DNS_RR_CLASS (aptr); + rr_len = DNS_RR_LEN (aptr); + aptr += RRFIXEDSZ; + + /* Check if we are really looking at a NAPTR record */ + if (rr_class == C_IN && rr_type == T_NAPTR) + { + /* parse the NAPTR record itself */ + + /* Allocate storage for this NAPTR answer appending it to the list */ + naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY); + if (!naptr_curr) + { + status = ARES_ENOMEM; + break; + } + if (naptr_last) + { + naptr_last->next = naptr_curr; + } + else + { + naptr_head = naptr_curr; + } + naptr_last = naptr_curr; + + vptr = aptr; + naptr_curr->order = DNS__16BIT(vptr); + vptr += sizeof(unsigned short); + naptr_curr->preference = DNS__16BIT(vptr); + vptr += sizeof(unsigned short); + + status = ares_expand_string(vptr, abuf, alen, &naptr_curr->flags, &len); + if (status != ARES_SUCCESS) + break; + vptr += len; + + status = ares_expand_string(vptr, abuf, alen, &naptr_curr->service, &len); + if (status != ARES_SUCCESS) + break; + vptr += len; + + status = ares_expand_string(vptr, abuf, alen, &naptr_curr->regexp, &len); + if (status != ARES_SUCCESS) + break; + vptr += len; + + status = ares_expand_name(vptr, abuf, alen, &naptr_curr->replacement, &len); + if (status != ARES_SUCCESS) + break; + } + + /* Don't lose memory in the next iteration */ + free (rr_name); + rr_name = NULL; + + /* Move on to the next record */ + aptr += rr_len; + } + + if (hostname) + free (hostname); + if (rr_name) + free (rr_name); + + /* clean up on error */ + if (status != ARES_SUCCESS) + { + if (naptr_head) + ares_free_data (naptr_head); + return status; + } + + /* everything looks fine, return the data */ + *naptr_out = naptr_head; + + return ARES_SUCCESS; +} + diff --git a/deps/uv/src/ares/ares_parse_ptr_reply.c b/deps/uv/src/ares/ares_parse_ptr_reply.c index 3b6dbc32e0..ed4a405bc8 100644 --- a/deps/uv/src/ares/ares_parse_ptr_reply.c +++ b/deps/uv/src/ares/ares_parse_ptr_reply.c @@ -42,6 +42,7 @@ #include #include "ares.h" #include "ares_dns.h" +#include "ares_nowarn.h" #include "ares_private.h" int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, @@ -189,8 +190,8 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, for (i=0 ; ih_aliases[i] = aliases[i]; hostent->h_aliases[aliascnt] = NULL; - hostent->h_addrtype = family; - hostent->h_length = addrlen; + hostent->h_addrtype = aresx_sitoss(family); + hostent->h_length = aresx_sitoss(addrlen); memcpy(hostent->h_addr_list[0], addr, addrlen); hostent->h_addr_list[1] = NULL; *host = hostent; diff --git a/deps/uv/src/ares/ares_parse_soa_reply.c b/deps/uv/src/ares/ares_parse_soa_reply.c new file mode 100644 index 0000000000..b8119544b7 --- /dev/null +++ b/deps/uv/src/ares/ares_parse_soa_reply.c @@ -0,0 +1,135 @@ + +/* Copyright 1998 by the Massachusetts Institute of Technology. + * Copyright (C) 2012 Marko Kreen + * + * 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. + */ + +#include "ares_setup.h" + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#else +# include "nameser.h" +#endif +#ifdef HAVE_ARPA_NAMESER_COMPAT_H +# include +#endif + +#include +#include +#include "ares.h" +#include "ares_dns.h" +#include "ares_data.h" +#include "ares_private.h" + +int +ares_parse_soa_reply(const unsigned char *abuf, int alen, + struct ares_soa_reply **soa_out) +{ + const unsigned char *aptr; + long len; + char *qname = NULL, *rr_name = NULL; + struct ares_soa_reply *soa = NULL; + int qdcount, ancount; + int status; + + if (alen < HFIXEDSZ) + return ARES_EBADRESP; + + /* parse message header */ + qdcount = DNS_HEADER_QDCOUNT(abuf); + ancount = DNS_HEADER_ANCOUNT(abuf); + if (qdcount != 1 || ancount != 1) + return ARES_EBADRESP; + aptr = abuf + HFIXEDSZ; + + /* query name */ + status = ares__expand_name_for_response(aptr, abuf, alen, &qname, &len); + if (status != ARES_SUCCESS) + goto failed_stat; + aptr += len; + + /* skip qtype & qclass */ + if (aptr + QFIXEDSZ > abuf + alen) + goto failed; + aptr += QFIXEDSZ; + + /* rr_name */ + status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); + if (status != ARES_SUCCESS) + goto failed_stat; + aptr += len; + + /* skip rr_type, rr_class, rr_ttl, rr_rdlen */ + if (aptr + RRFIXEDSZ > abuf + alen) + goto failed; + aptr += RRFIXEDSZ; + + /* allocate result struct */ + soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); + if (!soa) + return ARES_ENOMEM; + + /* nsname */ + status = ares__expand_name_for_response(aptr, abuf, alen, &soa->nsname, &len); + if (status != ARES_SUCCESS) + goto failed_stat; + aptr += len; + + /* hostmaster */ + status = ares__expand_name_for_response(aptr, abuf, alen, &soa->hostmaster, &len); + if (status != ARES_SUCCESS) + goto failed_stat; + aptr += len; + + /* integer fields */ + if (aptr + 5 * 4 > abuf + alen) + goto failed; + soa->serial = DNS__32BIT(aptr + 0 * 4); + soa->refresh = DNS__32BIT(aptr + 1 * 4); + soa->retry = DNS__32BIT(aptr + 2 * 4); + soa->expire = DNS__32BIT(aptr + 3 * 4); + soa->minttl = DNS__32BIT(aptr + 4 * 4); + + free(qname); + free(rr_name); + + *soa_out = soa; + + return ARES_SUCCESS; + +failed: + status = ARES_EBADRESP; + +failed_stat: + ares_free_data(soa); + if (qname) + free(qname); + if (rr_name) + free(rr_name); + return status; +} + diff --git a/deps/uv/src/ares/ares_private.h b/deps/uv/src/ares/ares_private.h index ff45ba7e5a..3c56bbcf3b 100644 --- a/deps/uv/src/ares/ares_private.h +++ b/deps/uv/src/ares/ares_private.h @@ -342,7 +342,7 @@ long ares__tvdiff(struct timeval t1, struct timeval t2); do { \ if ((c)->sock_state_cb) \ (c)->sock_state_cb((c)->sock_state_cb_data, (s), (r), (w)); \ - } while (0) + } WHILE_FALSE #ifdef CURLDEBUG /* This is low-level hard-hacking memory leak tracking and similar. Using the diff --git a/deps/uv/src/ares/ares_process.c b/deps/uv/src/ares/ares_process.c index e5efa5fb30..79a999fdf9 100644 --- a/deps/uv/src/ares/ares_process.c +++ b/deps/uv/src/ares/ares_process.c @@ -1,6 +1,6 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. - * Copyright (C) 2004-2010 by Daniel Stenberg + * Copyright (C) 2004-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -837,30 +837,29 @@ static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ #elif defined(HAVE_IOCTL_FIONBIO) /* older unix versions */ - int flags; - flags = nonblock; + int flags = nonblock ? 1 : 0; return ioctl(sockfd, FIONBIO, &flags); #elif defined(HAVE_IOCTLSOCKET_FIONBIO) #ifdef WATT32 - char flags; + char flags = nonblock ? 1 : 0; #else /* Windows */ - unsigned long flags; + unsigned long flags = nonblock ? 1UL : 0UL; #endif - flags = nonblock; return ioctlsocket(sockfd, FIONBIO, &flags); #elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO) /* Amiga */ - return IoctlSocket(sockfd, FIONBIO, (long)nonblock); + long flags = nonblock ? 1L : 0L; + return IoctlSocket(sockfd, FIONBIO, flags); #elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK) /* BeOS */ - long b = nonblock ? 1 : 0; + long b = nonblock ? 1L : 0L; return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); #else @@ -947,7 +946,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) salen = sizeof(saddr.sa4); memset(sa, 0, salen); saddr.sa4.sin_family = AF_INET; - saddr.sa4.sin_port = (unsigned short)(channel->tcp_port & 0xffff); + saddr.sa4.sin_port = aresx_sitous(channel->tcp_port); memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4, sizeof(server->addr.addrV4)); break; @@ -956,7 +955,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) salen = sizeof(saddr.sa6); memset(sa, 0, salen); saddr.sa6.sin6_family = AF_INET6; - saddr.sa6.sin6_port = (unsigned short)(channel->tcp_port & 0xffff); + saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port); memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6, sizeof(server->addr.addrV6)); break; @@ -1039,7 +1038,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server) salen = sizeof(saddr.sa4); memset(sa, 0, salen); saddr.sa4.sin_family = AF_INET; - saddr.sa4.sin_port = (unsigned short)(channel->udp_port & 0xffff); + saddr.sa4.sin_port = aresx_sitous(channel->udp_port); memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4, sizeof(server->addr.addrV4)); break; @@ -1048,7 +1047,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server) salen = sizeof(saddr.sa6); memset(sa, 0, salen); saddr.sa6.sin6_family = AF_INET6; - saddr.sa6.sin6_port = (unsigned short)(channel->udp_port & 0xffff); + saddr.sa6.sin6_port = aresx_sitous(channel->udp_port); memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6, sizeof(server->addr.addrV6)); break; diff --git a/deps/uv/src/ares/ares_send.c b/deps/uv/src/ares/ares_send.c index 37b0704579..75a84f687e 100644 --- a/deps/uv/src/ares/ares_send.c +++ b/deps/uv/src/ares/ares_send.c @@ -77,7 +77,7 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, } /* Compute the query ID. Start with no timeout. */ - query->qid = (unsigned short)DNS_HEADER_QID(qbuf); + query->qid = DNS_HEADER_QID(qbuf); query->timeout.tv_sec = 0; query->timeout.tv_usec = 0; diff --git a/deps/uv/src/ares/ares_setup.h b/deps/uv/src/ares/ares_setup.h index 254cccbb85..18e14557cd 100644 --- a/deps/uv/src/ares/ares_setup.h +++ b/deps/uv/src/ares/ares_setup.h @@ -2,7 +2,7 @@ #define HEADER_CARES_SETUP_H -/* Copyright (C) 2004 - 2009 by Daniel Stenberg et al +/* Copyright (C) 2004 - 2012 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 @@ -75,7 +75,9 @@ /* please, do it beyond the point further indicated in this file. */ /* ================================================================ */ -#if 0 /* libuv hack */ +#if 1 /* libuv hack */ +#include /* needed on windows */ +#else /* * c-ares external interface definitions are also used internally, * and might also include required system header files to define them. @@ -159,12 +161,32 @@ #endif /* HAVE_CONFIG_H */ +/* + * Arg 2 type for gethostname in case it hasn't been defined in config file. + */ + +#ifndef GETHOSTNAME_TYPE_ARG2 +# ifdef USE_WINSOCK +# define GETHOSTNAME_TYPE_ARG2 int +# else +# define GETHOSTNAME_TYPE_ARG2 size_t +# endif +#endif + #ifdef __POCC__ # include # include # define ESRCH 3 #endif +/* + * Android does have the arpa/nameser.h header which is detected by configure + * but it appears to be empty with recent NDK r7b / r7c, so we undefine here. + */ +#if (defined(ANDROID) || defined(__ANDROID__)) && defined(HAVE_ARPA_NAMESER_H) +# undef HAVE_ARPA_NAMESER_H +#endif + /* * Recent autoconf versions define these symbols in ares_config.h. We don't * want them (since they collide with the libcurl ones when we build diff --git a/deps/uv/src/ares/ares_timeout.c b/deps/uv/src/ares/ares_timeout.c index 2da4f5f4a1..738ad15284 100644 --- a/deps/uv/src/ares/ares_timeout.c +++ b/deps/uv/src/ares/ares_timeout.c @@ -62,19 +62,20 @@ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv, min_offset = offset; } - if(min_offset != -1) { - nextstop.tv_sec = min_offset/1000; - nextstop.tv_usec = (min_offset%1000)*1000; - } - /* If we found a minimum timeout and it's sooner than the one specified in * maxtv (if any), return it. Otherwise go with maxtv. */ - if (min_offset != -1 && (!maxtv || ares__timedout(maxtv, &nextstop))) + if (min_offset != -1) { - *tvbuf = nextstop; - return tvbuf; + nextstop.tv_sec = min_offset/1000; + nextstop.tv_usec = (min_offset%1000)*1000; + + if (!maxtv || ares__timedout(maxtv, &nextstop)) + { + *tvbuf = nextstop; + return tvbuf; + } } - else - return maxtv; + + return maxtv; } diff --git a/deps/uv/src/ares/setup_once.h b/deps/uv/src/ares/setup_once.h index a333f54a7c..fc630ef27a 100644 --- a/deps/uv/src/ares/setup_once.h +++ b/deps/uv/src/ares/setup_once.h @@ -2,7 +2,7 @@ #define __SETUP_ONCE_H -/* Copyright (C) 2004 - 2011 by Daniel Stenberg et al +/* Copyright (C) 2004 - 2012 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 @@ -72,7 +72,7 @@ #include #endif -#ifdef HAVE_STDBOOL_H +#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T) #include #endif @@ -299,6 +299,27 @@ struct timeval { #endif +/* + * Macro WHILE_FALSE may be used to build single-iteration do-while loops, + * avoiding compiler warnings. Mostly intended for other macro definitions. + */ + +#define WHILE_FALSE while(0) + +#if defined(_MSC_VER) && !defined(__POCC__) +# undef WHILE_FALSE +# if (_MSC_VER < 1500) +# define WHILE_FALSE while(1, 0) +# else +# define WHILE_FALSE \ +__pragma(warning(push)) \ +__pragma(warning(disable:4127)) \ +while(0) \ +__pragma(warning(pop)) +# endif +#endif + + /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ @@ -336,7 +357,7 @@ typedef int sig_atomic_t; #ifdef DEBUGBUILD #define DEBUGF(x) x #else -#define DEBUGF(x) do { } while (0) +#define DEBUGF(x) do { } WHILE_FALSE #endif @@ -347,7 +368,7 @@ typedef int sig_atomic_t; #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) #define DEBUGASSERT(x) assert(x) #else -#define DEBUGASSERT(x) do { } while (0) +#define DEBUGASSERT(x) do { } WHILE_FALSE #endif @@ -459,18 +480,6 @@ typedef int sig_atomic_t; #endif -/* - * System error codes for Windows CE - */ - -#if defined(WIN32) && !defined(HAVE_ERRNO_H) -#define ENOENT ERROR_FILE_NOT_FOUND -#define ESRCH ERROR_PATH_NOT_FOUND -#define ENOMEM ERROR_NOT_ENOUGH_MEMORY -#define ENOSPC ERROR_INVALID_PARAMETER -#endif - - /* * Actually use __32_getpwuid() on 64-bit VMS builds for getpwuid() */ @@ -501,4 +510,3 @@ typedef int sig_atomic_t; #endif /* __SETUP_ONCE_H */ - diff --git a/deps/uv/src/unix/async.c b/deps/uv/src/unix/async.c index f782e158ae..192a36182e 100644 --- a/deps/uv/src/unix/async.c +++ b/deps/uv/src/unix/async.c @@ -30,6 +30,36 @@ static int uv__async_init(uv_loop_t* loop); static void uv__async_io(uv_loop_t* loop, uv__io_t* handle, int events); +__attribute__((always_inline)) +inline static int uv__async_make_pending(volatile sig_atomic_t* ptr) { + /* Do a cheap read first. */ + if (*ptr) + return 1; + + /* Micro-optimization: use atomic memory operations to detect if we've been + * preempted by another thread and don't have to make an expensive syscall. + * This speeds up the heavily contended case by about 1-2% and has little + * if any impact on the non-contended case. + * + * Use XCHG instead of the CMPXCHG that __sync_val_compare_and_swap() emits + * on x86, it's about 4x faster. It probably makes zero difference in the + * grand scheme of things but I'm OCD enough not to let this one pass. + */ +#if __i386__ || __x86_64__ + { + unsigned int val = 1; + __asm__ __volatile__("xchgl %0, %1" : "+r" (val) : "m" (*ptr)); + return val != 0; + } +#elif __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1 /* gcc >= 4.1 */ + return __sync_val_compare_and_swap(ptr, 0, 1) != 0; +#else + *ptr = 1; + return 1; +#endif +} + + int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { if (uv__async_init(loop)) return uv__set_sys_error(loop, errno); @@ -50,7 +80,8 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { int uv_async_send(uv_async_t* handle) { int r; - handle->pending = 1; /* XXX needs a memory barrier? */ + if (uv__async_make_pending(&handle->pending)) + return 0; /* already pending */ do r = write(handle->loop->async_pipefd[1], "x", 1); diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 9f20d04b29..2f8815966d 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -228,7 +228,7 @@ void uv_loop_delete(uv_loop_t* loop) { static unsigned int uv__poll_timeout(uv_loop_t* loop) { - if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop)) + if (!uv__has_active_handles(loop)) return 0; if (!ngx_queue_empty(&loop->idle_handles)) @@ -298,9 +298,15 @@ static int uv_getaddrinfo_done(eio_req* req_) { uv__req_unregister(req->loop, req); - free(req->hints); - free(req->service); - free(req->hostname); + /* see initialization in uv_getaddrinfo() */ + if (req->hints) + free(req->hints); + else if (req->service) + free(req->service); + else if (req->hostname) + free(req->hostname); + else + assert(0); if (req->retcode == 0) { /* OK */ @@ -325,62 +331,81 @@ static int uv_getaddrinfo_done(eio_req* req_) { } -static void getaddrinfo_thread_proc(eio_req *req) { - uv_getaddrinfo_t* handle = req->data; +static void getaddrinfo_thread_proc(eio_req *req_) { + uv_getaddrinfo_t* req = req_->data; - handle->retcode = getaddrinfo(handle->hostname, - handle->service, - handle->hints, - &handle->res); + req->retcode = getaddrinfo(req->hostname, + req->service, + req->hints, + &req->res); } -/* stub implementation of uv_getaddrinfo */ int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* handle, + uv_getaddrinfo_t* req, uv_getaddrinfo_cb cb, const char* hostname, const char* service, const struct addrinfo* hints) { - eio_req* req; + size_t hostname_len; + size_t service_len; + size_t hints_len; + eio_req* req_; + size_t len; + char* buf; + + if (req == NULL || cb == NULL || (hostname == NULL && service == NULL)) + return uv__set_artificial_error(loop, UV_EINVAL); + uv_eio_init(loop); - if (handle == NULL || cb == NULL || - (hostname == NULL && service == NULL)) { - uv__set_artificial_error(loop, UV_EINVAL); - return -1; - } + hostname_len = hostname ? strlen(hostname) + 1 : 0; + service_len = service ? strlen(service) + 1 : 0; + hints_len = hints ? sizeof(*hints) : 0; + buf = malloc(hostname_len + service_len + hints_len); - uv__req_init(loop, handle, UV_GETADDRINFO); - handle->loop = loop; - handle->cb = cb; + if (buf == NULL) + return uv__set_artificial_error(loop, UV_ENOMEM); - /* TODO don't alloc so much. */ + uv__req_init(loop, req, UV_GETADDRINFO); + req->loop = loop; + req->cb = cb; + req->res = NULL; + req->hints = NULL; + req->service = NULL; + req->hostname = NULL; + req->retcode = 0; + + /* order matters, see uv_getaddrinfo_done() */ + len = 0; if (hints) { - handle->hints = malloc(sizeof(struct addrinfo)); - memcpy(handle->hints, hints, sizeof(struct addrinfo)); + req->hints = memcpy(buf + len, hints, sizeof(*hints)); + len += sizeof(*hints); } - else { - handle->hints = NULL; + + if (service) { + req->service = memcpy(buf + len, service, service_len); + len += service_len; } - /* TODO security! check lengths, check return values. */ + if (hostname) { + req->hostname = memcpy(buf + len, hostname, hostname_len); + len += hostname_len; + } - handle->hostname = hostname ? strdup(hostname) : NULL; - handle->service = service ? strdup(service) : NULL; - handle->res = NULL; - handle->retcode = 0; + req_ = eio_custom(getaddrinfo_thread_proc, + EIO_PRI_DEFAULT, + uv_getaddrinfo_done, + req, + &loop->uv_eio_channel); - /* TODO check handle->hostname == NULL */ - /* TODO check handle->service == NULL */ + if (req_) + return 0; - req = eio_custom(getaddrinfo_thread_proc, EIO_PRI_DEFAULT, - uv_getaddrinfo_done, handle, &loop->uv_eio_channel); - assert(req); - assert(req->data == handle); + free(buf); - return 0; + return uv__set_artificial_error(loop, UV_ENOMEM); } @@ -470,17 +495,34 @@ skip: } +#if __linux__ + int uv__nonblock(int fd, int set) { int r; -#if FIONBIO do r = ioctl(fd, FIONBIO, &set); while (r == -1 && errno == EINTR); return r; -#else +} + + +int uv__cloexec(int fd, int set) { + int r; + + do + r = ioctl(fd, set ? FIOCLEX : FIONCLEX); + while (r == -1 && errno == EINTR); + + return r; +} + +#else /* !__linux__ */ + +int uv__nonblock(int fd, int set) { int flags; + int r; do r = fcntl(fd, F_GETFL); @@ -499,7 +541,6 @@ int uv__nonblock(int fd, int set) { while (r == -1 && errno == EINTR); return r; -#endif } @@ -507,15 +548,6 @@ int uv__cloexec(int fd, int set) { int flags; int r; -#if __linux__ - /* Linux knows only FD_CLOEXEC so we can safely omit the fcntl(F_GETFD) - * syscall. CHECKME: That's probably true for other Unices as well. - */ - if (set) - flags = FD_CLOEXEC; - else - flags = 0; -#else do r = fcntl(fd, F_GETFD); while (r == -1 && errno == EINTR); @@ -527,7 +559,6 @@ int uv__cloexec(int fd, int set) { flags = r | FD_CLOEXEC; else flags = r & ~FD_CLOEXEC; -#endif do r = fcntl(fd, F_SETFD, flags); @@ -536,6 +567,8 @@ int uv__cloexec(int fd, int set) { return r; } +#endif /* __linux__ */ + /* This function is not execve-safe, there is a race window * between the call to dup() and fcntl(FD_CLOEXEC). diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c index e6deb3017b..cb45db0303 100644 --- a/deps/uv/src/unix/darwin.c +++ b/deps/uv/src/unix/darwin.c @@ -211,7 +211,8 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { uv_cpu_info_t* cpu_info; size = sizeof(model); - if (sysctlbyname("hw.model", &model, &size, NULL, 0) < 0) { + if (sysctlbyname("machdep.cpu.brand_string", &model, &size, NULL, 0) < 0 && + sysctlbyname("hw.model", &model, &size, NULL, 0) < 0) { return uv__new_sys_error(errno); } size = sizeof(cpuspeed); diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index be8006c5a8..d916b0b126 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -139,23 +139,9 @@ char** uv_setup_args(int argc, char** argv) { uv_err_t uv_set_process_title(const char* title) { - int oid[4]; - if (process_title) free(process_title); process_title = strdup(title); - - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - - sysctl(oid, - ARRAY_SIZE(oid), - NULL, - NULL, - process_title, - strlen(process_title) + 1); - + setproctitle(title); return uv_ok_; } @@ -275,7 +261,7 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { return uv__new_sys_error(ENOMEM); } - if (sysctlbyname("kern.cp_times", cp_times, &size, NULL, 0) < 0) { + if (sysctlbyname("kern.cp_times", &cp_times, &size, NULL, 0) < 0) { free(cp_times); free(*cpu_infos); return uv__new_sys_error(errno); diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index dd46c95ed5..23f16f7b0e 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -139,6 +139,8 @@ int uv__stream_open(uv_stream_t*, int fd, int flags); void uv__stream_destroy(uv_stream_t* stream); void uv__server_io(uv_loop_t* loop, uv__io_t* watcher, int events); int uv__accept(int sockfd); +int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr, + socklen_t addrlen, uv_connect_cb cb); /* tcp */ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb); diff --git a/deps/uv/src/unix/linux/syscalls.c b/deps/uv/src/unix/linux/syscalls.c index cbf2bbbdea..a99a6da883 100644 --- a/deps/uv/src/unix/linux/syscalls.c +++ b/deps/uv/src/unix/linux/syscalls.c @@ -69,6 +69,56 @@ # endif #endif /* __NR_eventfd2 */ +#ifndef __NR_epoll_create +# if __x86_64__ +# define __NR_epoll_create 213 +# elif __i386__ +# define __NR_epoll_create 254 +# elif __arm__ +# define __NR_epoll_create (UV_SYSCALL_BASE + 250) +# endif +#endif /* __NR_epoll_create */ + +#ifndef __NR_epoll_create1 +# if __x86_64__ +# define __NR_epoll_create1 291 +# elif __i386__ +# define __NR_epoll_create1 329 +# elif __arm__ +# define __NR_epoll_create1 (UV_SYSCALL_BASE + 357) +# endif +#endif /* __NR_epoll_create1 */ + +#ifndef __NR_epoll_ctl +# if __x86_64__ +# define __NR_epoll_ctl 233 /* used to be 214 */ +# elif __i386__ +# define __NR_epoll_ctl 255 +# elif __arm__ +# define __NR_epoll_ctl (UV_SYSCALL_BASE + 251) +# endif +#endif /* __NR_epoll_ctl */ + +#ifndef __NR_epoll_wait +# if __x86_64__ +# define __NR_epoll_wait 232 /* used to be 215 */ +# elif __i386__ +# define __NR_epoll_wait 256 +# elif __arm__ +# define __NR_epoll_wait (UV_SYSCALL_BASE + 252) +# endif +#endif /* __NR_epoll_wait */ + +#ifndef __NR_epoll_pwait +# if __x86_64__ +# define __NR_epoll_pwait 281 +# elif __i386__ +# define __NR_epoll_pwait 319 +# elif __arm__ +# define __NR_epoll_pwait (UV_SYSCALL_BASE + 346) +# endif +#endif /* __NR_epoll_pwait */ + #ifndef __NR_inotify_init # if __x86_64__ # define __NR_inotify_init 253 @@ -197,6 +247,64 @@ int uv__eventfd2(unsigned int count, int flags) { } +int uv__epoll_create(void) { +#if __NR_epoll_create + return syscall(__NR_epoll_create); +#else + return errno = ENOSYS, -1; +#endif +} + + +int uv__epoll_create1(int flags) { +#if __NR_epoll_create1 + return syscall(__NR_epoll_create1, flags); +#else + return errno = ENOSYS, -1; +#endif +} + + +int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) { +#if __NR_epoll_ctl + return syscall(__NR_epoll_ctl, epfd, op, fd, events); +#else + return errno = ENOSYS, -1; +#endif +} + + +int uv__epoll_wait(int epfd, + struct uv__epoll_event* events, + int nevents, + int timeout) { +#if __NR_epoll_wait + return syscall(__NR_epoll_wait, epfd, events, nevents, timeout); +#else + return errno = ENOSYS, -1; +#endif +} + + +int uv__epoll_pwait(int epfd, + struct uv__epoll_event* events, + int nevents, + int timeout, + const sigset_t* sigmask) { +#if __NR_epoll_pwait + return syscall(__NR_epoll_pwait, + epfd, + events, + nevents, + timeout, + sigmask, + sizeof(*sigmask)); +#else + return errno = ENOSYS, -1; +#endif +} + + int uv__inotify_init(void) { #if __NR_inotify_init return syscall(__NR_inotify_init); diff --git a/deps/uv/src/unix/linux/syscalls.h b/deps/uv/src/unix/linux/syscalls.h index ec70fd962f..527d8c5724 100644 --- a/deps/uv/src/unix/linux/syscalls.h +++ b/deps/uv/src/unix/linux/syscalls.h @@ -25,6 +25,7 @@ #undef _GNU_SOURCE #define _GNU_SOURCE +#include #include #include #include @@ -41,6 +42,19 @@ #define UV__SOCK_CLOEXEC UV__O_CLOEXEC #define UV__SOCK_NONBLOCK UV__O_NONBLOCK +/* epoll flags */ +#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC +#define UV__EPOLL_CTL_ADD 1 +#define UV__EPOLL_CTL_DEL 2 +#define UV__EPOLL_CTL_MOD 3 + +#define UV__EPOLLIN 1 +#define UV__EPOLLOUT 4 +#define UV__EPOLLERR 8 +#define UV__EPOLLHUP 16 +#define UV__EPOLLONESHOT 0x40000000 +#define UV__EPOLLET 0x80000000 + /* inotify flags */ #define UV__IN_ACCESS 0x001 #define UV__IN_MODIFY 0x002 @@ -55,6 +69,11 @@ #define UV__IN_DELETE_SELF 0x400 #define UV__IN_MOVE_SELF 0x800 +struct uv__epoll_event { + __u32 events; + __u64 data; +} __attribute__((packed)); + struct uv__inotify_event { __s32 wd; __u32 mask; @@ -70,6 +89,18 @@ struct uv__mmsghdr { int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags); int uv__eventfd(unsigned int count); +int uv__epoll_create(void); +int uv__epoll_create1(int flags); +int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev); +int uv__epoll_wait(int epfd, + struct uv__epoll_event* events, + int nevents, + int timeout); +int uv__epoll_pwait(int epfd, + struct uv__epoll_event* events, + int nevents, + int timeout, + const sigset_t* sigmask); int uv__eventfd2(unsigned int count, int flags); int uv__inotify_init(void); int uv__inotify_init1(int flags); diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c index 957e96f8a6..317ac67c10 100644 --- a/deps/uv/src/unix/pipe.c +++ b/deps/uv/src/unix/pipe.c @@ -170,17 +170,18 @@ void uv_pipe_connect(uv_connect_t* req, uv_connect_cb cb) { struct sockaddr_un saddr; int saved_errno; - int new_sock; - int err; + int sockfd; + int status; int r; saved_errno = errno; - new_sock = (handle->fd == -1); - err = -1; + sockfd = -1; + status = -1; - if (new_sock) - if ((handle->fd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) - goto out; + if ((sockfd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { + uv__set_sys_error(handle->loop, errno); + goto out; + } memset(&saddr, 0, sizeof saddr); uv_strlcpy(saddr.sun_path, name, sizeof(saddr.sun_path)); @@ -190,25 +191,25 @@ void uv_pipe_connect(uv_connect_t* req, * is either there or not. */ do { - r = connect(handle->fd, (struct sockaddr*)&saddr, sizeof saddr); + r = connect(sockfd, (struct sockaddr*)&saddr, sizeof saddr); } while (r == -1 && errno == EINTR); - if (r == -1) + if (r == -1) { + status = errno; + close(sockfd); goto out; + } - if (new_sock) - if (uv__stream_open((uv_stream_t*)handle, - handle->fd, - UV_STREAM_READABLE | UV_STREAM_WRITABLE)) - goto out; - + uv__stream_open((uv_stream_t*)handle, + sockfd, + UV_STREAM_READABLE | UV_STREAM_WRITABLE); uv__io_start(handle->loop, &handle->read_watcher); uv__io_start(handle->loop, &handle->write_watcher); - err = 0; + status = 0; out: - handle->delayed_error = err ? errno : 0; /* Passed to callback. */ + handle->delayed_error = status; /* Passed to callback. */ handle->connect_req = req; uv__req_init(handle->loop, req, UV_CONNECT); diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 284643e4a3..8c33ee09c5 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -784,6 +784,9 @@ static void uv__stream_connect(uv_stream_t* stream) { if (error == EINPROGRESS) return; + if (error == 0) + uv__io_start(stream->loop, &stream->read_watcher); + stream->connect_req = NULL; uv__req_unregister(stream->loop, req); @@ -794,6 +797,65 @@ static void uv__stream_connect(uv_stream_t* stream) { } +int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr, + socklen_t addrlen, uv_connect_cb cb) { + int sockfd; + int r; + + if (stream->type != UV_TCP) + return uv__set_sys_error(stream->loop, ENOTSOCK); + + if (stream->connect_req) + return uv__set_sys_error(stream->loop, EALREADY); + + if (stream->fd <= 0) { + sockfd = uv__socket(addr->sa_family, SOCK_STREAM, 0); + + if (sockfd == -1) + return uv__set_sys_error(stream->loop, errno); + + if (uv__stream_open(stream, + sockfd, + UV_STREAM_READABLE | UV_STREAM_WRITABLE)) { + close(sockfd); + return -1; + } + } + + stream->delayed_error = 0; + + do + r = connect(stream->fd, addr, addrlen); + while (r == -1 && errno == EINTR); + + if (r == -1) { + if (errno == EINPROGRESS) + ; /* not an error */ + else if (errno == ECONNREFUSED) + /* If we get a ECONNREFUSED wait until the next tick to report the + * error. Solaris wants to report immediately--other unixes want to + * wait. + */ + stream->delayed_error = errno; + else + return uv__set_sys_error(stream->loop, errno); + } + + uv__req_init(stream->loop, req, UV_CONNECT); + req->cb = cb; + req->handle = stream; + ngx_queue_init(&req->queue); + stream->connect_req = req; + + uv__io_start(stream->loop, &stream->write_watcher); + + if (stream->delayed_error) + uv__io_feed(stream->loop, &stream->write_watcher, UV__IO_WRITE); + + return 0; +} + + int uv_write2(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt, uv_stream_t* send_handle, uv_write_cb cb) { int empty_queue; diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index b95a89b456..a33ec9d98b 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -75,7 +75,6 @@ uint64_t uv_hrtime() { */ int uv_exepath(char* buffer, size_t* size) { ssize_t res; - pid_t pid; char buf[128]; if (buffer == NULL) @@ -84,8 +83,7 @@ int uv_exepath(char* buffer, size_t* size) { if (size == NULL) return (-1); - pid = getpid(); - (void) snprintf(buf, sizeof (buf), "/proc/%d/path/a.out", pid); + (void) snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid()); res = readlink(buf, buffer, *size - 1); if (res < 0) @@ -128,26 +126,27 @@ static void uv__fs_event_rearm(uv_fs_event_t *handle) { } -static void uv__fs_event_read(EV_P_ ev_io* w, int revents) { +static void uv__fs_event_read(uv_loop_t* loop, uv__io_t* w, int revents) { uv_fs_event_t *handle; - uv_loop_t *loop_; timespec_t timeout; port_event_t pe; int events; int r; - loop_ = container_of(w, uv_loop_t, fs_event_watcher); + (void) w; + (void) revents; do { /* TODO use port_getn() */ do { memset(&timeout, 0, sizeof timeout); - r = port_get(loop_->fs_fd, &pe, &timeout); + r = port_get(loop->fs_fd, &pe, &timeout); } while (r == -1 && errno == EINTR); if (r == -1 && errno == ETIME) break; + handle = (uv_fs_event_t *)pe.portev_user; assert((r == 0) && "unexpected port_get() error"); @@ -199,8 +198,8 @@ int uv_fs_event_init(uv_loop_t* loop, uv__fs_event_rearm(handle); if (first_run) { - ev_io_init(&loop->fs_event_watcher, uv__fs_event_read, portfd, EV_READ); - ev_io_start(loop->ev, &loop->fs_event_watcher); + uv__io_init(&loop->fs_event_watcher, uv__fs_event_read, portfd, UV__IO_READ); + uv__io_start(loop, &loop->fs_event_watcher); } return 0; @@ -433,7 +432,8 @@ uv_err_t uv_interface_addresses(uv_interface_address_t** addresses, address = *addresses; for (ent = addrs; ent != NULL; ent = ent->ifa_next) { - bzero(&ip, sizeof (ip)); + memset(&ip, 0, sizeof(ip)); + if (!(ent->ifa_flags & IFF_UP && ent->ifa_flags & IFF_RUNNING)) { continue; } diff --git a/deps/uv/src/unix/tcp.c b/deps/uv/src/unix/tcp.c index 233be82514..07ad2d9eca 100644 --- a/deps/uv/src/unix/tcp.c +++ b/deps/uv/src/unix/tcp.c @@ -34,26 +34,6 @@ int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* tcp) { } -static int maybe_new_socket(uv_tcp_t* handle, int domain, int flags) { - int sockfd; - - if (handle->fd != -1) - return 0; - - sockfd = uv__socket(domain, SOCK_STREAM, 0); - - if (sockfd == -1) - return uv__set_sys_error(handle->loop, errno); - - if (uv__stream_open((uv_stream_t*)handle, sockfd, flags)) { - close(sockfd); - return -1; - } - - return 0; -} - - static int uv__bind(uv_tcp_t* tcp, int domain, struct sockaddr* addr, @@ -64,8 +44,23 @@ static int uv__bind(uv_tcp_t* tcp, saved_errno = errno; status = -1; - if (maybe_new_socket(tcp, domain, UV_STREAM_READABLE|UV_STREAM_WRITABLE)) - return -1; + if (tcp->fd < 0) { + if ((tcp->fd = uv__socket(domain, SOCK_STREAM, 0)) == -1) { + uv__set_sys_error(tcp->loop, errno); + goto out; + } + + if (uv__stream_open((uv_stream_t*)tcp, + tcp->fd, + UV_STREAM_READABLE | UV_STREAM_WRITABLE)) { + close(tcp->fd); + tcp->fd = -1; + status = -2; + goto out; + } + } + + assert(tcp->fd >= 0); tcp->delayed_error = 0; if (bind(tcp->fd, addr, addrsize) == -1) { @@ -84,58 +79,6 @@ out: } -static int uv__connect(uv_connect_t* req, - uv_tcp_t* handle, - struct sockaddr* addr, - socklen_t addrlen, - uv_connect_cb cb) { - int r; - - assert(handle->type == UV_TCP); - - if (handle->connect_req) - return uv__set_sys_error(handle->loop, EALREADY); - - if (maybe_new_socket(handle, - addr->sa_family, - UV_STREAM_READABLE|UV_STREAM_WRITABLE)) { - return -1; - } - - handle->delayed_error = 0; - - do - r = connect(handle->fd, addr, addrlen); - while (r == -1 && errno == EINTR); - - if (r == -1) { - if (errno == EINPROGRESS) - ; /* not an error */ - else if (errno == ECONNREFUSED) - /* If we get a ECONNREFUSED wait until the next tick to report the - * error. Solaris wants to report immediately--other unixes want to - * wait. - */ - handle->delayed_error = errno; - else - return uv__set_sys_error(handle->loop, errno); - } - - uv__req_init(handle->loop, req, UV_CONNECT); - req->cb = cb; - req->handle = (uv_stream_t*) handle; - ngx_queue_init(&req->queue); - handle->connect_req = req; - - uv__io_start(handle->loop, &handle->write_watcher); - - if (handle->delayed_error) - uv__io_feed(handle->loop, &handle->write_watcher, UV__IO_WRITE); - - return 0; -} - - int uv__tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) { return uv__bind(handle, AF_INET, @@ -227,14 +170,33 @@ out: int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { - if (tcp->delayed_error) - return uv__set_sys_error(tcp->loop, tcp->delayed_error); + int r; - if (maybe_new_socket(tcp, AF_INET, UV_STREAM_READABLE)) + if (tcp->delayed_error) { + uv__set_sys_error(tcp->loop, tcp->delayed_error); return -1; + } - if (listen(tcp->fd, backlog)) - return uv__set_sys_error(tcp->loop, errno); + if (tcp->fd < 0) { + if ((tcp->fd = uv__socket(AF_INET, SOCK_STREAM, 0)) == -1) { + uv__set_sys_error(tcp->loop, errno); + return -1; + } + + if (uv__stream_open((uv_stream_t*)tcp, tcp->fd, UV_STREAM_READABLE)) { + close(tcp->fd); + tcp->fd = -1; + return -1; + } + } + + assert(tcp->fd >= 0); + + r = listen(tcp->fd, backlog); + if (r < 0) { + uv__set_sys_error(tcp->loop, errno); + return -1; + } tcp->connection_cb = cb; @@ -247,31 +209,37 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { int uv__tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - struct sockaddr_in addr, - uv_connect_cb cb) { - int saved_errno; + uv_tcp_t* handle, + struct sockaddr_in address, + uv_connect_cb cb) { + int saved_errno = errno; int status; - saved_errno = errno; - status = uv__connect(req, handle, (struct sockaddr*)&addr, sizeof addr, cb); - errno = saved_errno; + status = uv__connect(req, + (uv_stream_t*)handle, + (struct sockaddr*)&address, + sizeof address, + cb); + errno = saved_errno; return status; } int uv__tcp_connect6(uv_connect_t* req, - uv_tcp_t* handle, - struct sockaddr_in6 addr, - uv_connect_cb cb) { - int saved_errno; + uv_tcp_t* handle, + struct sockaddr_in6 address, + uv_connect_cb cb) { + int saved_errno = errno; int status; - saved_errno = errno; - status = uv__connect(req, handle, (struct sockaddr*)&addr, sizeof addr, cb); - errno = saved_errno; + status = uv__connect(req, + (uv_stream_t*)handle, + (struct sockaddr*)&address, + sizeof address, + cb); + errno = saved_errno; return status; } diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index a267d337d7..cd4e3333b5 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -167,44 +167,6 @@ void uv_once(uv_once_t* guard, void (*callback)(void)) { abort(); } -#if defined(__APPLE__) && defined(__MACH__) - -int uv_sem_init(uv_sem_t* sem, unsigned int value) { - return semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value); -} - - -void uv_sem_destroy(uv_sem_t* sem) { - if (semaphore_destroy(mach_task_self(), *sem)) - abort(); -} - - -void uv_sem_post(uv_sem_t* sem) { - if (semaphore_signal(*sem)) - abort(); -} - - -void uv_sem_wait(uv_sem_t* sem) { - if (semaphore_wait(*sem)) - abort(); -} - - -int uv_sem_trywait(uv_sem_t* sem) { - mach_timespec_t interval; - - interval.tv_sec = 0; - interval.tv_nsec = 0; - - if (semaphore_timedwait(*sem, interval) == KERN_SUCCESS) - return 0; - else - return -1; -} - -#else /* !(defined(__APPLE__) && defined(__MACH__)) */ int uv_sem_init(uv_sem_t* sem, unsigned int value) { return sem_init(sem, 0, value); @@ -247,5 +209,3 @@ int uv_sem_trywait(uv_sem_t* sem) { return r; } - -#endif /* defined(__APPLE__) && defined(__MACH__) */ diff --git a/deps/uv/test/benchmark-ares.c b/deps/uv/test/benchmark-ares.c index 27084fae20..37ee71b42e 100644 --- a/deps/uv/test/benchmark-ares.c +++ b/deps/uv/test/benchmark-ares.c @@ -64,7 +64,7 @@ static void prep_tcploopback() optmask = ARES_OPT_SERVERS | ARES_OPT_TCP_PORT | ARES_OPT_FLAGS; options.servers = &test_server.sin_addr; options.nservers = 1; - options.tcp_port = htons(TEST_PORT_2); + options.tcp_port = TEST_PORT_2; options.flags = ARES_FLAG_USEVC; rc = uv_ares_init_options(loop, &channel, &options, optmask); diff --git a/deps/uv/test/benchmark-async-pummel.c b/deps/uv/test/benchmark-async-pummel.c new file mode 100644 index 0000000000..f6ce45efc5 --- /dev/null +++ b/deps/uv/test/benchmark-async-pummel.c @@ -0,0 +1,97 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "task.h" +#include "uv.h" + +#include +#include + +#define NUM_PINGS (1000 * 1000) + +static unsigned int callbacks; +static volatile int done; + + +static void async_cb(uv_async_t* handle, int status) { + if (++callbacks == NUM_PINGS) + uv_close((uv_handle_t*) handle, NULL); +} + + +static void pummel(void* arg) { + while (!done) + uv_async_send((uv_async_t*) arg); +} + + +static int test_async_pummel(int nthreads) { + uv_thread_t* tids; + uv_async_t handle; + uint64_t time; + int i; + + tids = calloc(nthreads, sizeof(tids[0])); + ASSERT(tids != NULL); + + ASSERT(0 == uv_async_init(uv_default_loop(), &handle, async_cb)); + + for (i = 0; i < nthreads; i++) + ASSERT(0 == uv_thread_create(tids + i, pummel, &handle)); + + time = uv_hrtime(); + + ASSERT(0 == uv_run(uv_default_loop())); + + time = uv_hrtime() - time; + done = 1; + + for (i = 0; i < nthreads; i++) + ASSERT(0 == uv_thread_join(tids + i)); + + printf("%s callbacks in %.2f seconds (%s/sec)\n", + fmt(callbacks), + time / 1e9, + fmt(callbacks / (time / 1e9))); + + free(tids); + return 0; +} + + +BENCHMARK_IMPL(async_pummel_1) { + return test_async_pummel(1); +} + + +BENCHMARK_IMPL(async_pummel_2) { + return test_async_pummel(2); +} + + +BENCHMARK_IMPL(async_pummel_4) { + return test_async_pummel(4); +} + + +BENCHMARK_IMPL(async_pummel_8) { + return test_async_pummel(8); +} diff --git a/deps/uv/test/benchmark-async.c b/deps/uv/test/benchmark-async.c new file mode 100644 index 0000000000..2bf3040875 --- /dev/null +++ b/deps/uv/test/benchmark-async.c @@ -0,0 +1,137 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "task.h" +#include "uv.h" + +#include +#include + +#define NUM_PINGS (1000 * 1000) + +struct ctx { + uv_loop_t* loop; + uv_thread_t thread; + uv_async_t main_async; /* wake up main thread */ + uv_async_t worker_async; /* wake up worker */ + unsigned int nthreads; + unsigned int main_sent; + unsigned int main_seen; + unsigned int worker_sent; + unsigned int worker_seen; +}; + + +static void worker_async_cb(uv_async_t* handle, int status) { + struct ctx* ctx = container_of(handle, struct ctx, worker_async); + + ASSERT(0 == uv_async_send(&ctx->main_async)); + ctx->worker_sent++; + ctx->worker_seen++; + + if (ctx->worker_sent >= NUM_PINGS) + uv_close((uv_handle_t*) &ctx->worker_async, NULL); +} + + +static void main_async_cb(uv_async_t* handle, int status) { + struct ctx* ctx = container_of(handle, struct ctx, main_async); + + ASSERT(0 == uv_async_send(&ctx->worker_async)); + ctx->main_sent++; + ctx->main_seen++; + + if (ctx->main_sent >= NUM_PINGS) + uv_close((uv_handle_t*) &ctx->main_async, NULL); +} + + +static void worker(void* arg) { + struct ctx* ctx = arg; + ASSERT(0 == uv_async_send(&ctx->main_async)); + ASSERT(0 == uv_run(ctx->loop)); +} + + +static int test_async(int nthreads) { + struct ctx* threads; + struct ctx* ctx; + uint64_t time; + int i; + + threads = calloc(nthreads, sizeof(threads[0])); + ASSERT(threads != NULL); + + for (i = 0; i < nthreads; i++) { + ctx = threads + i; + ctx->nthreads = nthreads; + ctx->loop = uv_loop_new(); + ASSERT(ctx->loop != NULL); + ASSERT(0 == uv_async_init(ctx->loop, &ctx->worker_async, worker_async_cb)); + ASSERT(0 == uv_async_init(uv_default_loop(), &ctx->main_async, main_async_cb)); + ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx)); + } + + time = uv_hrtime(); + + ASSERT(0 == uv_run(uv_default_loop())); + + for (i = 0; i < nthreads; i++) + ASSERT(0 == uv_thread_join(&threads[i].thread)); + + time = uv_hrtime() - time; + + for (i = 0; i < nthreads; i++) { + ctx = threads + i; + ASSERT(ctx->worker_sent == NUM_PINGS); + ASSERT(ctx->worker_seen == NUM_PINGS); + ASSERT(ctx->main_sent == (unsigned int) NUM_PINGS); + ASSERT(ctx->main_seen == (unsigned int) NUM_PINGS); + } + + printf("%.2f sec (%s/sec)\n", + time / 1e9, + fmt(NUM_PINGS / (time / 1e9))); + + free(threads); + + return 0; +} + + +BENCHMARK_IMPL(async1) { + return test_async(1); +} + + +BENCHMARK_IMPL(async2) { + return test_async(2); +} + + +BENCHMARK_IMPL(async4) { + return test_async(4); +} + + +BENCHMARK_IMPL(async8) { + return test_async(8); +} diff --git a/deps/uv/test/benchmark-fs-stat.c b/deps/uv/test/benchmark-fs-stat.c index 53aa60b14e..e6b8a637b1 100644 --- a/deps/uv/test/benchmark-fs-stat.c +++ b/deps/uv/test/benchmark-fs-stat.c @@ -43,35 +43,6 @@ struct async_req { }; -static const char* fmt(double d) { - uint64_t v; - char* p; - - p = (char *) calloc(1, 32) + 31; /* leaks memory */ - v = d; - -#if 0 /* works but we don't care about fractional precision */ - if (d - v >= 0.01) { - *--p = '0' + (uint64_t) (d * 100) % 10; - *--p = '0' + (uint64_t) (d * 10) % 10; - *--p = '.'; - } -#endif - - if (v == 0) - *--p = '0'; - - while (v) { - if (v) *--p = '0' + (v % 10), v /= 10; - if (v) *--p = '0' + (v % 10), v /= 10; - if (v) *--p = '0' + (v % 10), v /= 10; - if (v) *--p = ','; - } - - return p; -} - - static void warmup(const char* path) { uv_fs_t reqs[MAX_CONCURRENT_REQS]; int i; diff --git a/deps/uv/test/benchmark-list.h b/deps/uv/test/benchmark-list.h index 2e24682f6d..ac22434477 100644 --- a/deps/uv/test/benchmark-list.h +++ b/deps/uv/test/benchmark-list.h @@ -45,6 +45,14 @@ BENCHMARK_DECLARE (udp_packet_storm_1000v1000) BENCHMARK_DECLARE (gethostbyname) BENCHMARK_DECLARE (getaddrinfo) BENCHMARK_DECLARE (fs_stat) +BENCHMARK_DECLARE (async1) +BENCHMARK_DECLARE (async2) +BENCHMARK_DECLARE (async4) +BENCHMARK_DECLARE (async8) +BENCHMARK_DECLARE (async_pummel_1) +BENCHMARK_DECLARE (async_pummel_2) +BENCHMARK_DECLARE (async_pummel_4) +BENCHMARK_DECLARE (async_pummel_8) BENCHMARK_DECLARE (spawn) BENCHMARK_DECLARE (thread_create) BENCHMARK_DECLARE (million_timers) @@ -108,6 +116,15 @@ TASK_LIST_START BENCHMARK_ENTRY (fs_stat) + BENCHMARK_ENTRY (async1) + BENCHMARK_ENTRY (async2) + BENCHMARK_ENTRY (async4) + BENCHMARK_ENTRY (async8) + BENCHMARK_ENTRY (async_pummel_1) + BENCHMARK_ENTRY (async_pummel_2) + BENCHMARK_ENTRY (async_pummel_4) + BENCHMARK_ENTRY (async_pummel_8) + BENCHMARK_ENTRY (spawn) BENCHMARK_ENTRY (thread_create) BENCHMARK_ENTRY (million_timers) diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index d0ebfbf073..668dc95e6f 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -40,6 +40,11 @@ /* Do platform-specific initialization. */ void platform_init(int argc, char **argv) { + /* Running the tests as root is not smart - don't do it. */ + if (getuid() == 0) { + fprintf(stderr, "Running the tests as root is not safe.\n"); + exit(1); + } /* Disable stdio output buffering. */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index 214c9a0dd0..5f878a4936 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -37,6 +37,35 @@ static void log_progress(int total, int passed, int failed, const char* name) { } +const char* fmt(double d) { + uint64_t v; + char* p; + + p = (char *) calloc(1, 32) + 31; /* leaks memory */ + v = d; + +#if 0 /* works but we don't care about fractional precision */ + if (d - v >= 0.01) { + *--p = '0' + (uint64_t) (d * 100) % 10; + *--p = '0' + (uint64_t) (d * 10) % 10; + *--p = '.'; + } +#endif + + if (v == 0) + *--p = '0'; + + while (v) { + if (v) *--p = '0' + (v % 10), v /= 10; + if (v) *--p = '0' + (v % 10), v /= 10; + if (v) *--p = '0' + (v % 10), v /= 10; + if (v) *--p = ','; + } + + return p; +} + + int run_tests(int timeout, int benchmark_output) { int total, passed, failed; task_entry_t* task; diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index 04497342f7..34d28a1e79 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -106,4 +106,7 @@ typedef enum { /* Pause the calling thread for a number of milliseconds. */ void uv_sleep(int msec); +/* Format big numbers nicely. WARNING: leaks memory. */ +const char* fmt(double d); + #endif /* TASK_H_ */ diff --git a/deps/uv/test/test-hrtime.c b/deps/uv/test/test-hrtime.c index 72a4d4b181..2a9156ecf9 100644 --- a/deps/uv/test/test-hrtime.c +++ b/deps/uv/test/test-hrtime.c @@ -47,7 +47,7 @@ TEST_IMPL(hrtime) { /* Check that the difference between the two hrtime values is somewhat in */ /* the range we expect it to be. */ ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC); - ASSERT(diff < (uint64_t) 80 * NANOSEC / MILLISEC); + ASSERT(diff < (uint64_t) 60 * NANOSEC / MILLISEC); --i; } return 0; diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 7665149964..c1836fbdfd 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -56,7 +56,6 @@ TEST_DECLARE (tcp_close) TEST_DECLARE (tcp_flags) TEST_DECLARE (tcp_write_error) TEST_DECLARE (tcp_write_to_half_open_connection) -TEST_DECLARE (tcp_unexpected_read) TEST_DECLARE (tcp_bind6_error_addrinuse) TEST_DECLARE (tcp_bind6_error_addrnotavail) TEST_DECLARE (tcp_bind6_error_fault) @@ -252,7 +251,6 @@ TASK_LIST_START TEST_ENTRY (tcp_flags) TEST_ENTRY (tcp_write_error) TEST_ENTRY (tcp_write_to_half_open_connection) - TEST_ENTRY (tcp_unexpected_read) TEST_ENTRY (tcp_bind6_error_addrinuse) TEST_ENTRY (tcp_bind6_error_addrnotavail) diff --git a/deps/uv/test/test-poll-close.c b/deps/uv/test/test-poll-close.c index 4c3701bc82..8389382740 100644 --- a/deps/uv/test/test-poll-close.c +++ b/deps/uv/test/test-poll-close.c @@ -36,11 +36,6 @@ static int close_cb_called = 0; -static void poll_cb_fail(uv_poll_t* handle, int status, int events) { - ASSERT(0 && "poll_fail_cb should never be called"); -} - - static void close_cb(uv_handle_t* handle) { close_cb_called++; } diff --git a/deps/uv/test/test-process-title.c b/deps/uv/test/test-process-title.c index 13d9dddfc4..59fceda31b 100644 --- a/deps/uv/test/test-process-title.c +++ b/deps/uv/test/test-process-title.c @@ -23,27 +23,20 @@ #include "task.h" #include - -static void set_title(const char* title) { +TEST_IMPL(process_title) { char buffer[512]; uv_err_t err; err = uv_get_process_title(buffer, sizeof(buffer)); ASSERT(UV_OK == err.code); - err = uv_set_process_title(title); + err = uv_set_process_title("new title"); ASSERT(UV_OK == err.code); err = uv_get_process_title(buffer, sizeof(buffer)); ASSERT(UV_OK == err.code); - ASSERT(strcmp(buffer, title) == 0); -} + ASSERT(strcmp(buffer, "new title") == 0); - -TEST_IMPL(process_title) { - /* Check for format string vulnerabilities. */ - set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"); - set_title("new title"); return 0; } diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 51ed2e59d7..06b211bcd8 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -71,12 +71,6 @@ static void exit_cb_failure_expected(uv_process_t* process, int exit_status, } -static void exit_cb_unexpected(uv_process_t* process, int exit_status, - int term_signal) { - ASSERT(0 && "should not have been called"); -} - - static void kill_cb(uv_process_t* process, int exit_status, int term_signal) { uv_err_t err; @@ -804,6 +798,14 @@ TEST_IMPL(spawn_setgid_fails) { #ifdef _WIN32 + +static void exit_cb_unexpected(uv_process_t* process, + int exit_status, + int term_signal) { + ASSERT(0 && "should not have been called"); +} + + TEST_IMPL(spawn_setuid_fails) { int r; diff --git a/deps/uv/test/test-tcp-unexpected-read.c b/deps/uv/test/test-tcp-unexpected-read.c deleted file mode 100644 index 7adb4dae2c..0000000000 --- a/deps/uv/test/test-tcp-unexpected-read.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "uv.h" -#include "task.h" - -static uv_check_t check_handle; -static uv_timer_t timer_handle; -static uv_tcp_t server_handle; -static uv_tcp_t client_handle; -static uv_tcp_t peer_handle; -static uv_write_t write_req; -static uv_connect_t connect_req; - -static unsigned long ticks; /* event loop ticks */ - - -static void check_cb(uv_check_t* handle, int status) { - ticks++; -} - - -static void timer_cb(uv_timer_t* handle, int status) { - uv_close((uv_handle_t*) &check_handle, NULL); - uv_close((uv_handle_t*) &timer_handle, NULL); - uv_close((uv_handle_t*) &server_handle, NULL); - uv_close((uv_handle_t*) &client_handle, NULL); - uv_close((uv_handle_t*) &peer_handle, NULL); -} - - -static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size) { - ASSERT(0 && "alloc_cb should not have been called"); -} - - -static void read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) { - ASSERT(0 && "read_cb should not have been called"); -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &client_handle); - ASSERT(0 == status); -} - - -static void write_cb(uv_write_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &peer_handle); - ASSERT(0 == status); -} - - -static void connection_cb(uv_stream_t* handle, int status) { - uv_buf_t buf; - - buf = uv_buf_init("PING", 4); - - ASSERT(0 == status); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &peer_handle)); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &peer_handle, - &buf, 1, write_cb)); -} - - -TEST_IMPL(tcp_unexpected_read) { - struct sockaddr_in addr; - uv_loop_t* loop; - - addr = uv_ip4_addr("127.0.0.1", TEST_PORT); - loop = uv_default_loop(); - - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1000, 0)); - ASSERT(0 == uv_check_init(loop, &check_handle)); - ASSERT(0 == uv_check_start(&check_handle, check_cb)); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_bind(&server_handle, addr)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); - ASSERT(0 == uv_tcp_connect(&connect_req, &client_handle, addr, connect_cb)); - ASSERT(0 == uv_run(loop)); - - /* This is somewhat inexact but the idea is that the event loop should not - * start busy looping when the server sends a message and the client isn't - * reading. - */ - ASSERT(ticks <= 10); - - return 0; -} diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 96c6b724c6..c14df2cc06 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -29,6 +29,7 @@ 'include', 'include/uv-private', 'src/', + 'src/ares', ], 'direct_dependent_settings': { 'include_dirs': [ 'include' ], @@ -85,8 +86,10 @@ 'src/ares/ares_parse_aaaa_reply.c', 'src/ares/ares_parse_a_reply.c', 'src/ares/ares_parse_mx_reply.c', + 'src/ares/ares_parse_naptr_reply.c', 'src/ares/ares_parse_ns_reply.c', 'src/ares/ares_parse_ptr_reply.c', + 'src/ares/ares_parse_soa_reply.c', 'src/ares/ares_parse_srv_reply.c', 'src/ares/ares_parse_txt_reply.c', 'src/ares/ares_platform.h', @@ -355,7 +358,6 @@ 'test/test-tcp-write-error.c', 'test/test-tcp-write-to-half-open-connection.c', 'test/test-tcp-writealot.c', - 'test/test-tcp-unexpected-read.c', 'test/test-threadpool.c', 'test/test-mutexes.c', 'test/test-thread.c', @@ -405,6 +407,8 @@ 'dependencies': [ 'uv' ], 'sources': [ 'test/benchmark-ares.c', + 'test/benchmark-async.c', + 'test/benchmark-async-pummel.c', 'test/benchmark-fs-stat.c', 'test/benchmark-getaddrinfo.c', 'test/benchmark-list.h',