Browse Source

Upgrade libuv to fe18438

v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
d1e6a13179
  1. 1
      deps/uv/.mailmap
  2. 3
      deps/uv/AUTHORS
  3. 4
      deps/uv/README.md
  4. 1
      deps/uv/config-mingw.mk
  5. 13
      deps/uv/include/ares.h
  6. 4
      deps/uv/include/ares_version.h
  7. 9
      deps/uv/include/uv-private/uv-unix.h
  8. 6
      deps/uv/include/uv-private/uv-win.h
  9. 6
      deps/uv/include/uv.h
  10. 20
      deps/uv/src/ares/CHANGES
  11. 24
      deps/uv/src/ares/README.msvc
  12. 35
      deps/uv/src/ares/RELEASE-NOTES
  13. 9
      deps/uv/src/ares/ares_expand_name.c
  14. 1
      deps/uv/src/ares/ares_fds.c
  15. 3
      deps/uv/src/ares/ares_free_hostent.c
  16. 30
      deps/uv/src/ares/ares_getenv.c
  17. 26
      deps/uv/src/ares/ares_getenv.h
  18. 13
      deps/uv/src/ares/ares_gethostbyaddr.c
  19. 26
      deps/uv/src/ares/ares_gethostbyname.c
  20. 5
      deps/uv/src/ares/ares_getnameinfo.c
  21. 329
      deps/uv/src/ares/ares_init.c
  22. 221
      deps/uv/src/ares/ares_iphlpapi.h
  23. 10
      deps/uv/src/ares/ares_library_init.c
  24. 5
      deps/uv/src/ares/ares_library_init.h
  25. 130
      deps/uv/src/ares/ares_nowarn.c
  26. 33
      deps/uv/src/ares/ares_nowarn.h
  27. 13
      deps/uv/src/ares/ares_options.c
  28. 3
      deps/uv/src/ares/ares_parse_a_reply.c
  29. 3
      deps/uv/src/ares/ares_parse_aaaa_reply.c
  30. 4
      deps/uv/src/ares/ares_parse_mx_reply.c
  31. 4
      deps/uv/src/ares/ares_parse_ns_reply.c
  32. 15
      deps/uv/src/ares/ares_parse_ptr_reply.c
  33. 6
      deps/uv/src/ares/ares_parse_srv_reply.c
  34. 11035
      deps/uv/src/ares/ares_platform.c
  35. 43
      deps/uv/src/ares/ares_platform.h
  36. 8
      deps/uv/src/ares/ares_private.h
  37. 49
      deps/uv/src/ares/ares_process.c
  38. 3
      deps/uv/src/ares/ares_search.c
  39. 2
      deps/uv/src/ares/ares_send.c
  40. 16
      deps/uv/src/ares/ares_setup.h
  41. 2
      deps/uv/src/ares/config_cygwin/ares_config.h
  42. 2
      deps/uv/src/ares/config_darwin/ares_config.h
  43. 2
      deps/uv/src/ares/config_freebsd/ares_config.h
  44. 2
      deps/uv/src/ares/config_linux/ares_config.h
  45. 2
      deps/uv/src/ares/config_netbsd/ares_config.h
  46. 2
      deps/uv/src/ares/config_openbsd/ares_config.h
  47. 2
      deps/uv/src/ares/config_sunos/ares_config.h
  48. 3
      deps/uv/src/ares/config_win32/ares_config.h
  49. 41
      deps/uv/src/ares/inet_net_pton.c
  50. 12
      deps/uv/src/ares/inet_net_pton.h
  51. 182
      deps/uv/src/ares/inet_ntop.c
  52. 1
      deps/uv/src/ares/inet_ntop.h
  53. 10
      deps/uv/src/ares/nameser.h
  54. 20
      deps/uv/src/ares/setup_once.h
  55. 2
      deps/uv/src/unix/cares.c
  56. 8
      deps/uv/src/unix/core.c
  57. 2
      deps/uv/src/unix/cygwin.c
  58. 2
      deps/uv/src/unix/darwin.c
  59. 23
      deps/uv/src/unix/error.c
  60. 2
      deps/uv/src/unix/freebsd.c
  61. 42
      deps/uv/src/unix/fs.c
  62. 2
      deps/uv/src/unix/internal.h
  63. 4
      deps/uv/src/unix/linux.c
  64. 2
      deps/uv/src/unix/netbsd.c
  65. 18
      deps/uv/src/unix/pipe.c
  66. 4
      deps/uv/src/unix/process.c
  67. 38
      deps/uv/src/unix/stream.c
  68. 2
      deps/uv/src/unix/sunos.c
  69. 56
      deps/uv/src/unix/tcp.c
  70. 80
      deps/uv/src/unix/tty.c
  71. 42
      deps/uv/src/unix/udp.c
  72. 23
      deps/uv/src/uv-common.c
  73. 4
      deps/uv/src/uv-common.h
  74. 2
      deps/uv/src/win/core.c
  75. 24
      deps/uv/src/win/error.c
  76. 6
      deps/uv/src/win/fs-event.c
  77. 26
      deps/uv/src/win/fs.c
  78. 14
      deps/uv/src/win/getaddrinfo.c
  79. 9
      deps/uv/src/win/internal.h
  80. 56
      deps/uv/src/win/pipe.c
  81. 18
      deps/uv/src/win/process.c
  82. 2
      deps/uv/src/win/stdio.c
  83. 8
      deps/uv/src/win/stream.c
  84. 104
      deps/uv/src/win/tcp.c
  85. 2
      deps/uv/src/win/threadpool.c
  86. 6
      deps/uv/src/win/timer.c
  87. 36
      deps/uv/src/win/tty.c
  88. 90
      deps/uv/src/win/udp.c
  89. 4
      deps/uv/src/win/util.c
  90. 1
      deps/uv/test/benchmark-sizes.c
  91. 18
      deps/uv/test/test-fs.c
  92. 2
      deps/uv/test/test-list.h
  93. 10
      deps/uv/test/test-tty.c
  94. 16
      deps/uv/uv.gyp

1
deps/uv/.mailmap

@ -6,3 +6,4 @@
<alan@prettyrobots.com> <alan@blogometer.com>
San-Tai Hsu <vanilla@fatpipi.com>
Isaac Z. Schlueter <i@izs.me>
Saúl Ibarra Corretgé <saghul@gmail.com>

3
deps/uv/AUTHORS

@ -24,3 +24,6 @@ Matthew Sporleder <msporleder@gmail.com>
Erick Tryzelaar <erick.tryzelaar@gmail.com>
Isaac Z. Schlueter <i@izs.me>
Pieter Noordhuis <pcnoordhuis@gmail.com>
Marek Jelen <marek@jelen.biz>
Fedor Indutny <fedor.indutny@gmail.com>
Saúl Ibarra Corretgé <saghul@gmail.com>

4
deps/uv/README.md

@ -30,14 +30,14 @@ Implemented:
* Thread pool scheduling `uv_queue_work`
* ANSI escape code controlled TTY `uv_tty_t`
In-progress:
* File system events (Currently supports inotify, `ReadDirectoryChangesW`
and will support kqueue and event ports in the near future.)
`uv_fs_event_t`
* VT100 TTY `uv_tty_t`
* Socket sharing between processes `uv_ipc_t`

1
deps/uv/config-mingw.mk

@ -28,6 +28,7 @@ CFLAGS=$(CPPFLAGS) -g --std=gnu89 -D_WIN32_WINNT=0x0501 -Isrc/ares/config_win32
LINKFLAGS=-lm
CARES_OBJS += src/ares/windows_port.o
CARES_OBJS += src/ares/ares_platform.o
WIN_SRCS=$(wildcard src/win/*.c)
WIN_OBJS=$(WIN_SRCS:.c=.o)

13
deps/uv/include/ares.h

@ -1,6 +1,6 @@
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2010 by Daniel Stenberg
* Copyright (C) 2007-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -96,10 +96,19 @@ typedef int ares_socklen_t;
# include <netinet/in.h>
# include <sys/socket.h>
# include <tcp.h>
#elif defined(_WIN32_WCE)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <winsock.h>
#elif defined(WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <winsock2.h>
# include <ws2tcpip.h>
# include <windows.h>
#else
# include <sys/socket.h>
# include <netinet/in.h>

4
deps/uv/include/ares_version.h

@ -7,11 +7,11 @@
#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 7
#define ARES_VERSION_PATCH 4
#define ARES_VERSION_PATCH 5
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
(ARES_VERSION_MINOR<<8)|\
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.7.4"
#define ARES_VERSION_STR "1.7.5-DEV"
#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1

9
deps/uv/include/uv-private/uv-unix.h

@ -33,10 +33,11 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <termios.h>
/* Note: May be cast to struct iovec. See writev(2). */
typedef struct {
@ -183,6 +184,8 @@ typedef int uv_file;
#define UV_WORK_PRIVATE_FIELDS \
eio_req* eio;
#define UV_TTY_PRIVATE_FIELDS /* empty */
#define UV_TTY_PRIVATE_FIELDS \
struct termios orig_termios; \
int mode;
#endif /* UV_UNIX_H */

6
deps/uv/include/uv-private/uv-win.h

@ -75,9 +75,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
uv_idle_t* next_idle_handle; \
ares_channel ares_chan; \
int ares_active_sockets; \
uv_timer_t ares_polling_timer; \
/* Last error code */ \
uv_err_t last_error;
uv_timer_t ares_polling_timer;
#define UV_REQ_TYPE_PRIVATE \
/* TODO: remove the req suffix */ \
@ -151,7 +149,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
#define UV_TCP_PRIVATE_FIELDS \
SOCKET socket; \
uv_err_t bind_error; \
int bind_error; \
union { \
struct { uv_tcp_server_fields }; \
struct { uv_tcp_connection_fields }; \

6
deps/uv/include/uv.h

@ -619,6 +619,12 @@ int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd);
*/
int uv_tty_set_mode(uv_tty_t*, int mode);
/*
* To be called when the program exits. Resets TTY settings to default
* values for the next process to take over.
*/
void uv_tty_reset_mode();
/*
* Gets the current Window size. On success zero is returned.
*/

20
deps/uv/src/ares/CHANGES

@ -1,5 +1,25 @@
Changelog for the c-ares project
Version 1.7.5 (August 16, 2011)
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:

24
deps/uv/src/ares/README.msvc

@ -40,6 +40,30 @@
library version it is using.
How to install using MSVC from the command line
-----------------------------------------------
In order to allow easy usage of c-ares libraries it may be convenient to
install c-ares libraries and header files to a common subdirectory tree.
Once that c-ares libraries have been built using procedure described above,
use same command prompt window to define environment variable INSTALL_DIR
to designate the top subdirectory where installation of c-ares libraries and
header files will be done.
> set INSTALL_DIR=c:\c-ares
Afterwards, run following command to actually perform the installation:
> nmake -f Makefile.msvc install
Installation procedure will copy c-ares libraries to subdirectory 'lib' and
c-ares header files to subdirectory 'include' below the INSTALL_DIR subdir.
When environment variable INSTALL_DIR is not defined, installation is done
to c-ares source folder where Makefile.msvc file is located.
How to build using Visual Studio 6 IDE
--------------------------------------

35
deps/uv/src/ares/RELEASE-NOTES

@ -1,25 +1,26 @@
c-ares version 1.7.4
Changed:
o local-bind: Support binding to local interface/IPs, see
ares_set_local_ip4, ares_set_local_ip6, ares_set_local_dev
c-ares version 1.7.5
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
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
Thanks go to these friendly people for their efforts and contributions:
Andrew C. Morrow, Ben Greear, Ben Noordhuis, Daniel Stenberg,
Guenter Knauf, Mike Crowe, Patrik Thunstrom, Yang Tse
Yang Tse, Jakub Hrozek, Gisle Vanem, Tom Hughes, David Stuart, Dima Tisnek,
Peter Pentchev, Stefan Buhler
Have fun!

9
deps/uv/src/ares/ares_expand_name.c

@ -87,7 +87,14 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
* Since this function strips trailing dots though, it becomes ""
*/
q[0] = '\0';
*enclen = 1; /* the caller should move one byte to get past this */
/* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but
valid) */
if ((*encoded & INDIR_MASK) == INDIR_MASK)
*enclen = 2;
else
*enclen = 1; /* the caller should move one byte to get past this */
return ARES_SUCCESS;
}

1
deps/uv/src/ares/ares_fds.c

@ -21,6 +21,7 @@
#endif
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h"
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)

3
deps/uv/src/ares/ares_free_hostent.c

@ -28,6 +28,9 @@ void ares_free_hostent(struct hostent *host)
{
char **p;
if (!host)
return;
free((char *)(host->h_name));
for (p = host->h_aliases; *p; p++)
free(*p);

30
deps/uv/src/ares/ares_getenv.c

@ -0,0 +1,30 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* 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"
#include "ares_getenv.h"
#ifndef HAVE_GETENV
char *ares_getenv(const char *name)
{
#ifdef _WIN32_WCE
return NULL;
#endif
}
#endif

26
deps/uv/src/ares/ares_getenv.h

@ -0,0 +1,26 @@
#ifndef HEADER_CARES_GETENV_H
#define HEADER_CARES_GETENV_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* 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"
#ifndef HAVE_GETENV
extern char *ares_getenv(const char *name);
#endif
#endif /* HEADER_CARES_GETENV_H */

13
deps/uv/src/ares/ares_gethostbyaddr.c

@ -42,6 +42,7 @@
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_platform.h"
#include "ares_private.h"
#ifdef WATT32
@ -186,7 +187,13 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
if (IS_NT()) {
win_platform platform;
PATH_HOSTS[0] = '\0';
platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;
@ -200,8 +207,10 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;
strcat(PATH_HOSTS, WIN_PATH_HOSTS);

26
deps/uv/src/ares/ares_gethostbyname.c

@ -48,6 +48,7 @@
#include "ares.h"
#include "inet_net_pton.h"
#include "bitncmp.h"
#include "ares_platform.h"
#include "ares_private.h"
#ifdef WATT32
@ -193,11 +194,11 @@ static void host_callback(void *arg, int status, int timeouts,
else if (hquery->sent_family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
if (status == ARES_ENODATA || status == ARES_EBADRESP) {
if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
hquery->want_family == AF_UNSPEC) {
/* The query returned something but either there were no AAAA
records (e.g. just CNAME) or the response was malformed. Try
looking up A instead. We should possibly limit this
attempt-next logic to AF_UNSPEC lookups only. */
looking up A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
@ -209,11 +210,10 @@ static void host_callback(void *arg, int status, int timeouts,
end_hquery(hquery, status, host);
}
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
hquery->want_family == AF_UNSPEC))
{
/* The AAAA query yielded no useful result. Now look up an A instead.
We should possibly limit this attempt-next logic to AF_UNSPEC lookups
only. */
/* The AAAA query yielded no useful result. Now look up an A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);
@ -344,7 +344,13 @@ static int file_lookup(const char *name, int family, struct hostent **host)
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
if (IS_NT()) {
win_platform platform;
PATH_HOSTS[0] = '\0';
platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;
@ -358,8 +364,10 @@ static int file_lookup(const char *name, int family, struct hostent **host)
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;
strcat(PATH_HOSTS, WIN_PATH_HOSTS);

5
deps/uv/src/ares/ares_getnameinfo.c

@ -58,6 +58,7 @@
#include "ares.h"
#include "ares_ipv6.h"
#include "inet_ntop.h"
#include "ares_nowarn.h"
#include "ares_private.h"
struct nameinfo_query {
@ -187,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(addr));
memcpy(&niquery->addr.addr4, addr, sizeof(struct in_addr));
ares_gethostbyaddr(channel, &addr->sin_addr,
sizeof(struct in_addr), AF_INET,
nameinfo_callback, niquery);
@ -195,7 +196,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
else
{
niquery->family = AF_INET6;
memcpy(&niquery->addr.addr6, addr6, sizeof(addr6));
memcpy(&niquery->addr.addr6, addr6, sizeof(struct ares_in6_addr));
ares_gethostbyaddr(channel, &addr6->sin6_addr,
sizeof(struct ares_in6_addr), AF_INET6,
nameinfo_callback, niquery);

329
deps/uv/src/ares/ares_init.c

@ -1,6 +1,6 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2010 by Daniel Stenberg
* Copyright (C) 2007-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -17,10 +17,6 @@
#include "ares_setup.h"
#ifdef USE_WINSOCK
#include <iphlpapi.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
@ -63,17 +59,19 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#ifdef ANDROID
#include <sys/system_properties.h>
#endif
#include "ares.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 ANDROID
#include <sys/system_properties.h>
#endif
#ifdef WATT32
#undef WIN32 /* Redefined in MingW/MSVC headers */
#endif
@ -102,7 +100,7 @@ static int config_lookup(ares_channel channel, const char *str,
const char *bindch, const char *filech);
static int config_sortlist(struct apattern **sortlist, int *nsort,
const char *str);
static char *try_config(char *s, const char *opt);
static char *try_config(char *s, const char *opt, char scc);
#endif
#define ARES_CONFIG_CHECK(x) (x->lookups && x->nsort > -1 && \
@ -363,7 +361,7 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
ipv4_nservers++;
}
if (ipv4_nservers) {
options->servers = malloc(ipv4_nservers * sizeof(struct server_state));
options->servers = malloc(ipv4_nservers * sizeof(struct in_addr));
if (!options->servers)
return ARES_ENOMEM;
for (i = j = 0; i < channel->nservers; i++)
@ -595,73 +593,195 @@ static int get_res_interfaces_nt(HKEY hKey, const char *subkey, char **obuf)
return 0;
}
/**
* The desired output for this method is that we set "ret_buf" to
* something like:
*
* 192.168.0.1,dns01.my.domain,fe80::200:f8ff:fe21:67cf
*
* The only ordering requirement is that primary servers are listed
* before secondary. There is no requirement that IPv4 addresses should
* necessarily be before IPv6.
*
* Note that ret_size should ideally be big enough to hold around
* 2-3 IPv4 and 2-3 IPv6 addresses.
*
* Finally, we need to return the total number of DNS servers located.
*/
static int get_iphlpapi_dns_info (char *ret_buf, size_t ret_size)
{
FIXED_INFO *fi, *newfi;
DWORD size = sizeof (*fi);
IP_ADDR_STRING *ipAddr;
int i, count = 0;
int debug = 0;
size_t ip_size = sizeof("255.255.255.255,")-1;
size_t left = ret_size;
char *ret = ret_buf;
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;
if (debug)
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)
{
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);
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 );
}
}
/* Check the current result for failure */
if( result != ERROR_SUCCESS )
{
free( pFirstEntry );
return 0;
}
/* 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;
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 */
/* 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;
/* NB on Windows this also returns stuff in the fec0::/10 range,
seems to be hard-coded somehow. Do we need to ignore them? */
}
}
}
if( pFirstEntry )
free( pFirstEntry );
if (ret > ret_buf)
ret[-1] = '\0';
return count;
}
if (strlen(fi->DnsServerList.IpAddress.String) > 0 &&
inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE &&
left > ip_size)
else
{
ret += sprintf (ret, "%s,", fi->DnsServerList.IpAddress.String);
left -= ret - ret_buf;
count++;
}
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;
for (i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ip_size;
ipAddr = ipAddr->Next, i++)
{
if (inet_addr(ipAddr->IpAddress.String) != INADDR_NONE)
if (debug)
{
ret += sprintf (ret, "%s,", ipAddr->IpAddress.String);
left -= ret - ret_buf;
count++;
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 (strlen(fi->DnsServerList.IpAddress.String) > 0 &&
inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE &&
left > ipv4_size)
{
ret += sprintf (ret, "%s,", fi->DnsServerList.IpAddress.String);
left -= ret - ret_buf;
++count;
}
for (i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ipv4_size;
ipAddr = ipAddr->Next, i++)
{
if (inet_addr(ipAddr->IpAddress.String) != INADDR_NONE)
{
ret += sprintf (ret, "%s,", ipAddr->IpAddress.String);
left -= ret - ret_buf;
++count;
}
if (debug)
printf (" %s (secondary %d)\n", ipAddr->IpAddress.String, i+1);
}
if (debug)
printf (" %s (secondary %d)\n", ipAddr->IpAddress.String, i+1);
}
quit:
if (fi)
free(fi);
if (debug && left <= ip_size)
printf ("Too many nameservers. Truncating to %d addressess", count);
if (ret > ret_buf)
ret[-1] = '\0';
return count;
if (fi)
free(fi);
if (debug && left <= ipv4_size)
printf ("Too many nameservers. Truncating to %d addressess", count);
if (ret > ret_buf)
ret[-1] = '\0';
return count;
}
}
#endif
@ -704,7 +824,8 @@ DhcpNameServer
DWORD data_type;
DWORD bytes;
DWORD result;
char buf[256];
char buf[512];
win_platform platform;
if (channel->nservers > -1) /* don't override ARES_OPT_SERVER */
return ARES_SUCCESS;
@ -716,7 +837,9 @@ DhcpNameServer
goto okay;
}
if (IS_NT())
platform = ares__getplatform();
if (platform == WIN_NT)
{
if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
@ -750,7 +873,7 @@ DhcpNameServer
RegCloseKey(mykey);
}
}
else
else if (platform == WIN_9X)
{
if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE, WIN_NS_9X, 0,
@ -832,7 +955,10 @@ DhcpNameServer
return ARES_ENOMEM;
for (i = 0; def_nameservers[i]; i++)
servers[i].addr.addrV4.s_addr = htonl(def_nameservers[i]);
{
servers[i].addr.addrV4.s_addr = htonl(def_nameservers[i]);
servers[i].addr.family = AF_INET;
}
status = ARES_EOF;
#elif defined(ANDROID)
@ -856,17 +982,19 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "domain")))
if ((p = try_config(line, "domain", ';')))
status = config_domain(channel, p);
else if ((p = try_config(line, "lookup")) && !channel->lookups)
else if ((p = try_config(line, "lookup", ';')) && !channel->lookups)
status = config_lookup(channel, p, "bind", "file");
else if ((p = try_config(line, "search")))
else if ((p = try_config(line, "search", ';')))
status = set_search(channel, p);
else if ((p = try_config(line, "nameserver")) && channel->nservers == -1)
else if ((p = try_config(line, "nameserver", ';')) &&
channel->nservers == -1)
status = config_nameserver(&servers, &nservers, p);
else if ((p = try_config(line, "sortlist")) && channel->nsort == -1)
else if ((p = try_config(line, "sortlist", ';')) &&
channel->nsort == -1)
status = config_sortlist(&sortlist, &nsort, p);
else if ((p = try_config(line, "options")))
else if ((p = try_config(line, "options", ';')))
status = set_options(channel, p);
else
status = ARES_SUCCESS;
@ -896,8 +1024,9 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "hosts:")) && !channel->lookups)
status = config_lookup(channel, p, "dns", "files");
if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups)
/* ignore errors */
(void)config_lookup(channel, p, "dns", "files");
}
fclose(fp);
}
@ -923,8 +1052,9 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "order")) && !channel->lookups)
status = config_lookup(channel, p, "bind", "hosts");
if ((p = try_config(line, "order", '\0')) && !channel->lookups)
/* ignore errors */
(void)config_lookup(channel, p, "bind", "hosts");
}
fclose(fp);
}
@ -950,8 +1080,9 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "hosts=")) && !channel->lookups)
status = config_lookup(channel, p, "bind", "local");
if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups)
/* ignore errors */
(void)config_lookup(channel, p, "bind", "local");
}
fclose(fp);
}
@ -1042,10 +1173,13 @@ static int init_by_defaults(ares_channel channel)
channel->nservers = 1;
}
#ifdef ENAMETOOLONG
#define toolong(x) (x == -1) && ((ENAMETOOLONG == errno) || (EINVAL == errno))
#if defined(USE_WINSOCK)
#define toolong(x) (x == -1) && (SOCKERRNO == WSAEFAULT)
#elif defined(ENAMETOOLONG)
#define toolong(x) (x == -1) && ((SOCKERRNO == ENAMETOOLONG) || \
(SOCKERRNO == EINVAL))
#else
#define toolong(x) (x == -1) && (EINVAL == errno)
#define toolong(x) (x == -1) && (SOCKERRNO == EINVAL)
#endif
if (channel->ndomains == -1) {
@ -1287,9 +1421,9 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
if (!sortlist_alloc(sortlist, nsort, &pat))
return ARES_ENOMEM;
}
if (ipbufpfx[0] &&
(bits = ares_inet_net_pton(AF_INET, ipbufpfx, &pat.addrV4,
sizeof(pat.addrV4))) > 0)
else if (ipbufpfx[0] &&
(bits = ares_inet_net_pton(AF_INET, ipbufpfx, &pat.addrV4,
sizeof(pat.addrV4))) > 0)
{
pat.type = PATTERN_CIDR;
pat.mask.bits = (unsigned short)bits;
@ -1426,7 +1560,7 @@ static const char *try_option(const char *p, const char *q, const char *opt)
}
#if !defined(WIN32) && !defined(WATT32)
static char *try_config(char *s, const char *opt)
static char *try_config(char *s, const char *opt, char scc)
{
size_t len;
char *p;
@ -1436,10 +1570,17 @@ static char *try_config(char *s, const char *opt)
/* no line or no option */
return NULL;
/* Hash '#' character is always used as primary comment char, additionally
a not-NUL secondary comment char will be considered when specified. */
/* trim line comment */
p = s;
while (*p && (*p != '#'))
p++;
if(scc)
while (*p && (*p != '#') && (*p != scc))
p++;
else
while (*p && (*p != '#'))
p++;
*p = '\0';
/* trim trailing whitespace */

221
deps/uv/src/ares/ares_iphlpapi.h

@ -0,0 +1,221 @@
#ifndef HEADER_CARES_IPHLPAPI_H
#define HEADER_CARES_IPHLPAPI_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004 - 2011 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#if defined(USE_WINSOCK)
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 22
#endif
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 65
#endif
/* ---------------------------------- */
#if !defined(_WS2DEF_) && \
!defined(__CSADDR_DEFINED__) && \
!defined(__CSADDR_T_DEFINED)
/* ---------------------------------- */
typedef struct _SOCKET_ADDRESS {
LPSOCKADDR lpSockaddr;
INT iSockaddrLength;
} SOCKET_ADDRESS, *PSOCKET_ADDRESS;
typedef struct _CSADDR_INFO {
SOCKET_ADDRESS LocalAddr;
SOCKET_ADDRESS RemoteAddr;
INT iSocketType;
INT iProtocol;
} CSADDR_INFO, *PCSADDR_INFO;
/* --------------------------------- */
#endif /* ! _WS2DEF_ && \ */
/* ! __CSADDR_DEFINED__ && \ */
/* ! __CSADDR_T_DEFINED */
/* --------------------------------- */
/* ------------------------------- */
#if !defined(IP_ADAPTER_DDNS_ENABLED)
/* ------------------------------- */
#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x0001
#define IP_ADAPTER_ADDRESS_TRANSIENT 0x0002
#define IP_ADAPTER_DDNS_ENABLED 0x0001
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x0002
#define IP_ADAPTER_DHCP_ENABLED 0x0004
#define IP_ADAPTER_RECEIVE_ONLY 0x0008
#define IP_ADAPTER_NO_MULTICAST 0x0010
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x0020
#define GAA_FLAG_SKIP_UNICAST 0x0001
#define GAA_FLAG_SKIP_ANYCAST 0x0002
#define GAA_FLAG_SKIP_MULTICAST 0x0004
#define GAA_FLAG_SKIP_DNS_SERVER 0x0008
#define GAA_FLAG_INCLUDE_PREFIX 0x0010
#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
typedef enum {
IpPrefixOriginOther = 0,
IpPrefixOriginManual,
IpPrefixOriginWellKnown,
IpPrefixOriginDhcp,
IpPrefixOriginRouterAdvertisement
} IP_PREFIX_ORIGIN;
typedef enum {
IpSuffixOriginOther = 0,
IpSuffixOriginManual,
IpSuffixOriginWellKnown,
IpSuffixOriginDhcp,
IpSuffixOriginLinkLayerAddress,
IpSuffixOriginRandom
} IP_SUFFIX_ORIGIN;
typedef enum {
IpDadStateInvalid = 0,
IpDadStateTentative,
IpDadStateDuplicate,
IpDadStateDeprecated,
IpDadStatePreferred
} IP_DAD_STATE;
typedef enum {
IfOperStatusUp = 1,
IfOperStatusDown,
IfOperStatusTesting,
IfOperStatusUnknown,
IfOperStatusDormant,
IfOperStatusNotPresent,
IfOperStatusLowerLayerDown
} IF_OPER_STATUS;
typedef enum {
ScopeLevelInterface = 0x0001,
ScopeLevelLink = 0x0002,
ScopeLevelSubnet = 0x0003,
ScopeLevelAdmin = 0x0004,
ScopeLevelSite = 0x0005,
ScopeLevelOrganization = 0x0008,
ScopeLevelGlobal = 0x000E
} SCOPE_LEVEL;
typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
IP_PREFIX_ORIGIN PrefixOrigin;
IP_SUFFIX_ORIGIN SuffixOrigin;
IP_DAD_STATE DadState;
ULONG ValidLifetime;
ULONG PreferredLifetime;
ULONG LeaseLifetime;
} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Reserved;
} s;
} u;
struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
typedef struct _IP_ADAPTER_PREFIX {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
} s;
} u;
struct _IP_ADAPTER_PREFIX *Next;
SOCKET_ADDRESS Address;
ULONG PrefixLength;
} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
typedef struct _IP_ADAPTER_ADDRESSES {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD IfIndex;
} s;
} u;
struct _IP_ADAPTER_ADDRESSES *Next;
PCHAR AdapterName;
PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
PWCHAR DnsSuffix;
PWCHAR Description;
PWCHAR FriendlyName;
BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD PhysicalAddressLength;
DWORD Flags;
DWORD Mtu;
DWORD IfType;
IF_OPER_STATUS OperStatus;
DWORD Ipv6IfIndex;
DWORD ZoneIndices[16];
PIP_ADAPTER_PREFIX FirstPrefix;
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
/* -------------------------------- */
#endif /* ! IP_ADAPTER_DDNS_ENABLED */
/* -------------------------------- */
#endif /* USE_WINSOCK */
#endif /* HEADER_CARES_IPHLPAPI_H */

10
deps/uv/src/ares/ares_library_init.c

@ -26,6 +26,7 @@
#ifdef USE_WINSOCK
fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
#endif
/* library-private global vars with source visibility restricted to this file */
@ -56,6 +57,15 @@ static int ares_win32_init(void)
return ARES_EADDRGETNETWORKPARAMS;
}
ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t)
GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses");
if (!ares_fpGetAdaptersAddresses)
{
/* This can happen on clients before WinXP, I don't
think it should be an error, unless we don't want to
support Windows 2000 anymore */
}
/*
* When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
* also known as RtlGenRandom, which is the case for Windows versions prior

5
deps/uv/src/ares/ares_library_init.h

@ -3,7 +3,7 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2009 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
@ -23,15 +23,18 @@
#ifdef USE_WINSOCK
#include <iphlpapi.h>
#include "ares_iphlpapi.h"
typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*);
typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG);
typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* );
/* Forward-declaration of variables defined in ares_library_init.c */
/* that are global and unique instances for whole c-ares library. */
extern fpGetNetworkParams_t ares_fpGetNetworkParams;
extern fpSystemFunction036_t ares_fpSystemFunction036;
extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses;
#endif /* USE_WINSOCK */

130
deps/uv/src/ares/ares_nowarn.c

@ -1,5 +1,5 @@
/* Copyright (C) 2010 by Daniel Stenberg
/* Copyright (C) 2010-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -17,13 +17,44 @@
#include "ares_setup.h"
#ifdef HAVE_ASSERT_H
# include <assert.h>
#endif
#if defined(__INTEL_COMPILER) && defined(__unix__)
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#endif /* __INTEL_COMPILER && __unix__ */
#define BUILDING_ARES_NOWARN_C 1
#include "ares_nowarn.h"
#define CARES_MASK_UINT (~(unsigned int) 0)
#define CARES_MASK_SINT (CARES_MASK_UINT >> 1)
#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
#endif
/*
** size_t to signed int
** unsigned size_t to signed int
*/
int aresx_uztosi(size_t uznum)
@ -51,9 +82,100 @@ int aresx_sltosi(long slnum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(slnum >= 0);
return (int)(slnum & (long) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed ssize_t to signed int
*/
int aresx_sztosi(ssize_t sznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sznum >= 0);
return (int)(sznum & (ssize_t) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed ssize_t to unsigned int
*/
unsigned int aresx_sztoui(ssize_t sznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sznum >= 0);
return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:1469) /* clobber ignored */
return FD_ISSET(fd, fdset);
#pragma warning(pop)
}
void aresx_FD_SET(int fd, fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:1469) /* clobber ignored */
FD_SET(fd, fdset);
#pragma warning(pop)
}
void aresx_FD_ZERO(fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:593) /* variable was set but never used */
FD_ZERO(fdset);
#pragma warning(pop)
}
unsigned short aresx_htons(unsigned short usnum)
{
#if (__INTEL_COMPILER == 910) && defined(__i386__)
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
#else
#pragma warning(push)
#pragma warning(disable:810) /* conversion may lose significant bits */
return htons(usnum);
#pragma warning(pop)
#endif
}
unsigned short aresx_ntohs(unsigned short usnum)
{
#if (__INTEL_COMPILER == 910) && defined(__i386__)
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
#else
#pragma warning(push)
#pragma warning(disable:810) /* conversion may lose significant bits */
return ntohs(usnum);
#pragma warning(pop)
#endif
}
#endif /* __INTEL_COMPILER && __unix__ */

33
deps/uv/src/ares/ares_nowarn.h

@ -2,7 +2,7 @@
#define HEADER_CARES_NOWARN_H
/* Copyright (C) 2010 by Daniel Stenberg
/* Copyright (C) 2010-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -21,4 +21,35 @@ int aresx_uztosi(size_t uznum);
int aresx_sltosi(long slnum);
int aresx_sztosi(ssize_t sznum);
unsigned int aresx_sztoui(ssize_t sznum);
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset);
void aresx_FD_SET(int fd, fd_set *fdset);
void aresx_FD_ZERO(fd_set *fdset);
unsigned short aresx_htons(unsigned short usnum);
unsigned short aresx_ntohs(unsigned short usnum);
#ifndef BUILDING_ARES_NOWARN_C
# undef FD_ISSET
# define FD_ISSET(a,b) aresx_FD_ISSET((a),(b))
# undef FD_SET
# define FD_SET(a,b) aresx_FD_SET((a),(b))
# undef FD_ZERO
# define FD_ZERO(a) aresx_FD_ZERO((a))
# undef htons
# define htons(a) aresx_htons((a))
# undef ntohs
# define ntohs(a) aresx_ntohs((a))
#endif
#endif /* __INTEL_COMPILER && __unix__ */
#endif /* HEADER_CARES_NOWARN_H */

13
deps/uv/src/ares/ares_options.c

@ -1,6 +1,6 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2008-2010 by Daniel Stenberg
* Copyright (C) 2008-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -135,12 +135,10 @@ int ares_set_servers(ares_channel channel,
int ares_set_servers_csv(ares_channel channel,
const char* _csv)
{
int i;
size_t i;
char* csv = NULL;
char* ptr;
char* start_host;
long port;
bool found_port;
int rv = ARES_SUCCESS;
struct ares_addr_node *servers = NULL;
struct ares_addr_node *last = NULL;
@ -165,7 +163,6 @@ int ares_set_servers_csv(ares_channel channel,
}
start_host = csv;
found_port = false;
for (ptr = csv; *ptr; ptr++) {
if (*ptr == ',') {
char* pp = ptr - 1;
@ -186,9 +183,8 @@ int ares_set_servers_csv(ares_channel channel,
pp--;
}
if ((pp != start_host) && ((pp + 1) < ptr)) {
/* Found it. */
found_port = true;
port = strtol(pp + 1, NULL, 10);
/* Found it. Parse over the port number */
(void)strtol(pp + 1, NULL, 10);
*pp = 0; /* null terminate host */
}
/* resolve host, try ipv4 first, rslt is in network byte order */
@ -233,7 +229,6 @@ int ares_set_servers_csv(ares_channel channel,
}
/* Set up for next one */
found_port = false;
start_host = ptr + 1;
}
}

3
deps/uv/src/ares/ares_parse_a_reply.c

@ -132,6 +132,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
@ -149,6 +150,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
{
if (aptr + sizeof(struct in_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
@ -159,6 +161,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
struct ares_addrttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct in_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}

3
deps/uv/src/ares/ares_parse_aaaa_reply.c

@ -132,6 +132,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
@ -149,6 +150,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
{
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
@ -159,6 +161,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
struct ares_addr6ttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}

4
deps/uv/src/ares/ares_parse_mx_reply.c

@ -47,7 +47,7 @@
int
ares_parse_mx_reply (const unsigned char *abuf, int alen,
struct ares_mx_reply **mx_out)
struct ares_mx_reply **mx_out)
{
unsigned int qdcount, ancount, i;
const unsigned char *aptr, *vptr;
@ -134,7 +134,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
mx_last = mx_curr;
vptr = aptr;
mx_curr->priority = ntohs (*((unsigned short *)vptr));
mx_curr->priority = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
status = ares_expand_name (vptr, abuf, alen, &mx_curr->host, &len);

4
deps/uv/src/ares/ares_parse_ns_reply.c

@ -1,5 +1,3 @@
/* $Id */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
@ -105,6 +103,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
if ( aptr + RRFIXEDSZ > abuf + alen )
{
status = ARES_EBADRESP;
free(rr_name);
break;
}
rr_type = DNS_RR_TYPE( aptr );
@ -119,6 +118,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
&len);
if ( status != ARES_SUCCESS )
{
free(rr_name);
break;
}

15
deps/uv/src/ares/ares_parse_ptr_reply.c

@ -99,6 +99,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
@ -114,13 +115,17 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
&len);
if (status != ARES_SUCCESS)
break;
{
free(rr_name);
break;
}
if (hostname)
free(hostname);
hostname = rr_data;
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char *));
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char));
if (!aliases[aliascnt])
{
free(rr_name);
status = ARES_ENOMEM;
break;
}
@ -131,6 +136,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
alias_alloc *= 2;
ptr = realloc(aliases, alias_alloc * sizeof(char *));
if(!ptr) {
free(rr_name);
status = ARES_ENOMEM;
break;
}
@ -144,7 +150,10 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
&len);
if (status != ARES_SUCCESS)
break;
{
free(rr_name);
break;
}
free(ptrname);
ptrname = rr_data;
}

6
deps/uv/src/ares/ares_parse_srv_reply.c

@ -139,11 +139,11 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
srv_last = srv_curr;
vptr = aptr;
srv_curr->priority = ntohs (*((unsigned short *)vptr));
srv_curr->priority = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
srv_curr->weight = ntohs (*((unsigned short *)vptr));
srv_curr->weight = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
srv_curr->port = ntohs (*((unsigned short *)vptr));
srv_curr->port = DNS__16BIT(vptr);
vptr += sizeof(unsigned short);
status = ares_expand_name (vptr, abuf, alen, &srv_curr->host, &len);

11035
deps/uv/src/ares/ares_platform.c

File diff suppressed because it is too large

43
deps/uv/src/ares/ares_platform.h

@ -0,0 +1,43 @@
#ifndef HEADER_CARES_PLATFORM_H
#define HEADER_CARES_PLATFORM_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004 - 2011 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#if defined(WIN32) && !defined(MSDOS)
typedef enum {
WIN_UNKNOWN,
WIN_3X,
WIN_9X,
WIN_NT,
WIN_CE
} win_platform;
win_platform ares__getplatform(void);
#endif
#if defined(_WIN32_WCE)
struct servent *getservbyport(int port, const char *proto);
#endif
#endif /* HEADER_CARES_PLATFORM_H */

8
deps/uv/src/ares/ares_private.h

@ -52,7 +52,6 @@
#if defined(WIN32) && !defined(WATT32)
#define IS_NT() ((int)GetVersion() > 0)
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
#define NAMESERVER "NameServer"
@ -89,6 +88,11 @@
#include "ares_ipv6.h"
#include "ares_llist.h"
#ifndef HAVE_GETENV
# include "ares_getenv.h"
# define getenv(ptr) ares_getenv(ptr)
#endif
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
@ -199,7 +203,7 @@ struct query {
void *arg;
/* Query status */
int try; /* Number of times we tried this query already. */
int try_count; /* Number of times we tried this query already. */
int server; /* Server this query has last been sent to. */
struct query_server_info *server_info; /* per-server state */
int using_tcp;

49
deps/uv/src/ares/ares_process.c

@ -63,10 +63,10 @@
#include <stdlib.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_nowarn.h"
#include "ares_private.h"
@ -300,29 +300,28 @@ static void advance_tcp_send_queue(ares_channel channel, int whichserver,
{
struct send_request *sendreq;
struct server_state *server = &channel->servers[whichserver];
while (num_bytes > 0)
{
sendreq = server->qhead;
if ((size_t)num_bytes >= sendreq->len)
{
num_bytes -= sendreq->len;
server->qhead = sendreq->next;
if (server->qhead == NULL)
{
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
server->qtail = NULL;
}
if (sendreq->data_storage != NULL)
free(sendreq->data_storage);
free(sendreq);
}
else
{
sendreq->data += num_bytes;
sendreq->len -= num_bytes;
num_bytes = 0;
}
while (num_bytes > 0) {
sendreq = server->qhead;
if ((size_t)num_bytes >= sendreq->len) {
num_bytes -= sendreq->len;
server->qhead = sendreq->next;
if (sendreq->data_storage)
free(sendreq->data_storage);
free(sendreq);
if (server->qhead == NULL) {
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
server->qtail = NULL;
/* qhead is NULL so we cannot continue this loop */
break;
}
}
else {
sendreq->data += num_bytes;
sendreq->len -= num_bytes;
num_bytes = 0;
}
}
}
/* If any TCP socket selects true for reading, read some data,
@ -686,7 +685,7 @@ static void next_server(ares_channel channel, struct query *query,
* servers to try. In total, we need to do channel->nservers * channel->tries
* attempts. Use query->try to remember how many times we already attempted
* this query. Use modular arithmetic to find the next server to try. */
while (++(query->try) < (channel->nservers * channel->tries))
while (++(query->try_count) < (channel->nservers * channel->tries))
{
struct server_state *server;
@ -791,7 +790,7 @@ void ares__send_query(ares_channel channel, struct query *query,
return;
}
}
timeplus = channel->timeout << (query->try / channel->nservers);
timeplus = channel->timeout << (query->try_count / channel->nservers);
timeplus = (timeplus * (9 + (rand () & 7))) / 16;
query->timeout = *now;
ares__timeadd(&query->timeout,

3
deps/uv/src/ares/ares_search.c

@ -20,7 +20,6 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
@ -292,7 +291,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
}
else
{
error = errno;
error = ERRNO;
switch(error)
{
case ENOENT:

2
deps/uv/src/ares/ares_send.c

@ -96,7 +96,7 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
query->arg = arg;
/* Initialize query status. */
query->try = 0;
query->try_count = 0;
/* Choose the server to send the query to. If rotation is enabled, keep track
* of the next server we want to use. */

16
deps/uv/src/ares/ares_setup.h

@ -1,7 +1,6 @@
#ifndef HEADER_CARES_SETUP_H
#define HEADER_CARES_SETUP_H
/* $Id$ */
/* Copyright (C) 2004 - 2009 by Daniel Stenberg et al
*
@ -31,6 +30,12 @@
#ifdef HAVE_CONFIG_H
#include "ares_config.h"
#else
#ifdef WIN32
#include "config-win32.h"
#endif
#endif /* HAVE_CONFIG_H */
/* ================================================================ */
@ -70,7 +75,7 @@
/* please, do it beyond the point further indicated in this file. */
/* ================================================================ */
#if 0 /* libuv disabled */
#if 0 /* libuv hack */
/*
* c-ares external interface definitions are also used internally,
* and might also include required system header files to define them.
@ -83,7 +88,7 @@
*/
#include <ares_rules.h>
#endif
#endif /* libuv hack */
/* ================================================================= */
/* No system header file shall be included in this file before this */
@ -102,6 +107,10 @@
*/
#ifdef HAVE_WINDOWS_H
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
# ifdef HAVE_WS2TCPIP_H
@ -112,7 +121,6 @@
# include <winsock.h>
# endif
# endif
# include <windows.h>
#endif
/*

2
deps/uv/src/ares/config_cygwin/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

2
deps/uv/src/ares/config_darwin/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

2
deps/uv/src/ares/config_freebsd/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

2
deps/uv/src/ares/config_linux/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

2
deps/uv/src/ares/config_netbsd/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

2
deps/uv/src/ares/config_openbsd/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

2
deps/uv/src/ares/config_sunos/ares_config.h

@ -508,3 +508,5 @@
/* the signed version of size_t */
/* #undef ssize_t */
#define HAVE_GETENV 1

3
deps/uv/src/ares/config_win32/ares_config.h

@ -108,6 +108,9 @@
/* Define if you have the strcasecmp function. */
/* #define HAVE_STRCASECMP 1 */
/* Define if you have the getenv function. */
#define HAVE_GETENV 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1

41
deps/uv/src/ares/inet_net_pton.c

@ -37,20 +37,20 @@
#endif
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_ipv6.h"
#include "ares_nowarn.h"
#include "inet_net_pton.h"
const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
#if !defined(HAVE_INET_NET_PTON) || !defined(HAVE_INET_NET_PTON_IPV6)
#ifndef HAVE_INET_NET_PTON
/*
* static int
@ -83,16 +83,17 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& ISASCII(src[1])
&& ISXDIGIT(src[1])) {
/* Hexadecimal: Eat nybble string. */
if (!size)
goto emsgsize;
dirty = 0;
src++; /* skip x or X. */
while ((ch = *src++) != '\0' && ISXDIGIT(ch)) {
while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) {
if (ISUPPER(ch))
ch = tolower(ch);
n = (int)(strchr(xdigits, ch) - xdigits);
n = aresx_sztosi(strchr(xdigits, ch) - xdigits);
if (dirty == 0)
tmp = n;
else
@ -109,18 +110,18 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
goto emsgsize;
*dst++ = (unsigned char) (tmp << 4);
}
} else if (ISDIGIT(ch)) {
} else if (ISASCII(ch) && ISDIGIT(ch)) {
/* Decimal: eat dotted digit string. */
for (;;) {
tmp = 0;
do {
n = (int)(strchr(digits, ch) - digits);
n = aresx_sztosi(strchr(digits, ch) - digits);
tmp *= 10;
tmp += n;
if (tmp > 255)
goto enoent;
} while ((ch = *src++) != '\0' &&
ISDIGIT(ch));
ISASCII(ch) && ISDIGIT(ch));
if (!size--)
goto emsgsize;
*dst++ = (unsigned char) tmp;
@ -129,27 +130,27 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
if (ch != '.')
goto enoent;
ch = *src++;
if (!ISDIGIT(ch))
if (!ISASCII(ch) || !ISDIGIT(ch))
goto enoent;
}
} else
goto enoent;
bits = -1;
if (ch == '/' &&
if (ch == '/' && ISASCII(src[0]) &&
ISDIGIT(src[0]) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
bits = 0;
do {
n = (int)(strchr(digits, ch) - digits);
n = aresx_sztosi(strchr(digits, ch) - digits);
bits *= 10;
bits += n;
} while ((ch = *src++) != '\0' && ISDIGIT(ch));
if (bits > 32)
goto enoent;
} while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch));
if (ch != '\0')
goto enoent;
if (bits > 32)
goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
@ -173,7 +174,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits < ((dst - odst) * 8))
bits = (int)(dst - odst) * 8;
bits = aresx_sztosi(dst - odst) * 8;
/*
* If there are no additional bits specified for a class D
* address adjust bits to 4.
@ -216,7 +217,7 @@ getbits(const char *src, int *bitsp)
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
val += aresx_sztosi(pch - digits);
if (val > 128) /* range */
return (0);
continue;
@ -248,7 +249,7 @@ getv4(const char *src, unsigned char *dst, int *bitsp)
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
val += aresx_sztoui(pch - digits);
if (val > 255) /* range */
return (0);
continue;
@ -269,8 +270,8 @@ getv4(const char *src, unsigned char *dst, int *bitsp)
return (0);
if (dst - odst > 3) /* too many octets? */
return (0);
*dst++ = (unsigned char)val;
return (1);
*dst = (unsigned char)val;
return 1;
}
static int
@ -308,7 +309,7 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
val |= aresx_sztoui(pch - xdigits);
if (++digits > 4)
goto enoent;
saw_xdigit = 1;
@ -425,7 +426,7 @@ ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
}
}
#endif
#endif /* HAVE_INET_NET_PTON */
#ifndef HAVE_INET_PTON
int ares_inet_pton(int af, const char *src, void *dst)

12
deps/uv/src/ares/inet_net_pton.h

@ -1,8 +1,7 @@
#ifndef __ARES_INET_NET_PTON_H
#define __ARES_INET_NET_PTON_H
#ifndef HEADER_CARES_INET_NET_PTON_H
#define HEADER_CARES_INET_NET_PTON_H
/* Copyright (C) 2005 by Daniel Stenberg
/* Copyright (C) 2005-2010 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@ -22,10 +21,11 @@
#else
int ares_inet_pton(int af, const char *src, void *dst);
#endif
#if defined(HAVE_INET_NET_PTON) && defined(HAVE_INET_NET_PTON_IPV6)
#ifdef HAVE_INET_NET_PTON
#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
#else
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
#endif
#endif /* __ARES_INET_NET_PTON_H */
#endif /* HEADER_CARES_INET_NET_PTON_H */

182
deps/uv/src/ares/inet_ntop.c

@ -1,18 +1,18 @@
/* Copyright (c) 1996 by Internet Software Consortium.
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "ares_setup.h"
@ -36,7 +36,6 @@
#endif
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -48,12 +47,6 @@
#ifndef HAVE_INET_NTOP
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
@ -68,32 +61,31 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
* return:
* pointer to presentation format address (`dst'), or NULL (see errno).
* note:
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid loosing the
* actual last winsock error. So use macro ERRNO to fetch the
* errno this funtion sets when returning NULL, not SOCKERRNO.
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid loosing the
* actual last winsock error. So use macro ERRNO to fetch the
* errno this funtion sets when returning NULL, not SOCKERRNO.
* author:
* Paul Vixie, 1996.
*/
const char *
ares_inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af)
{
case AF_INET:
return (inet_ntop4(src, dst, size));
case AF_INET6:
return (inet_ntop6(src, dst, size));
default:
SET_ERRNO(EAFNOSUPPORT);
return (NULL);
}
switch (af) {
case AF_INET:
return (inet_ntop4(src, dst, size));
case AF_INET6:
return (inet_ntop6(src, dst, size));
default:
SET_ERRNO(EAFNOSUPPORT);
return (NULL);
}
/* NOTREACHED */
}
/* const char *
* inet_ntop4(src, dst, size)
* format an IPv4 address, more or less like inet_ntoa()
* format an IPv4 address
* return:
* `dst' (as a const)
* notes:
@ -106,22 +98,21 @@ static const char *
inet_ntop4(const unsigned char *src, char *dst, size_t size)
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
char tmp[sizeof("255.255.255.255")];
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size)
{
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
return (dst);
if ((size_t)sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= size) {
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/* const char *
* inet_ntop6(src, dst, size)
* convert IPv6 binary address into presentation (printable) format
* convert IPv6 binary address into presentation (printable) format
* author:
* Paul Vixie, 1996.
* Paul Vixie, 1996.
*/
static const char *
inet_ntop6(const unsigned char *src, char *dst, size_t size)
@ -135,11 +126,8 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
*/
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
char *tp;
struct {
long base;
long len;
} best, cur;
unsigned long words[NS_IN6ADDRSZ / NS_INT16SZ];
struct { int base, len; } best, cur;
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
@ -149,37 +137,29 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
*/
memset(words, '\0', sizeof(words));
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
best.len = 0;
cur.base = -1;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{
if (words[i] == 0)
{
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
}
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
{
if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.len++;
} else {
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
@ -187,46 +167,42 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len))
{
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
if (i == best.base)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += SPRINTF((tp, "%lx", words[i]));
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 && (best.len == 6 ||
(best.len == 7 && words[7] != 0x0001) ||
(best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += sprintf(tp, "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ))
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size)
{
SET_ERRNO(ENOSPC);
return (NULL);
}
if ((size_t)(tp - tmp) > size) {
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
#endif

1
deps/uv/src/ares/inet_ntop.h

@ -18,7 +18,6 @@
*/
#ifdef HAVE_INET_NTOP
#include <arpa/inet.h>
#define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z)
#else
const char *ares_inet_ntop(int af, const void *src, char *dst, size_t size);

10
deps/uv/src/ares/nameser.h

@ -75,6 +75,11 @@ typedef enum __ns_type {
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (RFC3123) */
ns_t_ds = 43, /* Delegation Signer (RFC4034) */
ns_t_sshfp = 44, /* SSH Key Fingerprint (RFC4255) */
ns_t_rrsig = 46, /* Resource Record Signature (RFC4034) */
ns_t_nsec = 47, /* Next Secure (RFC4034) */
ns_t_dnskey = 48, /* DNS Public Key (RFC4034) */
ns_t_tkey = 249, /* Transaction key */
ns_t_tsig = 250, /* Transaction signature. */
ns_t_ixfr = 251, /* Incremental zone transfer. */
@ -181,6 +186,11 @@ typedef enum __ns_rcode {
#define T_SRV ns_t_srv
#define T_ATMA ns_t_atma
#define T_NAPTR ns_t_naptr
#define T_DS ns_t_ds
#define T_SSHFP ns_t_sshfp
#define T_RRSIG ns_t_rrsig
#define T_NSEC ns_t_nsec
#define T_DNSKEY ns_t_dnskey
#define T_TSIG ns_t_tsig
#define T_IXFR ns_t_ixfr
#define T_AXFR ns_t_axfr

20
deps/uv/src/ares/setup_once.h

@ -2,7 +2,7 @@
#define __SETUP_ONCE_H
/* Copyright (C) 2004 - 2010 by Daniel Stenberg et al
/* Copyright (C) 2004 - 2011 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
@ -35,7 +35,10 @@
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -248,6 +251,7 @@ struct timeval {
#define ISPRINT(x) (isprint((int) ((unsigned char)x)))
#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
#define ISLOWER(x) (islower((int) ((unsigned char)x)))
#define ISASCII(x) (isascii((int) ((unsigned char)x)))
#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
(((unsigned char)x) == '\t'))
@ -366,7 +370,7 @@ typedef int sig_atomic_t;
* (or equivalent) on this platform to hide platform details to code using it.
*/
#ifdef WIN32
#if defined(WIN32) && !defined(WATT32)
#define ERRNO ((int)GetLastError())
#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
#else
@ -455,6 +459,18 @@ 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()
*/

2
deps/uv/src/unix/cares.c

@ -147,7 +147,7 @@ int uv_ares_init_options(uv_loop_t* loop, ares_channel *channelptr,
/* only allow single init at a time */
if (loop->channel != NULL) {
uv_err_new_artificial(loop, UV_EALREADY);
uv__set_artificial_error(loop, UV_EALREADY);
return -1;
}

8
deps/uv/src/unix/core.c

@ -563,7 +563,7 @@ int uv_timer_stop(uv_timer_t* timer) {
int uv_timer_again(uv_timer_t* timer) {
if (!ev_is_active(&timer->timer_watcher)) {
uv_err_new(timer->loop, EINVAL);
uv__set_sys_error(timer->loop, EINVAL);
return -1;
}
@ -595,7 +595,7 @@ static int uv_getaddrinfo_done(eio_req* req) {
if (handle->retcode != 0) {
/* TODO how to display gai error strings? */
uv_err_new(handle->loop, handle->retcode);
uv__set_sys_error(handle->loop, handle->retcode);
}
handle->cb(handle, handle->retcode, res);
@ -626,7 +626,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (handle == NULL || cb == NULL ||
(hostname == NULL && service == NULL)) {
uv_err_new_artificial(loop, UV_EINVAL);
uv__set_artificial_error(loop, UV_EINVAL);
return -1;
}
@ -639,7 +639,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (hints) {
handle->hints = malloc(sizeof(struct addrinfo));
memcpy(&handle->hints, hints, sizeof(struct addrinfo));
memcpy(handle->hints, hints, sizeof(struct addrinfo));
}
else {
handle->hints = NULL;

2
deps/uv/src/unix/cygwin.c

@ -58,7 +58,7 @@ int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_err_new(loop, ENOSYS);
uv__set_sys_error(loop, ENOSYS);
return -1;
}

2
deps/uv/src/unix/darwin.c

@ -73,7 +73,7 @@ int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_err_new(loop, ENOSYS);
uv__set_sys_error(loop, ENOSYS);
return -1;
}

23
deps/uv/src/unix/error.c

@ -56,11 +56,6 @@ void uv_fatal_error(const int errorno, const char* syscall) {
}
uv_err_t uv_last_error(uv_loop_t* loop) {
return loop->last_err;
}
char* uv_strerror(uv_err_t err) {
return strerror(err.sys_errno_);
}
@ -90,21 +85,3 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
assert(0 && "unreachable");
return -1;
}
uv_err_t uv_err_new_artificial(uv_loop_t* loop, int code) {
uv_err_t err;
err.sys_errno_ = 0;
err.code = code;
loop->last_err = err;
return err;
}
uv_err_t uv_err_new(uv_loop_t* loop, int sys_error) {
uv_err_t err;
err.sys_errno_ = sys_error;
err.code = uv_translate_sys_error(sys_error);
loop->last_err = err;
return err;
}

2
deps/uv/src/unix/freebsd.c

@ -72,7 +72,7 @@ int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_err_new(loop, ENOSYS);
uv__set_sys_error(loop, ENOSYS);
return -1;
}

42
deps/uv/src/unix/fs.c

@ -46,7 +46,7 @@
/* async */ \
req->eio = eiofunc(args, EIO_PRI_DEFAULT, uv__fs_after, req); \
if (!req->eio) { \
uv_err_new(loop, ENOMEM); \
uv__set_sys_error(loop, ENOMEM); \
return -1; \
} \
uv_ref(loop); \
@ -54,7 +54,7 @@
/* sync */ \
req->result = func(args); \
if (req->result) { \
uv_err_new(loop, errno); \
uv__set_sys_error(loop, errno); \
} \
return req->result; \
} \
@ -192,7 +192,7 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
uv_ref(loop);
req->eio = eio_open(path, flags, mode, EIO_PRI_DEFAULT, uv__fs_after, req);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -200,7 +200,7 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
/* sync */
req->result = open(path, flags, mode);
if (req->result < 0) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -224,7 +224,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file fd, void* buf,
uv__fs_after, req);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -235,7 +235,7 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file fd, void* buf,
pread(fd, buf, length, offset);
if (req->result < 0) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -261,7 +261,7 @@ int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
req->eio = eio_write(file, buf, length, offset, EIO_PRI_DEFAULT,
uv__fs_after, req);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -272,7 +272,7 @@ int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
pwrite(file, buf, length, offset);
if (req->result < 0) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -308,7 +308,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
uv_ref(loop);
req->eio = eio_readdir(path, flags, EIO_PRI_DEFAULT, uv__fs_after, req);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -316,7 +316,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
/* sync */
DIR* dir = opendir(path);
if (!dir) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
req->result = -1;
return -1;
}
@ -345,7 +345,7 @@ int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
r = closedir(dir);
if (r) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
req->result = -1;
return -1;
}
@ -381,7 +381,7 @@ int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
free(pathdup);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -392,7 +392,7 @@ int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
free(pathdup);
if (req->result < 0) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -413,7 +413,7 @@ int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
req->eio = eio_fstat(file, EIO_PRI_DEFAULT, uv__fs_after, req);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -422,7 +422,7 @@ int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
req->result = fstat(file, &req->statbuf);
if (req->result < 0) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -520,7 +520,7 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
WRAP_EIO(UV_FS_FUTIME, eio_futime, _futime, ARGS3(file, atime, mtime))
#else
uv_err_new(loop, ENOSYS);
uv__set_sys_error(loop, ENOSYS);
return -1;
#endif
}
@ -550,7 +550,7 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
free(pathdup);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -561,7 +561,7 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
free(pathdup);
if (req->result < 0) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -600,7 +600,7 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_ref(loop);
return 0;
} else {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
} else {
@ -616,7 +616,7 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
}
if ((buf = malloc(size + 1)) == NULL) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}
@ -693,7 +693,7 @@ int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,
req->eio = eio_custom(uv__work, EIO_PRI_DEFAULT, uv__after_work, req);
if (!req->eio) {
uv_err_new(loop, ENOMEM);
uv__set_sys_error(loop, ENOMEM);
return -1;
}

2
deps/uv/src/unix/internal.h

@ -96,8 +96,6 @@ int uv__socket(int domain, int type, int protocol);
/* error */
uv_err_code uv_translate_sys_error(int sys_errno);
uv_err_t uv_err_new(uv_loop_t* loop, int sys_error);
uv_err_t uv_err_new_artificial(uv_loop_t* loop, int code);
void uv_fatal_error(const int errorno, const char* syscall);
/* stream */

4
deps/uv/src/unix/linux.c

@ -145,7 +145,7 @@ int uv_fs_event_init(uv_loop_t* loop,
* keep creating new inotify fds.
*/
if ((fd = new_inotify_fd()) == -1) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -158,7 +158,7 @@ int uv_fs_event_init(uv_loop_t* loop,
| IN_MOVED_TO;
if (inotify_add_watch(fd, filename, flags) == -1) {
uv_err_new(loop, errno);
uv__set_sys_error(loop, errno);
uv__close(fd);
return -1;
}

2
deps/uv/src/unix/netbsd.c

@ -75,7 +75,7 @@ int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_err_new(loop, ENOSYS);
uv__set_sys_error(loop, ENOSYS);
return -1;
}

18
deps/uv/src/unix/pipe.c

@ -53,13 +53,13 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
/* Already bound? */
if (handle->fd >= 0) {
uv_err_new_artificial(handle->loop, UV_EINVAL);
uv__set_artificial_error(handle->loop, UV_EINVAL);
goto out;
}
/* Make a copy of the file name, it outlives this function's scope. */
if ((pipe_fname = strdup(name)) == NULL) {
uv_err_new(handle->loop, ENOMEM);
uv__set_sys_error(handle->loop, ENOMEM);
goto out;
}
@ -67,7 +67,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
name = NULL;
if ((sockfd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
goto out;
}
@ -88,7 +88,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
|| unlink(pipe_fname) == -1
|| bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr) == -1) {
/* Convert ENOENT to EACCES for compatibility with Windows. */
uv_err_new(handle->loop, (errno == ENOENT) ? EACCES : errno);
uv__set_sys_error(handle->loop, (errno == ENOENT) ? EACCES : errno);
goto out;
}
}
@ -125,13 +125,13 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
status = -1;
if (handle->fd == -1) {
uv_err_new_artificial(handle->loop, UV_EINVAL);
uv__set_artificial_error(handle->loop, UV_EINVAL);
goto out;
}
assert(handle->fd >= 0);
if ((status = listen(handle->fd, backlog)) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
} else {
handle->connection_cb = cb;
ev_io_init(&handle->read_watcher, uv__pipe_accept, handle->fd, EV_READ);
@ -190,7 +190,7 @@ int uv_pipe_connect(uv_connect_t* req,
status = -1;
if ((sockfd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
goto out;
}
@ -207,7 +207,7 @@ int uv_pipe_connect(uv_connect_t* req,
while (r == -1 && errno == EINTR);
if (r == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
uv__close(sockfd);
goto out;
}
@ -257,7 +257,7 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
assert(0 && "EAGAIN on uv__accept(pipefd)");
} else {
uv_err_new(pipe->loop, errno);
uv__set_sys_error(pipe->loop, errno);
}
} else {
pipe->accepted_fd = sockfd;

4
deps/uv/src/unix/process.c

@ -277,7 +277,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
return 0;
error:
uv_err_new(process->loop, errno);
uv__set_sys_error(process->loop, errno);
uv__close(stdin_pipe[0]);
uv__close(stdin_pipe[1]);
uv__close(stdout_pipe[0]);
@ -292,7 +292,7 @@ int uv_process_kill(uv_process_t* process, int signum) {
int r = kill(process->pid, signum);
if (r) {
uv_err_new(process->loop, errno);
uv__set_sys_error(process->loop, errno);
return -1;
} else {
return 0;

38
deps/uv/src/unix/stream.c

@ -87,7 +87,7 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) {
yes = 1;
if (stream->type == UV_TCP
&& setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
uv_err_new(stream->loop, errno);
uv__set_sys_error(stream->loop, errno);
return -1;
}
@ -118,7 +118,7 @@ void uv__stream_destroy(uv_stream_t* stream) {
free(req->bufs);
if (req->cb) {
uv_err_new_artificial(req->handle->loop, UV_EINTR);
uv__set_artificial_error(req->handle->loop, UV_EINTR);
req->cb(req, -1);
}
}
@ -129,7 +129,7 @@ void uv__stream_destroy(uv_stream_t* stream) {
req = ngx_queue_data(q, uv_write_t, queue);
if (req->cb) {
uv_err_new_artificial(stream->loop, req->error);
uv__set_artificial_error(stream->loop, req->error);
req->cb(req, req->error ? -1 : 0);
}
}
@ -167,7 +167,7 @@ void uv__server_io(EV_P_ ev_io* watcher, int revents) {
/* TODO special trick. unlock reserved socket, accept, close. */
return;
} else {
uv_err_new(stream->loop, errno);
uv__set_sys_error(stream->loop, errno);
stream->connection_cb((uv_stream_t*)stream, -1);
}
} else {
@ -199,7 +199,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) {
streamClient = (uv_stream_t*)client;
if (streamServer->accepted_fd < 0) {
uv_err_new(server->loop, EAGAIN);
uv__set_sys_error(server->loop, EAGAIN);
goto out;
}
@ -272,12 +272,12 @@ static void uv__drain(uv_stream_t* stream) {
if (shutdown(stream->fd, SHUT_WR)) {
/* Error. Report it. User should call uv_close(). */
uv_err_new(stream->loop, errno);
uv__set_sys_error(stream->loop, errno);
if (req->cb) {
req->cb(req, -1);
}
} else {
uv_err_new(stream->loop, 0);
uv__set_sys_error(stream->loop, 0);
((uv_handle_t*) stream)->flags |= UV_SHUT;
if (req->cb) {
req->cb(req, 0);
@ -428,7 +428,7 @@ static void uv__write_callbacks(uv_stream_t* stream) {
/* NOTE: call callback AFTER freeing the request data. */
if (req->cb) {
uv_err_new_artificial(stream->loop, req->error);
uv__set_artificial_error(stream->loop, req->error);
req->cb(req, req->error ? -1 : 0);
}
@ -472,19 +472,19 @@ static void uv__read(uv_stream_t* stream) {
if (stream->flags & UV_READING) {
ev_io_start(ev, &stream->read_watcher);
}
uv_err_new(stream->loop, EAGAIN);
uv__set_sys_error(stream->loop, EAGAIN);
stream->read_cb(stream, 0, buf);
return;
} else {
/* Error. User should call uv_close(). */
uv_err_new(stream->loop, errno);
uv__set_sys_error(stream->loop, errno);
stream->read_cb(stream, -1, buf);
assert(!ev_is_active(&stream->read_watcher));
return;
}
} else if (nread == 0) {
/* EOF */
uv_err_new_artificial(stream->loop, UV_EOF);
uv__set_artificial_error(stream->loop, UV_EOF);
ev_io_stop(ev, &stream->read_watcher);
stream->read_cb(stream, -1, buf);
return;
@ -505,7 +505,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) {
stream->flags & UV_SHUT ||
stream->flags & UV_CLOSED ||
stream->flags & UV_CLOSING) {
uv_err_new(stream->loop, EINVAL);
uv__set_sys_error(stream->loop, EINVAL);
return -1;
}
@ -593,7 +593,7 @@ static void uv__stream_connect(uv_stream_t* stream) {
return;
} else {
/* Error */
uv_err_new(stream->loop, error);
uv__set_sys_error(stream->loop, error);
stream->connect_req = NULL;
if (req->cb) {
@ -610,7 +610,7 @@ int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
if (stream->fd <= 0) {
if ((sockfd = uv__socket(addr->sa_family, SOCK_STREAM, 0)) == -1) {
uv_err_new(stream->loop, errno);
uv__set_sys_error(stream->loop, errno);
return -1;
}
@ -627,12 +627,12 @@ int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
ngx_queue_init(&req->queue);
if (stream->connect_req) {
uv_err_new(stream->loop, EALREADY);
uv__set_sys_error(stream->loop, EALREADY);
return -1;
}
if (stream->type != UV_TCP) {
uv_err_new(stream->loop, ENOTSOCK);
uv__set_sys_error(stream->loop, ENOTSOCK);
return -1;
}
@ -656,7 +656,7 @@ int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
break;
default:
uv_err_new(stream->loop, errno);
uv__set_sys_error(stream->loop, errno);
return -1;
}
}
@ -684,7 +684,7 @@ int uv_write(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt,
"uv_write (unix) does not yet support other types of streams");
if (stream->fd < 0) {
uv_err_new(stream->loop, EBADF);
uv__set_sys_error(stream->loop, EBADF);
return -1;
}
@ -742,7 +742,7 @@ int uv_read_start(uv_stream_t* stream, uv_alloc_cb alloc_cb, uv_read_cb read_cb)
stream->type == UV_TTY);
if (stream->flags & UV_CLOSING) {
uv_err_new(stream->loop, EINVAL);
uv__set_sys_error(stream->loop, EINVAL);
return -1;
}

2
deps/uv/src/unix/sunos.c

@ -67,7 +67,7 @@ int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv_err_new(loop, ENOSYS);
uv__set_sys_error(loop, ENOSYS);
return -1;
}

56
deps/uv/src/unix/tcp.c

@ -45,7 +45,7 @@ static int uv__tcp_bind(uv_tcp_t* tcp,
if (tcp->fd < 0) {
if ((tcp->fd = uv__socket(domain, SOCK_STREAM, 0)) == -1) {
uv_err_new(tcp->loop, errno);
uv__set_sys_error(tcp->loop, errno);
goto out;
}
@ -64,7 +64,7 @@ static int uv__tcp_bind(uv_tcp_t* tcp,
if (errno == EADDRINUSE) {
tcp->delayed_error = errno;
} else {
uv_err_new(tcp->loop, errno);
uv__set_sys_error(tcp->loop, errno);
goto out;
}
}
@ -76,26 +76,26 @@ out:
}
int uv_tcp_bind(uv_tcp_t* tcp, struct sockaddr_in addr) {
if (addr.sin_family != AF_INET) {
uv_err_new(tcp->loop, EFAULT);
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
if (handle->type != UV_TCP || addr.sin_family != AF_INET) {
uv__set_sys_error(handle->loop, EFAULT);
return -1;
}
return uv__tcp_bind(tcp,
return uv__tcp_bind(handle,
AF_INET,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in));
}
int uv_tcp_bind6(uv_tcp_t* tcp, struct sockaddr_in6 addr) {
if (addr.sin6_family != AF_INET6) {
uv_err_new(tcp->loop, EFAULT);
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
if (handle->type != UV_TCP || addr.sin6_family != AF_INET6) {
uv__set_sys_error(handle->loop, EFAULT);
return -1;
}
return uv__tcp_bind(tcp,
return uv__tcp_bind(handle,
AF_INET6,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in6));
@ -112,13 +112,13 @@ int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
saved_errno = errno;
if (handle->delayed_error) {
uv_err_new(handle->loop, handle->delayed_error);
uv__set_sys_error(handle->loop, handle->delayed_error);
rv = -1;
goto out;
}
if (handle->fd < 0) {
uv_err_new(handle->loop, EINVAL);
uv__set_sys_error(handle->loop, EINVAL);
rv = -1;
goto out;
}
@ -127,7 +127,7 @@ int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
socklen = (socklen_t)*namelen;
if (getsockname(handle->fd, name, &socklen) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
rv = -1;
} else {
*namelen = (int)socklen;
@ -149,13 +149,13 @@ int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
saved_errno = errno;
if (handle->delayed_error) {
uv_err_new(handle->loop, handle->delayed_error);
uv__set_sys_error(handle->loop, handle->delayed_error);
rv = -1;
goto out;
}
if (handle->fd < 0) {
uv_err_new(handle->loop, EINVAL);
uv__set_sys_error(handle->loop, EINVAL);
rv = -1;
goto out;
}
@ -164,7 +164,7 @@ int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
socklen = (socklen_t)*namelen;
if (getpeername(handle->fd, name, &socklen) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
rv = -1;
} else {
*namelen = (int)socklen;
@ -180,13 +180,13 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
int r;
if (tcp->delayed_error) {
uv_err_new(tcp->loop, tcp->delayed_error);
uv__set_sys_error(tcp->loop, tcp->delayed_error);
return -1;
}
if (tcp->fd < 0) {
if ((tcp->fd = uv__socket(AF_INET, SOCK_STREAM, 0)) == -1) {
uv_err_new(tcp->loop, errno);
uv__set_sys_error(tcp->loop, errno);
return -1;
}
@ -201,7 +201,7 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
r = listen(tcp->fd, backlog);
if (r < 0) {
uv_err_new(tcp->loop, errno);
uv__set_sys_error(tcp->loop, errno);
return -1;
}
@ -226,13 +226,8 @@ int uv_tcp_connect(uv_connect_t* req,
saved_errno = errno;
status = -1;
if (handle->type != UV_TCP) {
uv_err_new(handle->loop, EINVAL);
goto out;
}
if (address.sin_family != AF_INET) {
uv_err_new(handle->loop, EINVAL);
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv__set_sys_error(handle->loop, EINVAL);
goto out;
}
@ -258,13 +253,8 @@ int uv_tcp_connect6(uv_connect_t* req,
saved_errno = errno;
status = -1;
if (handle->type != UV_TCP) {
uv_err_new(handle->loop, EINVAL);
goto out;
}
if (address.sin6_family != AF_INET6) {
uv_err_new(handle->loop, EINVAL);
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv__set_sys_error(handle->loop, EINVAL);
goto out;
}

80
deps/uv/src/unix/tty.c

@ -29,43 +29,66 @@
#include <sys/ioctl.h>
static int orig_termios_fd = -1;
static struct termios orig_termios;
int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd) {
uv__nonblock(fd, 1);
uv__stream_init(loop, (uv_stream_t*)tty, UV_TTY);
uv__stream_open((uv_stream_t*)tty, fd, UV_READABLE | UV_WRITABLE);
loop->counters.tty_init++;
tty->mode = 0;
return 0;
}
int uv_tty_set_mode(uv_tty_t* tty, int mode) {
int fd = tty->fd;
struct termios orig_termios; /* in order to restore at exit */
struct termios raw;
if (tcgetattr(fd, &orig_termios) == -1) goto fatal;
raw = orig_termios; /* modify the original mode */
/* input modes: no break, no CR to NL, no parity check, no strip char,
* no start/stop output control. */
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
/* output modes */
raw.c_oflag |= (ONLCR);
/* control modes - set 8 bit chars */
raw.c_cflag |= (CS8);
/* local modes - echoing off, canonical off, no extended functions,
* no signal chars (^Z,^C) */
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
/* control chars - set return condition: min number of bytes and timer.
* We want read to return every single byte, without timeout. */
raw.c_cc[VMIN] = 1; raw.c_cc[VTIME] = 0; /* 1 byte, no timer */
/* put terminal in raw mode after flushing */
if (tcsetattr(fd, TCSAFLUSH, &raw) < 0) goto fatal;
return 0;
if (mode && tty->mode == 0) {
/* on */
if (tcgetattr(fd, &tty->orig_termios)) {
goto fatal;
}
/* This is used for uv_tty_reset_mode() */
if (orig_termios_fd == -1) {
orig_termios = tty->orig_termios;
orig_termios_fd = fd;
}
raw = tty->orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag |= (ONLCR);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
raw.c_cc[VMIN] = 1;
raw.c_cc[VTIME] = 0;
/* Put terminal in raw mode after flushing */
if (tcsetattr(fd, TCSAFLUSH, &raw)) {
goto fatal;
}
tty->mode = 1;
return 0;
} else if (mode == 0 && tty->mode) {
/* off */
/* Put terminal in original mode after flushing */
if (tcsetattr(fd, TCSAFLUSH, &tty->orig_termios)) {
goto fatal;
}
tty->mode = 0;
return 0;
}
fatal:
uv_err_new(tty->loop, ENOTTY);
uv__set_sys_error(tty->loop, errno);
return -1;
}
@ -74,7 +97,7 @@ int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
struct winsize ws;
if (ioctl(tty->fd, TIOCGWINSZ, &ws) < 0) {
uv_err_new(tty->loop, errno);
uv__set_sys_error(tty->loop, errno);
return -1;
}
@ -89,7 +112,7 @@ uv_handle_type uv_guess_handle(uv_file file) {
struct stat s;
if (file < 0) {
uv_err_new(NULL, EINVAL); /* XXX Need loop? */
uv__set_sys_error(NULL, EINVAL); /* XXX Need loop? */
return -1;
}
@ -98,7 +121,7 @@ uv_handle_type uv_guess_handle(uv_file file) {
}
if (fstat(file, &s)) {
uv_err_new(NULL, errno); /* XXX Need loop? */
uv__set_sys_error(NULL, errno); /* XXX Need loop? */
return -1;
}
@ -108,3 +131,10 @@ uv_handle_type uv_guess_handle(uv_file file) {
return UV_NAMED_PIPE;
}
void uv_tty_reset_mode() {
if (orig_termios_fd >= 0) {
tcsetattr(orig_termios_fd, TCSANOW, &orig_termios);
}
}

42
deps/uv/src/unix/udp.c

@ -84,7 +84,7 @@ void uv__udp_destroy(uv_udp_t* handle) {
req = ngx_queue_data(q, uv_udp_send_t, queue);
if (req->send_cb) {
/* FIXME proper error code like UV_EABORTED */
uv_err_new_artificial(handle->loop, UV_EINTR);
uv__set_artificial_error(handle->loop, UV_EINTR);
req->send_cb(req, -1);
}
}
@ -187,7 +187,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) {
req->send_cb(req, 0);
}
else {
uv_err_new(handle->loop, -req->status);
uv__set_sys_error(handle->loop, -req->status);
req->send_cb(req, -1);
}
}
@ -223,11 +223,11 @@ static void uv__udp_recvmsg(uv_udp_t* handle) {
if (nread == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
uv_err_new(handle->loop, EAGAIN);
uv__set_sys_error(handle->loop, EAGAIN);
handle->recv_cb(handle, 0, buf, NULL, 0);
}
else {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
handle->recv_cb(handle, -1, buf, NULL, 0);
}
}
@ -305,24 +305,24 @@ static int uv__udp_bind(uv_udp_t* handle,
/* Check for bad flags. */
if (flags & ~UV_UDP_IPV6ONLY) {
uv_err_new(handle->loop, EINVAL);
uv__set_sys_error(handle->loop, EINVAL);
goto out;
}
/* Cannot set IPv6-only mode on non-IPv6 socket. */
if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) {
uv_err_new(handle->loop, EINVAL);
uv__set_sys_error(handle->loop, EINVAL);
goto out;
}
/* Check for already active socket. */
if (handle->fd != -1) {
uv_err_new_artificial(handle->loop, UV_EALREADY);
uv__set_artificial_error(handle->loop, UV_EALREADY);
goto out;
}
if ((fd = uv__socket(domain, SOCK_DGRAM, 0)) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
goto out;
}
@ -330,17 +330,17 @@ static int uv__udp_bind(uv_udp_t* handle,
#ifdef IPV6_V6ONLY
yes = 1;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof yes) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
goto out;
}
#else
uv_err_new((uv_handle_t*)handle, ENOTSUP);
uv__set_sys_error((uv_handle_t*)handle, ENOTSUP);
goto out;
#endif
}
if (bind(fd, addr, len) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
goto out;
}
@ -417,7 +417,7 @@ static int uv__udp_send(uv_udp_send_t* req,
req->bufs = req->bufsml;
}
else if ((req->bufs = malloc(bufcnt * sizeof(bufs[0]))) == NULL) {
uv_err_new(handle->loop, ENOMEM);
uv__set_sys_error(handle->loop, ENOMEM);
return -1;
}
memcpy(req->bufs, bufs, bufcnt * sizeof(bufs[0]));
@ -444,6 +444,11 @@ int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned flags) {
if (handle->type != UV_UDP || addr.sin_family != AF_INET) {
uv__set_sys_error(handle->loop, EFAULT);
return -1;
}
return uv__udp_bind(handle,
AF_INET,
(struct sockaddr*)&addr,
@ -453,6 +458,11 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned flags) {
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags) {
if (handle->type != UV_UDP || addr.sin6_family != AF_INET6) {
uv__set_sys_error(handle->loop, EFAULT);
return -1;
}
return uv__udp_bind(handle,
AF_INET6,
(struct sockaddr*)&addr,
@ -471,7 +481,7 @@ int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
saved_errno = errno;
if (handle->fd < 0) {
uv_err_new(handle->loop, EINVAL);
uv__set_sys_error(handle->loop, EINVAL);
rv = -1;
goto out;
}
@ -480,7 +490,7 @@ int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
socklen = (socklen_t)*namelen;
if (getsockname(handle->fd, name, &socklen) == -1) {
uv_err_new(handle->loop, errno);
uv__set_sys_error(handle->loop, errno);
rv = -1;
} else {
*namelen = (int)socklen;
@ -528,12 +538,12 @@ int uv_udp_recv_start(uv_udp_t* handle,
uv_alloc_cb alloc_cb,
uv_udp_recv_cb recv_cb) {
if (alloc_cb == NULL || recv_cb == NULL) {
uv_err_new_artificial(handle->loop, UV_EINVAL);
uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
if (ev_is_active(&handle->read_watcher)) {
uv_err_new_artificial(handle->loop, UV_EALREADY);
uv__set_artificial_error(handle->loop, UV_EALREADY);
return -1;
}

23
deps/uv/src/uv-common.c

@ -95,6 +95,29 @@ const char* uv_err_name(uv_err_t err) {
}
void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error) {
loop->last_err.code = code;
loop->last_err.sys_errno_ = sys_error;
}
void uv__set_sys_error(uv_loop_t* loop, int sys_error) {
loop->last_err.code = uv_translate_sys_error(sys_error);
loop->last_err.sys_errno_ = sys_error;
}
void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code) {
loop->last_err.code = code;
loop->last_err.sys_errno_ = 0;
}
uv_err_t uv_last_error(uv_loop_t* loop) {
return loop->last_err;
}
struct sockaddr_in uv_ip4_addr(const char* ip, int port) {
struct sockaddr_in addr;

4
deps/uv/src/uv-common.h

@ -48,5 +48,9 @@ void uv_add_ares_handle(uv_loop_t* loop, uv_ares_task_t* handle);
int uv_ares_handles_empty(uv_loop_t* loop);
uv_err_code uv_translate_sys_error(int sys_errno);
void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error);
void uv__set_sys_error(uv_loop_t* loop, int sys_error);
void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code);
#endif /* UV_COMMON_H_ */

2
deps/uv/src/win/core.c

@ -82,7 +82,7 @@ static void uv_loop_init(uv_loop_t* loop) {
loop->ares_active_sockets = 0;
loop->ares_chan = NULL;
loop->last_error = uv_ok_;
loop->last_err = uv_ok_;
}

24
deps/uv/src/win/error.c

@ -67,11 +67,6 @@ void uv_fatal_error(const int errorno, const char* syscall) {
}
uv_err_t uv_last_error(uv_loop_t* loop) {
return loop->last_error;
}
/* TODO: thread safety */
static char* last_err_str_ = NULL;
@ -136,22 +131,3 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
}
}
uv_err_t uv_new_sys_error(int sys_errno) {
uv_err_t e;
e.code = uv_translate_sys_error(sys_errno);
e.sys_errno_ = sys_errno;
return e;
}
void uv_set_sys_error(uv_loop_t* loop, int sys_errno) {
loop->last_error.code = uv_translate_sys_error(sys_errno);
loop->last_error.sys_errno_ = sys_errno;
}
void uv_set_error(uv_loop_t* loop, uv_err_code code, int sys_errno) {
loop->last_error.code = code;
loop->last_error.sys_errno_ = sys_errno;
}

6
deps/uv/src/win/fs-event.c

@ -144,7 +144,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
if (!uv_utf8_to_utf16(filename, filenamew,
name_size / sizeof(wchar_t))) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -252,7 +252,7 @@ error:
handle->buffer = NULL;
}
uv_set_sys_error(loop, last_error);
uv__set_sys_error(loop, last_error);
return -1;
}
@ -330,7 +330,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
handle->cb(handle, NULL, UV_CHANGE, 0);
}
} else {
loop->last_error = GET_REQ_UV_ERROR(req);
uv__set_sys_error(loop, GET_REQ_ERROR(req));
handle->cb(handle, NULL, 0, -1);
}

26
deps/uv/src/win/fs.c

@ -66,7 +66,7 @@
if (!QueueUserWorkItem(&uv_fs_thread_proc, \
req, \
WT_EXECUTELONGFUNCTION)) { \
uv_set_sys_error((loop), GetLastError()); \
uv__set_sys_error((loop), GetLastError()); \
return -1; \
} \
req->flags |= UV_FS_ASYNC_QUEUED; \
@ -75,7 +75,9 @@
#define SET_UV_LAST_ERROR_FROM_REQ(req) \
if (req->flags & UV_FS_LAST_ERROR_SET) { \
uv_set_sys_error(req->loop, req->last_error); \
uv__set_sys_error(req->loop, req->last_error); \
} else if (req->result == -1) { \
uv__set_error(req->loop, (uv_err_code)req->errorno, req->last_error); \
}
#define SET_REQ_LAST_ERROR(req, error) \
@ -85,7 +87,8 @@
#define SET_REQ_RESULT(req, result_value) \
req->result = (result_value); \
if (req->result == -1) { \
req->errorno = uv_translate_sys_error(_doserrno); \
req->last_error = _doserrno; \
req->errorno = uv_translate_sys_error(req->last_error); \
}
#define SET_REQ_RESULT_WIN32_ERROR(req, sys_errno) \
@ -576,11 +579,14 @@ void fs__symlink(uv_fs_t* req, const char* path, const char* new_path,
path,
flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
if (result == -1) {
SET_REQ_LAST_ERROR(req, GetLastError());
SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
return;
}
} else {
result = -1;
errno = ENOSYS;
req->result = -1;
req->errorno = UV_ENOTSUP;
req->last_error = ERROR_SUCCESS;
return;
}
SET_REQ_RESULT(req, result);
@ -1016,9 +1022,9 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid,
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
int len = strlen(path);
char* path2 = NULL;
int has_backslash = (path[len - 1] == '\\' || path[len - 1] == '/');
if (path[len - 1] == '\\' || path[len - 1] == '/') {
if (len > 1 && path[len - 2] != ':' &&
(path[len - 1] == '\\' || path[len - 1] == '/')) {
path2 = strdup(path);
if (!path2) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
@ -1054,9 +1060,9 @@ int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
int len = strlen(path);
char* path2 = NULL;
int has_backslash = (path[len - 1] == '\\' || path[len - 1] == '/');
if (path[len - 1] == '\\' || path[len - 1] == '/') {
if (len > 1 && path[len - 2] != ':' &&
(path[len - 1] == '\\' || path[len - 1] == '/')) {
path2 = strdup(path);
if (!path2) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");

14
deps/uv/src/win/getaddrinfo.c

@ -256,7 +256,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (handle == NULL || getaddrinfo_cb == NULL ||
(node == NULL && service == NULL)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
goto error;
}
@ -271,7 +271,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (node != NULL) {
nodesize = ALIGNED_SIZE(uv_utf8_to_utf16(node, NULL, 0) * sizeof(wchar_t));
if (nodesize == 0) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
goto error;
}
}
@ -280,7 +280,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
servicesize = ALIGNED_SIZE(uv_utf8_to_utf16(service, NULL, 0) *
sizeof(wchar_t));
if (servicesize == 0) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
goto error;
}
}
@ -291,7 +291,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
/* allocate memory for inputs, and partition it as needed */
alloc_ptr = (char*)malloc(nodesize + servicesize + hintssize);
if (!alloc_ptr) {
uv_set_sys_error(loop, WSAENOBUFS);
uv__set_sys_error(loop, WSAENOBUFS);
goto error;
}
@ -305,7 +305,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (uv_utf8_to_utf16(node,
(wchar_t*) alloc_ptr,
nodesize / sizeof(wchar_t)) == 0) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
goto error;
}
alloc_ptr += nodesize;
@ -320,7 +320,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (uv_utf8_to_utf16(service,
(wchar_t*) alloc_ptr,
servicesize / sizeof(wchar_t)) == 0) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
goto error;
}
alloc_ptr += servicesize;
@ -352,7 +352,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (QueueUserWorkItem(&getaddrinfo_thread_proc,
handle,
WT_EXECUTELONGFUNCTION) == 0) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
goto error;
}

9
deps/uv/src/win/internal.h

@ -275,9 +275,6 @@ extern const uv_err_t uv_ok_;
void uv_fatal_error(const int errorno, const char* syscall);
uv_err_code uv_translate_sys_error(int sys_errno);
uv_err_t uv_new_sys_error(int sys_errno);
void uv_set_sys_error(uv_loop_t* loop, int sys_errno);
void uv_set_error(uv_loop_t* loop, uv_err_code code, int sys_errno);
#define SET_REQ_STATUS(req, status) \
(req)->overlapped.Internal = (ULONG_PTR) (status)
@ -300,12 +297,6 @@ void uv_set_error(uv_loop_t* loop, uv_err_code code, int sys_errno);
#define GET_REQ_SOCK_ERROR(req) \
(uv_ntstatus_to_winsock_error(GET_REQ_STATUS((req))))
#define GET_REQ_UV_ERROR(req) \
(uv_new_sys_error(GET_REQ_ERROR((req))))
#define GET_REQ_UV_SOCK_ERROR(req) \
(uv_new_sys_error(GET_REQ_SOCK_ERROR((req))))
/*
* Initialization for the windows and winsock api

56
deps/uv/src/win/pipe.c

@ -111,7 +111,7 @@ int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access,
errno = GetLastError();
if (errno != ERROR_PIPE_BUSY && errno != ERROR_ACCESS_DENIED) {
uv_set_sys_error(loop, errno);
uv__set_sys_error(loop, errno);
err = -1;
goto done;
}
@ -124,7 +124,7 @@ int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access,
loop->iocp,
(ULONG_PTR)handle,
0) == NULL) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
err = -1;
goto done;
}
@ -209,7 +209,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
/* Failure */
handle->flags &= ~UV_HANDLE_SHUTTING;
if (req->cb) {
uv_set_sys_error(loop, pRtlNtStatusToDosError(nt_status));
uv__set_sys_error(loop, pRtlNtStatusToDosError(nt_status));
req->cb(req, -1);
}
DECREASE_PENDING_REQ_COUNT(handle);
@ -237,7 +237,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
/* Failure. */
handle->flags &= ~UV_HANDLE_SHUTTING;
if (req->cb) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
req->cb(req, -1);
}
DECREASE_PENDING_REQ_COUNT(handle);
@ -274,12 +274,12 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
uv_pipe_accept_t* req;
if (handle->flags & UV_HANDLE_BOUND) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
if (!name) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
@ -300,7 +300,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
}
if (!uv_utf8_to_utf16(name, handle->name, nameSize / sizeof(wchar_t))) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -317,17 +317,17 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
if (handle->accept_reqs[0].pipeHandle == INVALID_HANDLE_VALUE) {
errno = GetLastError();
if (errno == ERROR_ACCESS_DENIED) {
uv_set_error(loop, UV_EADDRINUSE, errno);
uv__set_error(loop, UV_EADDRINUSE, errno);
} else if (errno == ERROR_PATH_NOT_FOUND || errno == ERROR_INVALID_NAME) {
uv_set_error(loop, UV_EACCESS, errno);
uv__set_error(loop, UV_EACCESS, errno);
} else {
uv_set_sys_error(loop, errno);
uv__set_sys_error(loop, errno);
}
goto error;
}
if (uv_set_pipe_handle(loop, handle, handle->accept_reqs[0].pipeHandle)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
goto error;
}
@ -473,7 +473,7 @@ error:
if (pipeHandle != INVALID_HANDLE_VALUE) {
CloseHandle(pipeHandle);
}
uv_set_sys_error(loop, errno);
uv__set_sys_error(loop, errno);
return -1;
}
@ -575,7 +575,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) {
if (!req) {
/* No valid connections found, so we error out. */
uv_set_sys_error(loop, WSAEWOULDBLOCK);
uv__set_sys_error(loop, WSAEWOULDBLOCK);
return -1;
}
@ -607,19 +607,19 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
if (!(handle->flags & UV_HANDLE_BOUND) &&
!(handle->flags & UV_HANDLE_GIVEN_OS_HANDLE)) {
uv_set_error(loop, UV_EINVAL, 0);
uv__set_artificial_error(loop, UV_EINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_LISTENING ||
handle->flags & UV_HANDLE_READING) {
uv_set_error(loop, UV_EALREADY, 0);
uv__set_artificial_error(loop, UV_EALREADY);
return -1;
}
if (!(handle->flags & UV_HANDLE_PIPESERVER) &&
!(handle->flags & UV_HANDLE_GIVEN_OS_HANDLE)) {
uv_set_error(loop, UV_ENOTSUP, 0);
uv__set_artificial_error(loop, UV_ENOTSUP);
return -1;
}
@ -638,7 +638,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
req->next_pending = NULL;
if (uv_set_pipe_handle(loop, handle, pipeHandle)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -698,17 +698,17 @@ int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
uv_loop_t* loop = handle->loop;
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
uv_set_error(loop, UV_EINVAL, 0);
uv__set_artificial_error(loop, UV_EINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_READING) {
uv_set_error(loop, UV_EALREADY, 0);
uv__set_artificial_error(loop, UV_EALREADY);
return -1;
}
if (handle->flags & UV_HANDLE_EOF) {
uv_set_error(loop, UV_EOF, 0);
uv__set_artificial_error(loop, UV_EOF);
return -1;
}
@ -730,19 +730,19 @@ int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
int result;
if (bufcnt != 1) {
uv_set_error(loop, UV_ENOTSUP, 0);
uv__set_artificial_error(loop, UV_ENOTSUP);
return -1;
}
assert(handle->handle != INVALID_HANDLE_VALUE);
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
uv_set_error(loop, UV_EINVAL, 0);
uv__set_artificial_error(loop, UV_EINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_SHUTTING) {
uv_set_error(loop, UV_EOF, 0);
uv__set_artificial_error(loop, UV_EOF);
return -1;
}
@ -759,7 +759,7 @@ int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
&req->overlapped);
if (!result && GetLastError() != ERROR_IO_PENDING) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -788,7 +788,7 @@ static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
handle->flags |= UV_HANDLE_EOF;
uv_read_stop((uv_stream_t*) handle);
uv_set_error(loop, UV_EOF, 0);
uv__set_artificial_error(loop, UV_EOF);
handle->read_cb((uv_stream_t*) handle, -1, uv_null_buf_);
}
@ -801,7 +801,7 @@ static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error,
uv_read_stop((uv_stream_t*) handle);
uv_set_sys_error(loop, error);
uv__set_sys_error(loop, error);
handle->read_cb((uv_stream_t*)handle, -1, buf);
}
@ -891,7 +891,7 @@ void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
if (req->cb) {
if (!REQ_SUCCESS(req)) {
loop->last_error = GET_REQ_UV_ERROR(req);
uv__set_sys_error(loop, GET_REQ_ERROR(req));
((uv_write_cb)req->cb)(req, -1);
} else {
((uv_write_cb)req->cb)(req, 0);
@ -946,7 +946,7 @@ void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle,
uv_pipe_connection_init(handle);
((uv_connect_cb)req->cb)(req, 0);
} else {
loop->last_error = GET_REQ_UV_ERROR(req);
uv__set_sys_error(loop, GET_REQ_ERROR(req));
((uv_connect_cb)req->cb)(req, -1);
}
}

18
deps/uv/src/win/process.c

@ -45,7 +45,7 @@ typedef struct env_var {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); \
} \
if (!uv_utf8_to_utf16(s, t, size / sizeof(wchar_t))) { \
uv_set_sys_error(loop, GetLastError()); \
uv__set_sys_error(loop, GetLastError()); \
err = -1; \
goto done; \
}
@ -746,7 +746,7 @@ static int uv_create_stdio_pipe_pair(uv_loop_t* loop, uv_pipe_t* server_pipe,
DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
if (server_pipe->type != UV_NAMED_PIPE) {
uv_set_error(loop, UV_EINVAL, 0);
uv__set_artificial_error(loop, UV_EINVAL);
err = -1;
goto done;
}
@ -771,13 +771,13 @@ static int uv_create_stdio_pipe_pair(uv_loop_t* loop, uv_pipe_t* server_pipe,
NULL);
if (*child_pipe == INVALID_HANDLE_VALUE) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
err = -1;
goto done;
}
if (!SetNamedPipeHandleState(*child_pipe, &mode, NULL, NULL)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
err = -1;
goto done;
}
@ -787,7 +787,7 @@ static int uv_create_stdio_pipe_pair(uv_loop_t* loop, uv_pipe_t* server_pipe,
*/
if (!ConnectNamedPipe(server_pipe->handle, NULL)) {
if (GetLastError() != ERROR_PIPE_CONNECTED) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
err = -1;
goto done;
}
@ -822,7 +822,7 @@ static int duplicate_std_handle(uv_loop_t* loop, DWORD id, HANDLE* dup) {
return 0;
} else if (handle == INVALID_HANDLE_VALUE) {
*dup = INVALID_HANDLE_VALUE;
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -834,7 +834,7 @@ static int duplicate_std_handle(uv_loop_t* loop, DWORD id, HANDLE* dup) {
TRUE,
DUPLICATE_SAME_ACCESS)) {
*dup = INVALID_HANDLE_VALUE;
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -854,7 +854,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
PROCESS_INFORMATION info;
if (!options.file) {
uv_set_error(loop, UV_EINVAL, 0);
uv__set_artificial_error(loop, UV_EINVAL);
return -1;
}
@ -877,7 +877,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
}
GetCurrentDirectoryW(size, cwd);
} else {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
err = -1;
goto done;
}

2
deps/uv/src/win/stdio.c

@ -69,7 +69,7 @@ uv_stream_t* uv_std_handle(uv_loop_t* loop, uv_std_type type) {
default:
assert(0);
uv_set_error(loop, UV_EINVAL, 0);
uv__set_artificial_error(loop, UV_EINVAL);
return NULL;
}
}

8
deps/uv/src/win/stream.c

@ -93,7 +93,7 @@ int uv_read_start(uv_stream_t* handle, uv_alloc_cb alloc_cb,
int uv_read_stop(uv_stream_t* handle) {
if (handle->type = UV_TTY) {
if (handle->type == UV_TTY) {
return uv_tty_read_stop((uv_tty_t*) handle);
} else {
handle->flags &= ~UV_HANDLE_READING;
@ -115,7 +115,7 @@ int uv_write(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt,
return uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, bufcnt, cb);
default:
assert(0);
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
}
@ -125,12 +125,12 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) {
uv_loop_t* loop = handle->loop;
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_SHUTTING) {
uv_set_sys_error(loop, WSAESHUTDOWN);
uv__set_sys_error(loop, WSAESHUTDOWN);
return -1;
}

104
deps/uv/src/win/tcp.c

@ -54,13 +54,13 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
/* Set the socket to nonblocking mode */
if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
/* Make the socket non-inheritable */
if (!SetHandleInformation((HANDLE)socket, HANDLE_FLAG_INHERIT, 0)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -70,7 +70,7 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
loop->iocp,
(ULONG_PTR)socket,
0) == NULL) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -80,7 +80,7 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
} else if (GetLastError() != ERROR_INVALID_FUNCTION) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
}
@ -107,8 +107,8 @@ int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* handle) {
void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
uv_err_t err;
int status;
int sys_error;
if (handle->flags & UV_HANDLE_CONNECTION &&
handle->flags & UV_HANDLE_SHUTTING &&
@ -120,11 +120,11 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
handle->flags |= UV_HANDLE_SHUT;
} else {
status = -1;
err = uv_new_sys_error(WSAGetLastError());
sys_error = WSAGetLastError();
}
if (handle->shutdown_req->cb) {
if (status == -1) {
loop->last_error = err;
uv__set_sys_error(loop, sys_error);
}
handle->shutdown_req->cb(handle->shutdown_req, status);
}
@ -163,7 +163,7 @@ static int uv__bind(uv_loop_t* loop, uv_tcp_t* handle, int domain,
if (handle->socket == INVALID_SOCKET) {
sock = socket(domain, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -179,10 +179,10 @@ static int uv__bind(uv_loop_t* loop, uv_tcp_t* handle, int domain,
err = WSAGetLastError();
if (err == WSAEADDRINUSE) {
/* Some errors are not to be reported until connect() or listen() */
handle->bind_error = uv_new_sys_error(err);
handle->bind_error = err;
handle->flags |= UV_HANDLE_BIND_ERROR;
} else {
uv_set_sys_error(loop, err);
uv__set_sys_error(loop, err);
return -1;
}
}
@ -196,8 +196,8 @@ static int uv__bind(uv_loop_t* loop, uv_tcp_t* handle, int domain,
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
uv_loop_t* loop = handle->loop;
if (addr.sin_family != AF_INET) {
uv_set_sys_error(loop, WSAEFAULT);
if (handle->type != UV_TCP || addr.sin_family != AF_INET) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
@ -212,8 +212,8 @@ int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
uv_loop_t* loop = handle->loop;
if (addr.sin6_family != AF_INET6) {
uv_set_sys_error(loop, WSAEFAULT);
if (handle->type != UV_TCP || addr.sin6_family != AF_INET6) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
@ -226,7 +226,7 @@ int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
sizeof(struct sockaddr_in6));
} else {
uv_set_sys_error(loop, WSAEAFNOSUPPORT);
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
return -1;
}
}
@ -356,14 +356,14 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
assert(backlog > 0);
if (handle->flags & UV_HANDLE_BIND_ERROR) {
loop->last_error = handle->bind_error;
uv__set_sys_error(loop, handle->bind_error);
return -1;
}
if (handle->flags & UV_HANDLE_LISTENING ||
handle->flags & UV_HANDLE_READING) {
/* Already listening. */
uv_set_sys_error(loop, WSAEALREADY);
uv__set_sys_error(loop, WSAEALREADY);
return -1;
}
@ -372,7 +372,7 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
return -1;
if (listen(handle->socket, backlog) == SOCKET_ERROR) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -407,12 +407,12 @@ int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client) {
if (!req) {
/* No valid connections found, so we error out. */
uv_set_sys_error(loop, WSAEWOULDBLOCK);
uv__set_sys_error(loop, WSAEWOULDBLOCK);
return -1;
}
if (req->accept_socket == INVALID_SOCKET) {
uv_set_sys_error(loop, WSAENOTCONN);
uv__set_sys_error(loop, WSAENOTCONN);
return -1;
}
@ -445,17 +445,17 @@ int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
uv_loop_t* loop = handle->loop;
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_READING) {
uv_set_sys_error(loop, WSAEALREADY);
uv__set_sys_error(loop, WSAEALREADY);
return -1;
}
if (handle->flags & UV_HANDLE_EOF) {
uv_set_sys_error(loop, WSAESHUTDOWN);
uv__set_sys_error(loop, WSAESHUTDOWN);
return -1;
}
@ -480,12 +480,12 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
DWORD bytes;
if (handle->flags & UV_HANDLE_BIND_ERROR) {
loop->last_error = handle->bind_error;
uv__set_sys_error(loop, handle->bind_error);
return -1;
}
if (address.sin_family != AF_INET) {
uv_set_sys_error(loop, WSAEFAULT);
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
@ -515,7 +515,7 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
/* The req will be processed with IOCP. */
handle->reqs_pending++;
} else {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -531,17 +531,17 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
DWORD bytes;
if (!uv_allow_ipv6) {
uv_new_sys_error(WSAEAFNOSUPPORT);
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
return -1;
}
if (handle->flags & UV_HANDLE_BIND_ERROR) {
loop->last_error = handle->bind_error;
uv__set_sys_error(loop, handle->bind_error);
return -1;
}
if (address.sin6_family != AF_INET6) {
uv_set_sys_error(loop, WSAEFAULT);
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
@ -569,7 +569,7 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
} else if (UV_SUCCEEDED_WITH_IOCP(success)) {
handle->reqs_pending++;
} else {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -583,18 +583,18 @@ int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
int result;
if (!(handle->flags & UV_HANDLE_BOUND)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_BIND_ERROR) {
loop->last_error = handle->bind_error;
uv__set_sys_error(loop, handle->bind_error);
return -1;
}
result = getsockname(handle->socket, name, namelen);
if (result != 0) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -608,18 +608,18 @@ int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
int result;
if (!(handle->flags & UV_HANDLE_BOUND)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_BIND_ERROR) {
loop->last_error = handle->bind_error;
uv__set_sys_error(loop, handle->bind_error);
return -1;
}
result = getpeername(handle->socket, name, namelen);
if (result != 0) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -633,12 +633,12 @@ int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle,
DWORD bytes;
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
if (handle->flags & UV_HANDLE_SHUTTING) {
uv_set_sys_error(loop, WSAESHUTDOWN);
uv__set_sys_error(loop, WSAESHUTDOWN);
return -1;
}
@ -670,7 +670,7 @@ int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle,
handle->write_queue_size += req->queued_bytes;
} else {
/* Send failed due to an error. */
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -691,7 +691,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
/* An error occurred doing the read. */
if ((handle->flags & UV_HANDLE_READING)) {
handle->flags &= ~UV_HANDLE_READING;
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
uv_buf_init(NULL, 0) : handle->read_buffer;
handle->read_cb((uv_stream_t*)handle, -1, buf);
@ -712,8 +712,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
/* Connection closed */
handle->flags &= ~UV_HANDLE_READING;
handle->flags |= UV_HANDLE_EOF;
loop->last_error.code = UV_EOF;
loop->last_error.sys_errno_ = ERROR_SUCCESS;
uv__set_error(loop, UV_EOF, ERROR_SUCCESS);
buf.base = 0;
buf.len = 0;
handle->read_cb((uv_stream_t*)handle, -1, handle->read_buffer);
@ -744,8 +743,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
/* Connection closed */
handle->flags &= ~UV_HANDLE_READING;
handle->flags |= UV_HANDLE_EOF;
loop->last_error.code = UV_EOF;
loop->last_error.sys_errno_ = ERROR_SUCCESS;
uv__set_error(loop, UV_EOF, ERROR_SUCCESS);
handle->read_cb((uv_stream_t*)handle, -1, buf);
break;
}
@ -753,11 +751,11 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
/* Read buffer was completely empty, report a 0-byte read. */
uv_set_sys_error(loop, WSAEWOULDBLOCK);
uv__set_sys_error(loop, WSAEWOULDBLOCK);
handle->read_cb((uv_stream_t*)handle, 0, buf);
} else {
/* Ouch! serious error. */
uv_set_sys_error(loop, err);
uv__set_sys_error(loop, err);
handle->flags &= ~UV_HANDLE_READING;
handle->read_cb((uv_stream_t*)handle, -1, buf);
}
@ -784,8 +782,8 @@ void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle,
handle->write_queue_size -= req->queued_bytes;
if (req->cb) {
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
((uv_write_cb)req->cb)(req, loop->last_error.code == UV_OK ? 0 : -1);
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
((uv_write_cb)req->cb)(req, loop->last_err.code == UV_OK ? 0 : -1);
}
handle->write_reqs_pending--;
@ -812,7 +810,7 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
if (handle->flags & UV_HANDLE_LISTENING) {
handle->flags &= ~UV_HANDLE_LISTENING;
if (handle->connection_cb) {
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
handle->connection_cb((uv_stream_t*)handle, -1);
}
}
@ -859,11 +857,11 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
active_tcp_streams++;
((uv_connect_cb)req->cb)(req, 0);
} else {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
((uv_connect_cb)req->cb)(req, -1);
}
} else {
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
((uv_connect_cb)req->cb)(req, -1);
}
}

2
deps/uv/src/win/threadpool.c

@ -57,7 +57,7 @@ int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,
uv_work_req_init(loop, req, work_cb, after_work_cb);
if (!QueueUserWorkItem(&uv_work_thread_proc, req, WT_EXECUTELONGFUNCTION)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}

6
deps/uv/src/win/timer.c

@ -77,12 +77,12 @@ uint64_t uv_hrtime(void) {
/* If the performance frequency is zero, there's no support. */
if (!uv_hrtime_frequency_) {
/* uv_set_sys_error(loop, ERROR_NOT_SUPPORTED); */
/* uv__set_sys_error(loop, ERROR_NOT_SUPPORTED); */
return 0;
}
if (!QueryPerformanceCounter(&counter)) {
/* uv_set_sys_error(loop, GetLastError()); */
/* uv__set_sys_error(loop, GetLastError()); */
return 0;
}
@ -181,7 +181,7 @@ int uv_timer_again(uv_timer_t* handle) {
/* If timer_cb is NULL that means that the timer was never started. */
if (!handle->timer_cb) {
uv_set_sys_error(loop, ERROR_INVALID_DATA);
uv__set_sys_error(loop, ERROR_INVALID_DATA);
return -1;
}

36
deps/uv/src/win/tty.c

@ -92,12 +92,12 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd) {
win_handle = (HANDLE) _get_osfhandle(fd);
if (win_handle == INVALID_HANDLE_VALUE) {
uv_set_sys_error(loop, ERROR_INVALID_HANDLE);
uv__set_sys_error(loop, ERROR_INVALID_HANDLE);
return -1;
}
if (!GetConsoleMode(win_handle, &tty->original_console_mode)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -163,7 +163,7 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
}
if (!SetConsoleMode(tty->handle, flags)) {
uv_set_sys_error(tty->loop, GetLastError());
uv__set_sys_error(tty->loop, GetLastError());
return -1;
}
@ -203,7 +203,7 @@ int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
CONSOLE_SCREEN_BUFFER_INFO info;
if (!GetConsoleScreenBufferInfo(tty->handle, &info)) {
uv_set_sys_error(tty->loop, GetLastError());
uv__set_sys_error(tty->loop, GetLastError());
return -1;
}
@ -452,7 +452,7 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
/* An error occurred while waiting for the event. */
if ((handle->flags & UV_HANDLE_READING)) {
handle->flags &= ~UV_HANDLE_READING;
loop->last_error = GET_REQ_UV_ERROR(req);
uv__set_sys_error(loop, GET_REQ_ERROR(req));
handle->read_cb((uv_stream_t*)handle, -1, uv_null_buf_);
}
goto out;
@ -461,7 +461,7 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
/* Fetch the number of events */
if (!GetNumberOfConsoleInputEvents(handle->handle, &records_left)) {
handle->flags &= ~UV_HANDLE_READING;
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
handle->read_cb((uv_stream_t*)handle, -1, uv_null_buf_);
goto out;
}
@ -479,7 +479,7 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
&handle->last_input_record,
1,
&records_read)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
handle->flags &= ~UV_HANDLE_READING;
handle->read_cb((uv_stream_t*) handle, -1, buf);
goto out;
@ -579,7 +579,7 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
/* If the utf16 character(s) couldn't be converted something must */
/* be wrong. */
if (!char_len) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
handle->flags &= ~UV_HANDLE_READING;
handle->read_cb((uv_stream_t*) handle, -1, buf);
goto out;
@ -689,11 +689,11 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle,
!(handle->flags & UV_HANDLE_TTY_RAW)) {
/* Real error */
handle->flags &= ~UV_HANDLE_READING;
loop->last_error = GET_REQ_UV_ERROR(req);
uv__set_sys_error(loop, GET_REQ_ERROR(req));
handle->read_cb((uv_stream_t*) handle, -1, buf);
} else {
/* The read was cancelled, or whatever we don't care */
uv_set_sys_error(loop, WSAEWOULDBLOCK); /* maps to UV_EAGAIN */
uv__set_sys_error(loop, WSAEWOULDBLOCK); /* maps to UV_EAGAIN */
handle->read_cb((uv_stream_t*) handle, 0, buf);
}
@ -702,7 +702,7 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle,
/* TODO: read unicode, convert to utf-8 */
DWORD bytes = req->overlapped.InternalHigh;
if (bytes == 0) {
uv_set_sys_error(loop, WSAEWOULDBLOCK); /* maps to UV_EAGAIN */
uv__set_sys_error(loop, WSAEWOULDBLOCK); /* maps to UV_EAGAIN */
}
handle->read_cb((uv_stream_t*) handle, bytes, buf);
}
@ -770,7 +770,7 @@ int uv_tty_read_stop(uv_tty_t* handle) {
DWORD written;
memset(&record, 0, sizeof record);
if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) {
uv_set_sys_error(handle->loop, GetLastError());
uv__set_sys_error(handle->loop, GetLastError());
return -1;
}
}
@ -1483,7 +1483,7 @@ int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle,
if ((handle->flags & UV_HANDLE_SHUTTING) ||
(handle->flags & UV_HANDLE_CLOSING)) {
uv_set_sys_error(loop, WSAESHUTDOWN);
uv__set_sys_error(loop, WSAESHUTDOWN);
return -1;
}
@ -1515,8 +1515,8 @@ void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
handle->write_queue_size -= req->queued_bytes;
if (req->cb) {
loop->last_error = GET_REQ_UV_ERROR(req);
((uv_write_cb)req->cb)(req, loop->last_error.code == UV_OK ? 0 : -1);
uv__set_sys_error(loop, GET_REQ_ERROR(req));
((uv_write_cb)req->cb)(req, loop->last_err.code == UV_OK ? 0 : -1);
}
handle->write_reqs_pending--;
@ -1589,3 +1589,9 @@ void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle,
uv_connect_t* req) {
abort();
}
void uv_tty_reset_mode() {
/* Not necessary to do anything. */
;
}

90
deps/uv/src/win/udp.c

@ -46,13 +46,13 @@ int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
int result;
if (!(handle->flags & UV_HANDLE_BOUND)) {
uv_set_sys_error(loop, WSAEINVAL);
uv__set_sys_error(loop, WSAEINVAL);
return -1;
}
result = getsockname(handle->socket, name, namelen);
if (result != 0) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -68,13 +68,13 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle,
/* Set the socket to nonblocking mode */
if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
/* Make the socket non-inheritable */
if (!SetHandleInformation((HANDLE)socket, HANDLE_FLAG_INHERIT, 0)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -84,14 +84,14 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle,
loop->iocp,
(ULONG_PTR)socket,
0) == NULL) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
if (pSetFileCompletionNotificationModes) {
if (!pSetFileCompletionNotificationModes((HANDLE)socket,
FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
uv_set_sys_error(loop, GetLastError());
uv__set_sys_error(loop, GetLastError());
return -1;
}
@ -148,13 +148,14 @@ static int uv__bind(uv_udp_t* handle, int domain, struct sockaddr* addr,
if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) {
/* UV_UDP_IPV6ONLY is supported only for IPV6 sockets */
uv_set_sys_error(loop, UV_EINVAL);
uv__set_sys_error(loop, UV_EINVAL);
return -1;
}
if (handle->socket == INVALID_SOCKET) {
sock = socket(domain, SOCK_DGRAM, 0);
if (sock == INVALID_SOCKET) {
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -183,7 +184,7 @@ static int uv__bind(uv_udp_t* handle, int domain, struct sockaddr* addr,
if (r == SOCKET_ERROR) {
err = WSAGetLastError();
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -197,8 +198,8 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
unsigned int flags) {
uv_loop_t* loop = handle->loop;
if (addr.sin_family != AF_INET) {
uv_set_sys_error(loop, WSAEFAULT);
if (handle->type != UV_UDP || addr.sin_family != AF_INET) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
@ -214,8 +215,8 @@ int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
unsigned int flags) {
uv_loop_t* loop = handle->loop;
if (addr.sin6_family != AF_INET6) {
uv_set_sys_error(loop, WSAEFAULT);
if (handle->type != UV_UDP || addr.sin6_family != AF_INET6) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
@ -227,7 +228,7 @@ int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
sizeof(struct sockaddr_in6),
flags);
} else {
uv_new_sys_error(WSAEAFNOSUPPORT);
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
return -1;
}
}
@ -329,7 +330,7 @@ int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
uv_loop_t* loop = handle->loop;
if (handle->flags & UV_HANDLE_READING) {
uv_set_sys_error(loop, WSAEALREADY);
uv__set_sys_error(loop, WSAEALREADY);
return -1;
}
@ -363,55 +364,6 @@ int uv_udp_recv_stop(uv_udp_t* handle) {
}
int uv_udp_connect6(uv_connect_t* req, uv_udp_t* handle,
struct sockaddr_in6 address, uv_connect_cb cb) {
uv_loop_t* loop = handle->loop;
int addrsize = sizeof(struct sockaddr_in6);
BOOL success;
DWORD bytes;
if (!uv_allow_ipv6) {
uv_new_sys_error(WSAEAFNOSUPPORT);
return -1;
}
if (address.sin6_family != AF_INET6) {
uv_set_sys_error(loop, WSAEFAULT);
return -1;
}
if (!(handle->flags & UV_HANDLE_BOUND) &&
uv_udp_bind6(handle, uv_addr_ip6_any_, 0) < 0)
return -1;
uv_req_init(loop, (uv_req_t*) req);
req->type = UV_CONNECT;
req->handle = (uv_stream_t*) handle;
req->cb = cb;
memset(&req->overlapped, 0, sizeof(req->overlapped));
success = pConnectEx6(handle->socket,
(struct sockaddr*) &address,
addrsize,
NULL,
0,
&bytes,
&req->overlapped);
if (UV_SUCCEEDED_WITHOUT_IOCP(success)) {
handle->reqs_pending++;
uv_insert_pending_req(loop, (uv_req_t*)req);
} else if (UV_SUCCEEDED_WITH_IOCP(success)) {
handle->reqs_pending++;
} else {
uv_set_sys_error(loop, WSAGetLastError());
return -1;
}
return 0;
}
static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
int bufcnt, struct sockaddr* addr, int addr_len, uv_udp_send_cb cb) {
uv_loop_t* loop = handle->loop;
@ -444,7 +396,7 @@ static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
handle->reqs_pending++;
} else {
/* Send failed due to an error. */
uv_set_sys_error(loop, WSAGetLastError());
uv__set_sys_error(loop, WSAGetLastError());
return -1;
}
@ -501,7 +453,7 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
GET_REQ_STATUS(req) != STATUS_RECEIVE_EXPEDITED) {
/* An error occurred doing the read. */
if ((handle->flags & UV_HANDLE_READING)) {
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
uv_udp_recv_stop(handle);
#if 0
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
@ -558,11 +510,11 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
} else {
err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
uv_set_sys_error(loop, WSAEWOULDBLOCK);
uv__set_sys_error(loop, WSAEWOULDBLOCK);
handle->recv_cb(handle, 0, buf, NULL, 0);
} else {
/* Ouch! serious error. */
uv_set_sys_error(loop, err);
uv__set_sys_error(loop, err);
handle->recv_cb(handle, -1, buf, NULL, 0);
}
}
@ -588,7 +540,7 @@ void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle,
if (REQ_SUCCESS(req)) {
req->cb(req, 0);
} else {
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
req->cb(req, -1);
}
}

4
deps/uv/src/win/util.c

@ -69,7 +69,7 @@ int uv_exepath(char* buffer, size_t* size) {
/* Get the path as UTF-16 */
utf16Size = GetModuleFileNameW(NULL, utf16Buffer, *size - 1);
if (utf16Size <= 0) {
/* uv_set_sys_error(loop, GetLastError()); */
/* uv__set_sys_error(loop, GetLastError()); */
retVal = -1;
goto done;
}
@ -79,7 +79,7 @@ int uv_exepath(char* buffer, size_t* size) {
/* Convert to UTF-8 */
*size = uv_utf16_to_utf8(utf16Buffer, utf16Size, buffer, *size);
if (!*size) {
/* uv_set_sys_error(loop, GetLastError()); */
/* uv__set_sys_error(loop, GetLastError()); */
retVal = -1;
goto done;
}

1
deps/uv/test/benchmark-sizes.c

@ -29,6 +29,7 @@ BENCHMARK_IMPL(sizes) {
LOGF("uv_connect_t: %u bytes\n", (unsigned int) sizeof(uv_connect_t));
LOGF("uv_tcp_t: %u bytes\n", (unsigned int) sizeof(uv_tcp_t));
LOGF("uv_pipe_t: %u bytes\n", (unsigned int) sizeof(uv_pipe_t));
LOGF("uv_tty_t: %u bytes\n", (unsigned int) sizeof(uv_tty_t));
LOGF("uv_prepare_t: %u bytes\n", (unsigned int) sizeof(uv_prepare_t));
LOGF("uv_check_t: %u bytes\n", (unsigned int) sizeof(uv_check_t));
LOGF("uv_idle_t: %u bytes\n", (unsigned int) sizeof(uv_idle_t));

18
deps/uv/test/test-fs.c

@ -1077,7 +1077,7 @@ TEST_IMPL(fs_symlink) {
r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink", 0, NULL);
#ifdef _WIN32
if (r == -1) {
if (req.errorno == ENOSYS) {
if (uv_last_error(loop).code == UV_ENOTSUP) {
/*
* Windows doesn't support symlinks on older versions.
* We just pass the test and bail out early if we get ENOTSUP.
@ -1245,3 +1245,19 @@ TEST_IMPL(fs_futime) {
return 0;
}
TEST_IMPL(fs_stat_missing_path) {
uv_fs_t req;
int r;
loop = uv_default_loop();
r = uv_fs_stat(loop, &req, "non_existent_file", NULL);
ASSERT(r == -1);
ASSERT(req.result == -1);
ASSERT(uv_last_error(loop).code == UV_ENOENT);
uv_fs_req_cleanup(&req);
return 0;
}

2
deps/uv/test/test-list.h

@ -91,6 +91,7 @@ TEST_DECLARE (fs_link)
TEST_DECLARE (fs_symlink)
TEST_DECLARE (fs_utime)
TEST_DECLARE (fs_futime)
TEST_DECLARE (fs_stat_missing_path)
TEST_DECLARE (fs_event_watch_dir)
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_current_dir)
@ -216,6 +217,7 @@ TASK_LIST_START
TEST_ENTRY (fs_utime)
TEST_ENTRY (fs_futime)
TEST_ENTRY (fs_symlink)
TEST_ENTRY (fs_stat_missing_path)
TEST_ENTRY (fs_event_watch_dir)
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_current_dir)

10
deps/uv/test/test-tty.c

@ -48,6 +48,16 @@ TEST_IMPL(tty) {
ASSERT(width > 10);
ASSERT(height > 10);
/* Turn on raw mode. */
r = uv_tty_set_mode(&tty, 1);
ASSERT(r == 0);
/* Turn off raw mode. */
r = uv_tty_set_mode(&tty, 0);
ASSERT(r == 0);
/* TODO check the actual mode! */
uv_close((uv_handle_t*)&tty, NULL);
uv_run(loop);

16
deps/uv/uv.gyp

@ -21,11 +21,8 @@
'include/uv.h',
'src/uv-common.c',
'src/uv-common.h',
'src/ares/ares__close_sockets.c',
'src/ares/ares__get_hostent.c',
'src/ares/ares__read_line.c',
'src/ares/ares__timeval.c',
'src/ares/ares_cancel.c',
'src/ares/ares__close_sockets.c',
'src/ares/ares_data.c',
'src/ares/ares_data.h',
'src/ares/ares_destroy.c',
@ -35,8 +32,10 @@
'src/ares/ares_fds.c',
'src/ares/ares_free_hostent.c',
'src/ares/ares_free_string.c',
'src/ares/ares_getenv.h',
'src/ares/ares_gethostbyaddr.c',
'src/ares/ares_gethostbyname.c',
'src/ares/ares__get_hostent.c',
'src/ares/ares_getnameinfo.c',
'src/ares/ares_getopt.c',
'src/ares/ares_getopt.h',
@ -51,16 +50,18 @@
'src/ares/ares_nowarn.c',
'src/ares/ares_nowarn.h',
'src/ares/ares_options.c',
'src/ares/ares_parse_a_reply.c',
'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_ns_reply.c',
'src/ares/ares_parse_ptr_reply.c',
'src/ares/ares_parse_srv_reply.c',
'src/ares/ares_parse_txt_reply.c',
'src/ares/ares_platform.h',
'src/ares/ares_private.h',
'src/ares/ares_process.c',
'src/ares/ares_query.c',
'src/ares/ares__read_line.c',
'src/ares/ares_rules.h',
'src/ares/ares_search.c',
'src/ares/ares_send.c',
@ -71,6 +72,7 @@
'src/ares/ares_strdup.h',
'src/ares/ares_strerror.c',
'src/ares/ares_timeout.c',
'src/ares/ares__timeval.c',
'src/ares/ares_version.c',
'src/ares/ares_writev.c',
'src/ares/ares_writev.h',
@ -82,6 +84,7 @@
'src/ares/inet_ntop.h',
'src/ares/nameser.h',
'src/ares/setup_once.h',
'src/ares/windows_port.c',
],
'conditions': [
[ 'OS=="win"', {
@ -98,6 +101,9 @@
'include/uv-private/uv-win.h',
'src/ares/config_win32/ares_config.h',
'src/ares/windows_port.c',
'src/ares/ares_getenv.c',
'src/ares/ares_iphlpapi.h',
'src/ares/ares_platform.c',
'src/win/async.c',
'src/win/cares.c',
'src/win/core.c',

Loading…
Cancel
Save