Browse Source

upgrade libuv to 0303197

v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
627f379f22
  1. 5
      deps/uv/config-unix.mk
  2. 1
      deps/uv/include/uv-private/ev.h
  3. 33
      deps/uv/include/uv-private/uv-unix.h
  4. 7
      deps/uv/include/uv.h
  5. 2
      deps/uv/src/unix/core.c
  6. 12
      deps/uv/src/unix/cygwin.c
  7. 41
      deps/uv/src/unix/darwin.c
  8. 3
      deps/uv/src/unix/ev/ev.c
  9. 15
      deps/uv/src/unix/ev/ev_kqueue.c
  10. 40
      deps/uv/src/unix/freebsd.c
  11. 22
      deps/uv/src/unix/internal.h
  12. 121
      deps/uv/src/unix/kqueue.c
  13. 18
      deps/uv/src/unix/linux.c
  14. 43
      deps/uv/src/unix/netbsd.c
  15. 36
      deps/uv/src/unix/sunos.c
  16. 64
      deps/uv/src/unix/tcp.c
  17. 48
      deps/uv/src/unix/udp.c
  18. 62
      deps/uv/src/uv-common.c
  19. 17
      deps/uv/src/uv-common.h
  20. 60
      deps/uv/src/win/tcp.c
  21. 45
      deps/uv/src/win/udp.c
  22. 29
      deps/uv/src/win/util.c
  23. 42
      deps/uv/test/test-fs-event.c
  24. 2
      deps/uv/test/test-fs.c
  25. 19
      deps/uv/test/test-get-loadavg.c
  26. 34
      deps/uv/test/test-get-memory.c
  27. 6
      deps/uv/test/test-list.h
  28. 70
      deps/uv/test/test-tcp-connect-error.c
  29. 68
      deps/uv/test/test-tcp-connect6-error.c
  30. 20
      deps/uv/uv.gyp

5
deps/uv/config-unix.mk

@ -44,7 +44,7 @@ ifeq (SunOS,$(uname_S))
EV_CONFIG=config_sunos.h
EIO_CONFIG=config_sunos.h
CPPFLAGS += -Isrc/ares/config_sunos -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
LINKFLAGS+=-lsocket -lnsl
LINKFLAGS+=-lsocket -lnsl -lkstat
OBJS += src/unix/sunos.o
endif
@ -54,6 +54,7 @@ EIO_CONFIG=config_darwin.h
CPPFLAGS += -Isrc/ares/config_darwin
LINKFLAGS+=-framework CoreServices
OBJS += src/unix/darwin.o
OBJS += src/unix/kqueue.o
endif
ifeq (Linux,$(uname_S))
@ -71,6 +72,7 @@ EIO_CONFIG=config_freebsd.h
CPPFLAGS += -Isrc/ares/config_freebsd
LINKFLAGS+=
OBJS += src/unix/freebsd.o
OBJS += src/unix/kqueue.o
endif
ifeq (NetBSD,$(uname_S))
@ -79,6 +81,7 @@ EIO_CONFIG=config_netbsd.h
CPPFLAGS += -Isrc/ares/config_netbsd
LINKFLAGS+=
OBJS += src/unix/netbsd.o
OBJS += src/unix/kqueue.o
endif
ifneq (,$(findstring CYGWIN,$(uname_S)))

1
deps/uv/include/uv-private/ev.h

@ -207,6 +207,7 @@ enum {
EV_NONE = 0x00, /* no events */
EV_READ = 0x01, /* ev_io detected read will not block */
EV_WRITE = 0x02, /* ev_io detected write will not block */
EV_LIBUV_KQUEUE_HACK = 0x40,
EV__IOFDSET = 0x80, /* internal use only */
EV_IO = EV_READ, /* alias for type-detection */
EV_TIMER = 0x00000100, /* timer timed out */

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

@ -27,10 +27,6 @@
#include "ev.h"
#include "eio.h"
#if defined(__linux__)
#include "uv-private/uv-linux.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@ -47,11 +43,6 @@ typedef struct {
typedef int uv_file;
/* Stub. Remove it once all platforms support the file watcher API. */
#ifndef UV_FS_EVENT_PRIVATE_FIELDS
#define UV_FS_EVENT_PRIVATE_FIELDS /* empty */
#endif
#define UV_LOOP_PRIVATE_FIELDS \
ares_channel channel; \
/* \
@ -188,4 +179,28 @@ typedef int uv_file;
struct termios orig_termios; \
int mode;
/* UV_FS_EVENT_PRIVATE_FIELDS */
#if defined(__linux__)
#define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io read_watcher; \
uv_fs_event_cb cb; \
#elif (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) \
|| defined(__FreeBSD__) \
|| defined(__OpenBSD__) \
|| defined(__NetBSD__)
#define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io event_watcher; \
uv_fs_event_cb cb; \
int fflags; \
#else
/* Stub for platforms where the file watcher isn't implemented yet. */
#define UV_FS_EVENT_PRIVATE_FIELDS
#endif
#endif /* UV_UNIX_H */

7
deps/uv/include/uv.h

@ -1044,6 +1044,9 @@ struct uv_fs_event_s {
};
/* Gets load avg */
void uv_loadavg(double avg[3]);
/*
* If filename is a directory then we will watch for all events in that
* directory. If filename is a file - we will only get events from that
@ -1065,6 +1068,10 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size);
/* Gets the executable path */
int uv_exepath(char* buffer, size_t* size);
/* Memory info */
double uv_get_free_memory(void);
double uv_get_total_memory(void);
/*
* Returns the current high-resolution real time. This is expressed in
* nanoseconds. It is relative to an arbitrary time in the past. It is not

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

@ -172,7 +172,7 @@ void uv_loop_delete(uv_loop_t* loop) {
uv_loop_t* uv_default_loop() {
if (!default_loop_ptr) {
default_loop_ptr = &default_loop_struct;
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
#if HAVE_KQUEUE
default_loop_struct.ev = ev_default_loop(EVBACKEND_KQUEUE);
#else
default_loop_struct.ev = ev_default_loop(EVFLAG_AUTO);

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

@ -36,6 +36,11 @@ uint64_t uv_hrtime() {
return (ts.tv_sec * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {
/* Unsupported as of cygwin 1.7.7 */
avg[0] = avg[1] = avg[2] = 0;
}
int uv_exepath(char* buffer, size_t* size) {
uint32_t usize;
@ -53,6 +58,13 @@ int uv_exepath(char* buffer, size_t* size) {
return 0;
}
double uv_get_free_memory(void) {
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
}
double uv_get_total_memory(void) {
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
}
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,

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

@ -29,6 +29,9 @@
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <unistd.h> /* sysconf */
uint64_t uv_hrtime() {
@ -68,16 +71,38 @@ int uv_exepath(char* buffer, size_t* size) {
return 0;
}
double uv_get_free_memory(void) {
vm_statistics_data_t info;
mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t);
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv__set_sys_error(loop, ENOSYS);
return -1;
if (host_statistics(mach_host_self(), HOST_VM_INFO,
(host_info_t)&info, &count) != KERN_SUCCESS) {
return -1;
}
return (double) info.free_count * sysconf(_SC_PAGESIZE);
}
double uv_get_total_memory(void) {
uint64_t info;
int which[] = {CTL_HW, HW_MEMSIZE};
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) {
return -1;
}
return (double) info;
}
void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return;
void uv__fs_event_destroy(uv_fs_event_t* handle) {
assert(0 && "implement me");
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
avg[2] = (double) info.ldavg[2] / info.fscale;
}

3
deps/uv/src/unix/ev/ev.c

@ -2663,7 +2663,8 @@ ev_io_start (EV_P_ ev_io *w)
return;
assert (("libev: ev_io_start called with negative fd", fd >= 0));
assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
assert (("libev: ev_io_start called with illegal event mask",
!(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE | EV_LIBUV_KQUEUE_HACK))));
EV_FREQUENT_CHECK;

15
deps/uv/src/unix/ev/ev_kqueue.c

@ -43,6 +43,9 @@
#include <string.h>
#include <errno.h>
extern void
uv__kqueue_hack (EV_P_ int fflags, ev_io *w);
void inline_speed
kqueue_change (EV_P_ int fd, int filter, int flags, int fflags)
{
@ -80,6 +83,10 @@ kqueue_modify (EV_P_ int fd, int oev, int nev)
if (nev & EV_WRITE)
kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_ADD | EV_ENABLE, NOTE_EOF);
if (nev & EV_LIBUV_KQUEUE_HACK)
kqueue_change (EV_A_ fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT,
NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE);
}
static void
@ -114,6 +121,13 @@ kqueue_poll (EV_P_ ev_tstamp timeout)
{
int fd = kqueue_events [i].ident;
if (kqueue_events [i].filter == EVFILT_VNODE)
{
/* pass kqueue filter flags to libuv */
ev_io *w = (ev_io *)(anfds [fd].head);
uv__kqueue_hack (EV_A_ kqueue_events [i].fflags, w);
}
if (expect_false (kqueue_events [i].flags & EV_ERROR))
{
int err = kqueue_events [i].data;
@ -140,6 +154,7 @@ kqueue_poll (EV_P_ ev_tstamp timeout)
fd,
kqueue_events [i].filter == EVFILT_READ ? EV_READ
: kqueue_events [i].filter == EVFILT_WRITE ? EV_WRITE
: kqueue_events [i].filter == EVFILT_VNODE ? EV_LIBUV_KQUEUE_HACK
: 0
);
}

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

@ -25,6 +25,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <time.h>
@ -67,16 +68,39 @@ int uv_exepath(char* buffer, size_t* size) {
return 0;
}
double uv_get_free_memory(void) {
vm_statistics_data_t info;
mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t);
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv__set_sys_error(loop, ENOSYS);
return -1;
if (host_statistics(mach_host_self(), HOST_VM_INFO,
(host_info_t)&info, &count) != KERN_SUCCESS) {
return -1;
}
return (double) info.free_count * sysconf(_SC_PAGESIZE);
}
double uv_get_total_memory(void) {
unsigned long info;
int which[] = {CTL_HW, HW_PHYSMEM};
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) {
return -1;
}
return (double) info;
}
void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return;
void uv__fs_event_destroy(uv_fs_event_t* handle) {
assert(0 && "implement me");
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
avg[2] = (double) info.ldavg[2] / info.fscale;
}

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

@ -32,33 +32,37 @@
#include <linux/version.h>
#include <features.h>
#undef HAVE_FUTIMES
#undef HAVE_PIPE2
#undef HAVE_ACCEPT4
/* futimes() requires linux >= 2.6.22 and glib >= 2.6 */
#if LINUX_VERSION_CODE >= 0x20616 && __GLIBC_PREREQ(2, 6)
#define HAVE_FUTIMES
#define HAVE_FUTIMES 1
#endif
/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
#define HAVE_PIPE2
#define HAVE_PIPE2 1
#endif
/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
#define HAVE_ACCEPT4
#define HAVE_ACCEPT4 1
#endif
#endif /* __linux__ */
#ifdef __APPLE__
# define HAVE_FUTIMES
# define HAVE_FUTIMES 1
#endif
#ifdef __FreeBSD__
# define HAVE_FUTIMES
# define HAVE_FUTIMES 1
#endif
/* FIXME exact copy of the #ifdef guard in uv-unix.h */
#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) \
|| defined(__FreeBSD__) \
|| defined(__OpenBSD__) \
|| defined(__NetBSD__)
# define HAVE_KQUEUE 1
#endif
#define container_of(ptr, type, member) \

121
deps/uv/src/unix/kqueue.c

@ -0,0 +1,121 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "internal.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/event.h>
#include <fcntl.h>
#include <time.h>
static void uv__fs_event(EV_P_ ev_io* w, int revents);
static void uv__fs_event_start(uv_fs_event_t* handle) {
ev_io_init(&handle->event_watcher,
uv__fs_event,
handle->fd,
EV_LIBUV_KQUEUE_HACK);
ev_io_start(handle->loop->ev, &handle->event_watcher);
}
static void uv__fs_event_stop(uv_fs_event_t* handle) {
ev_io_stop(handle->loop->ev, &handle->event_watcher);
}
static void uv__fs_event(EV_P_ ev_io* w, int revents) {
uv_fs_event_t* handle;
int events;
assert(revents == EV_LIBUV_KQUEUE_HACK);
handle = container_of(w, uv_fs_event_t, event_watcher);
if (handle->fflags & (NOTE_ATTRIB | NOTE_EXTEND))
events = UV_CHANGE;
else
events = UV_RENAME;
handle->cb(handle, NULL, events, 0);
uv__fs_event_stop(handle);
/* File watcher operates in one-shot mode, re-arm it. */
if (handle->fd != -1)
uv__fs_event_start(handle);
}
/* Called by libev, don't touch. */
void uv__kqueue_hack(EV_P_ int fflags, ev_io *w) {
uv_fs_event_t* handle;
handle = container_of(w, uv_fs_event_t, event_watcher);
handle->fflags = fflags;
}
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
#if HAVE_KQUEUE
int fd;
if (cb == NULL) {
uv__set_sys_error(loop, EINVAL);
return -1;
}
/* TODO open asynchronously - but how do we report back errors? */
if ((fd = open(filename, O_RDONLY)) == -1) {
uv__set_sys_error(loop, errno);
return -1;
}
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
handle->filename = strdup(filename);
handle->fflags = 0;
handle->cb = cb;
handle->fd = fd;
uv__fs_event_start(handle);
return 0;
#else
uv__set_sys_error(loop, ENOSYS);
return -1;
#endif
}
void uv__fs_event_destroy(uv_fs_event_t* handle) {
free(handle->filename);
uv__close(handle->fd);
handle->fd = -1;
}

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

@ -28,6 +28,7 @@
#include <errno.h>
#include <sys/inotify.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <time.h>
@ -52,6 +53,16 @@ uint64_t uv_hrtime() {
return (ts.tv_sec * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {
struct sysinfo info;
if (sysinfo(&info) < 0) return;
avg[0] = (double) info.loads[0] / 65536.0;
avg[1] = (double) info.loads[1] / 65536.0;
avg[2] = (double) info.loads[2] / 65536.0;
}
int uv_exepath(char* buffer, size_t* size) {
if (!buffer || !size) {
@ -64,6 +75,13 @@ int uv_exepath(char* buffer, size_t* size) {
return 0;
}
double uv_get_free_memory(void) {
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
}
double uv_get_total_memory(void) {
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
}
static int new_inotify_fd(void) {
#if defined(IN_NONBLOCK) && defined(IN_CLOEXEC)

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

@ -24,6 +24,7 @@
#include <string.h>
#include <errno.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/sysctl.h>
@ -40,6 +41,17 @@ uint64_t uv_hrtime(void) {
return (ts.tv_sec * NANOSEC + ts.tv_nsec);
}
void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return;
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
avg[2] = (double) info.ldavg[2] / info.fscale;
}
int uv_exepath(char* buffer, size_t* size) {
uint32_t usize;
@ -70,16 +82,31 @@ int uv_exepath(char* buffer, size_t* size) {
return 0;
}
double uv_get_free_memory(void) {
struct uvmexp info;
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_UVMEXP};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) {
return -1;
}
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb) {
uv__set_sys_error(loop, ENOSYS);
return -1;
return (double) info.free * psysconf(_SC_PAGESIZE);
}
double uv_get_total_memory(void) {
#if defined(HW_PHYSMEM64)
uint64_t info;
int which[] = {CTL_HW, HW_PHYSMEM64};
#else
unsigned int info;
int which[] = {CTL_HW, HW_PHYSMEM};
#endif
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) {
return -1;
}
void uv__fs_event_destroy(uv_fs_event_t* handle) {
assert(0 && "implement me");
return (double) info;
}

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

@ -19,6 +19,7 @@
*/
#include "uv.h"
#include "internal.h"
#include <stdio.h>
#include <stdint.h>
@ -26,7 +27,9 @@
#include <errno.h>
#include <sys/time.h>
#include <sys/loadavg.h>
#include <unistd.h>
#include <kstat.h>
uint64_t uv_hrtime() {
@ -62,6 +65,39 @@ int uv_exepath(char* buffer, size_t* size) {
return (0);
}
double uv_get_free_memory(void) {
kstat_ctl_t *kc;
kstat_t *ksp;
kstat_named_t *knp;
ulong_t freemem;
if ((kc = kstat_open()) == NULL) return -1;
ksp = kstat_lookup(kc, (char *)"unix", 0, (char *)"system_pages");
if(kstat_read(kc, ksp, NULL) == -1){
return -1;
}
else {
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"freemem");
freemem = knp->value.ul;
}
kstat_close(kc);
return (double) freemem * sysconf(_SC_PAGESIZE);
}
double uv_get_total_memory(void) {
return (double) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
}
void uv_loadavg(double avg[3]) {
(void) getloadavg(avg, 3);
}
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,

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

@ -33,10 +33,10 @@ int uv_tcp_init(uv_loop_t* loop, uv_tcp_t* tcp) {
}
static int uv__tcp_bind(uv_tcp_t* tcp,
int domain,
struct sockaddr* addr,
int addrsize) {
static int uv__bind(uv_tcp_t* tcp,
int domain,
struct sockaddr* addr,
int addrsize) {
int saved_errno;
int status;
@ -76,29 +76,19 @@ out:
}
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(handle,
AF_INET,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in));
int uv__tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
return uv__bind(handle,
AF_INET,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in));
}
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(handle,
AF_INET6,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in6));
int uv__tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
return uv__bind(handle,
AF_INET6,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in6));
}
@ -216,55 +206,37 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
}
int uv_tcp_connect(uv_connect_t* req,
int uv__tcp_connect(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in address,
uv_connect_cb cb) {
int saved_errno;
int saved_errno = errno;
int status;
saved_errno = errno;
status = -1;
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv__set_sys_error(handle->loop, EINVAL);
goto out;
}
status = uv__connect(req,
(uv_stream_t*)handle,
(struct sockaddr*)&address,
sizeof address,
cb);
out:
errno = saved_errno;
return status;
}
int uv_tcp_connect6(uv_connect_t* req,
int uv__tcp_connect6(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in6 address,
uv_connect_cb cb) {
int saved_errno;
int saved_errno = errno;
int status;
saved_errno = errno;
status = -1;
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv__set_sys_error(handle->loop, EINVAL);
goto out;
}
status = uv__connect(req,
(uv_stream_t*)handle,
(struct sockaddr*)&address,
sizeof address,
cb);
out:
errno = saved_errno;
return status;
}

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

@ -34,8 +34,6 @@ static void uv__udp_run_pending(uv_udp_t* handle);
static void uv__udp_recvmsg(uv_udp_t* handle);
static void uv__udp_sendmsg(uv_udp_t* handle);
static void uv__udp_io(EV_P_ ev_io* w, int events);
static int uv__udp_bind(uv_udp_t* handle, int domain, struct sockaddr* addr,
socklen_t len, unsigned flags);
static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, int domain);
static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
int bufcnt, struct sockaddr* addr, socklen_t addrlen, uv_udp_send_cb send_cb);
@ -289,11 +287,11 @@ static void uv__udp_io(EV_P_ ev_io* w, int events) {
}
static int uv__udp_bind(uv_udp_t* handle,
int domain,
struct sockaddr* addr,
socklen_t len,
unsigned flags) {
static int uv__bind(uv_udp_t* handle,
int domain,
struct sockaddr* addr,
socklen_t len,
unsigned flags) {
int saved_errno;
int status;
int yes;
@ -389,7 +387,7 @@ static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, int domain) {
abort();
}
return uv__udp_bind(handle, domain, (struct sockaddr*)&taddr, addrlen, 0);
return uv__bind(handle, domain, (struct sockaddr*)&taddr, addrlen, 0);
}
@ -443,31 +441,21 @@ 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,
sizeof addr,
flags);
int uv__udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned flags) {
return uv__bind(handle,
AF_INET,
(struct sockaddr*)&addr,
sizeof addr,
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,
sizeof addr,
flags);
int uv__udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags) {
return uv__bind(handle,
AF_INET6,
(struct sockaddr*)&addr,
sizeof addr,
flags);
}

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

@ -206,3 +206,65 @@ void uv_remove_ares_handle(uv_ares_task_t* handle) {
int uv_ares_handles_empty(uv_loop_t* loop) {
return loop->uv_ares_handles_ ? 0 : 1;
}
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
if (handle->type != UV_TCP || addr.sin_family != AF_INET) {
uv__set_artificial_error(handle->loop, UV_EFAULT);
return -1;
}
return uv__tcp_bind(handle, addr);
}
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
if (handle->type != UV_TCP || addr.sin6_family != AF_INET6) {
uv__set_artificial_error(handle->loop, UV_EFAULT);
return -1;
}
return uv__tcp_bind6(handle, addr);
}
int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
unsigned int flags) {
if (handle->type != UV_UDP || addr.sin_family != AF_INET) {
uv__set_artificial_error(handle->loop, UV_EFAULT);
return -1;
}
return uv__udp_bind(handle, addr, flags);
}
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
unsigned int flags) {
if (handle->type != UV_UDP || addr.sin6_family != AF_INET6) {
uv__set_artificial_error(handle->loop, UV_EFAULT);
return -1;
}
return uv__udp_bind6(handle, addr, flags);
}
int uv_tcp_connect(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in address,
uv_connect_cb cb) {
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
return uv__tcp_connect(req, handle, address, cb);
}
int uv_tcp_connect6(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in6 address,
uv_connect_cb cb) {
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
return uv__tcp_connect6(req, handle, address, cb);
}

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

@ -53,4 +53,21 @@ 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);
int uv__tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr);
int uv__tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr);
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);
int uv__tcp_connect(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in address,
uv_connect_cb cb);
int uv__tcp_connect6(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in6 address,
uv_connect_cb cb);
#endif /* UV_COMMON_H_ */

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

@ -154,8 +154,10 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
}
static int uv__bind(uv_loop_t* loop, uv_tcp_t* handle, int domain,
struct sockaddr* addr, int addrsize) {
static int uv__bind(uv_tcp_t* handle,
int domain,
struct sockaddr* addr,
int addrsize) {
DWORD err;
int r;
SOCKET sock;
@ -163,11 +165,11 @@ 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(handle->loop, WSAGetLastError());
return -1;
}
if (uv_tcp_set_socket(loop, handle, sock) == -1) {
if (uv_tcp_set_socket(handle->loop, handle, sock) == -1) {
closesocket(sock);
return -1;
}
@ -182,7 +184,7 @@ static int uv__bind(uv_loop_t* loop, uv_tcp_t* handle, int domain,
handle->bind_error = err;
handle->flags |= UV_HANDLE_BIND_ERROR;
} else {
uv__set_sys_error(loop, err);
uv__set_sys_error(handle->loop, err);
return -1;
}
}
@ -193,40 +195,24 @@ 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 (handle->type != UV_TCP || addr.sin_family != AF_INET) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
return uv__bind(loop,
handle,
int uv__tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
return uv__bind(handle,
AF_INET,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in));
}
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
uv_loop_t* loop = handle->loop;
if (handle->type != UV_TCP || addr.sin6_family != AF_INET6) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
int uv__tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
if (uv_allow_ipv6) {
handle->flags |= UV_HANDLE_IPV6;
return uv__bind(loop,
handle,
return uv__bind(handle,
AF_INET6,
(struct sockaddr*)&addr,
sizeof(struct sockaddr_in6));
} else {
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
uv__set_sys_error(handle->loop, WSAEAFNOSUPPORT);
return -1;
}
}
@ -472,8 +458,10 @@ int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
}
int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
struct sockaddr_in address, uv_connect_cb cb) {
int uv__tcp_connect(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in address,
uv_connect_cb cb) {
uv_loop_t* loop = handle->loop;
int addrsize = sizeof(struct sockaddr_in);
BOOL success;
@ -484,11 +472,6 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
return -1;
}
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
if (!(handle->flags & UV_HANDLE_BOUND) &&
uv_tcp_bind(handle, uv_addr_ip4_any_) < 0)
return -1;
@ -523,8 +506,10 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
}
int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
struct sockaddr_in6 address, uv_connect_cb cb) {
int uv__tcp_connect6(uv_connect_t* req,
uv_tcp_t* handle,
struct sockaddr_in6 address,
uv_connect_cb cb) {
uv_loop_t* loop = handle->loop;
int addrsize = sizeof(struct sockaddr_in6);
BOOL success;
@ -540,11 +525,6 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
return -1;
}
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
if (!(handle->flags & UV_HANDLE_BOUND) &&
uv_tcp_bind6(handle, uv_addr_ip6_any_) < 0)
return -1;

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

@ -89,13 +89,14 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle,
}
if (pSetFileCompletionNotificationModes) {
if (!pSetFileCompletionNotificationModes((HANDLE)socket,
FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
if (pSetFileCompletionNotificationModes((HANDLE)socket,
FILE_SKIP_SET_EVENT_ON_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());
return -1;
}
handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
}
handle->socket = socket;
@ -139,27 +140,29 @@ void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) {
}
static int uv__bind(uv_udp_t* handle, int domain, struct sockaddr* addr,
int addrsize, unsigned int flags) {
uv_loop_t* loop = handle->loop;
static int uv__bind(uv_udp_t* handle,
int domain,
struct sockaddr* addr,
int addrsize,
unsigned int flags) {
DWORD err;
int r;
SOCKET sock;
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_artificial_error(handle->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(handle->loop, WSAGetLastError());
return -1;
}
if (uv_udp_set_socket(loop, handle, sock) == -1) {
if (uv_udp_set_socket(handle->loop, handle, sock) == -1) {
closesocket(sock);
return -1;
}
@ -184,7 +187,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(handle->loop, WSAGetLastError());
return -1;
}
@ -194,15 +197,8 @@ static int uv__bind(uv_udp_t* handle, int domain, struct sockaddr* addr,
}
int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
int uv__udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
unsigned int flags) {
uv_loop_t* loop = handle->loop;
if (handle->type != UV_UDP || addr.sin_family != AF_INET) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
return uv__bind(handle,
AF_INET,
(struct sockaddr*) &addr,
@ -211,15 +207,8 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
}
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
int uv__udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
unsigned int flags) {
uv_loop_t* loop = handle->loop;
if (handle->type != UV_UDP || addr.sin6_family != AF_INET6) {
uv__set_sys_error(loop, WSAEFAULT);
return -1;
}
if (uv_allow_ipv6) {
handle->flags |= UV_HANDLE_IPV6;
return uv__bind(handle,
@ -228,7 +217,7 @@ int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
sizeof(struct sockaddr_in6),
flags);
} else {
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
uv__set_sys_error(handle->loop, WSAEAFNOSUPPORT);
return -1;
}
}

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

@ -94,3 +94,32 @@ done:
return retVal;
}
void uv_loadavg(double avg[3]) {
/* Can't be implemented */
avg[0] = avg[1] = avg[2] = 0;
}
double uv_get_free_memory(void) {
MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof(memory_status);
if(!GlobalMemoryStatusEx(&memory_status))
{
return -1;
}
return (double)memory_status.ullAvailPhys;
}
double uv_get_total_memory(void) {
MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof(memory_status);
if(!GlobalMemoryStatusEx(&memory_status))
{
return -1;
}
return (double)memory_status.ullTotalPhys;
}

42
deps/uv/test/test-fs-event.c

@ -25,11 +25,12 @@
#include <string.h>
#include <fcntl.h>
uv_fs_event_t fs_event;
uv_timer_t timer;
int timer_cb_called;
int close_cb_called;
int fs_event_cb_called;
static uv_fs_event_t fs_event;
static uv_timer_t timer;
static int timer_cb_called;
static int close_cb_called;
static int fs_event_cb_called;
static int timer_cb_touch_called;
static void create_dir(uv_loop_t* loop, const char* name) {
int r;
@ -84,7 +85,7 @@ static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_RENAME);
ASSERT(strcmp(filename, "file1") == 0);
ASSERT(filename == NULL || strcmp(filename, "file1") == 0);
uv_close((uv_handle_t*)handle, close_cb);
}
@ -94,7 +95,7 @@ static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
ASSERT(strcmp(filename, "file2") == 0);
ASSERT(filename == NULL || strcmp(filename, "file2") == 0);
uv_close((uv_handle_t*)handle, close_cb);
}
@ -104,7 +105,7 @@ static void fs_event_cb_file_current_dir(uv_fs_event_t* handle,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
ASSERT(strcmp(filename, "watch_file") == 0);
ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0);
uv_close((uv_handle_t*)handle, close_cb);
}
@ -125,6 +126,13 @@ static void timer_cb_file(uv_timer_t* handle, int status) {
}
}
static void timer_cb_touch(uv_timer_t* timer, int status) {
ASSERT(status == 0);
uv_close((uv_handle_t*)timer, NULL);
touch_file(timer->loop, "watch_file");
timer_cb_touch_called++;
}
TEST_IMPL(fs_event_watch_dir) {
uv_fs_t fs_req;
uv_loop_t* loop = uv_default_loop();
@ -192,10 +200,13 @@ TEST_IMPL(fs_event_watch_file) {
}
TEST_IMPL(fs_event_watch_file_current_dir) {
uv_timer_t timer;
uv_loop_t* loop;
uv_fs_t fs_req;
uv_loop_t* loop = uv_default_loop();
int r;
loop = uv_default_loop();
/* Setup */
uv_fs_unlink(loop, &fs_req, "watch_file", NULL);
create_file(loop, "watch_file");
@ -203,11 +214,20 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
r = uv_fs_event_init(loop, &fs_event, "watch_file",
fs_event_cb_file_current_dir);
ASSERT(r != -1);
touch_file(loop, "watch_file");
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
r = uv_timer_start(&timer, timer_cb_touch, 1, 0);
ASSERT(r == 0);
ASSERT(timer_cb_touch_called == 0);
ASSERT(fs_event_cb_called == 0);
ASSERT(close_cb_called == 0);
uv_run(loop);
ASSERT(timer_cb_touch_called == 1);
ASSERT(fs_event_cb_called == 1);
ASSERT(close_cb_called == 1);

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

@ -1260,4 +1260,4 @@ TEST_IMPL(fs_stat_missing_path) {
uv_fs_req_cleanup(&req);
return 0;
}
}

19
deps/uv/include/uv-private/uv-linux.h → deps/uv/test/test-get-loadavg.c

@ -19,11 +19,18 @@
* IN THE SOFTWARE.
*/
#ifndef UV_LINUX_H
#define UV_LINUX_H
#include "uv.h"
#include "task.h"
#define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io read_watcher; \
uv_fs_event_cb cb; \
TEST_IMPL(get_loadavg) {
#endif /* UV_LINUX_H */
double avg[3];
uv_loadavg(avg);
ASSERT(avg != NULL);
ASSERT(avg[0] >= 0);
ASSERT(avg[1] >= 0);
ASSERT(avg[2] >= 0);
return 0;
}

34
deps/uv/test/test-get-memory.c

@ -0,0 +1,34 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
TEST_IMPL(get_memory) {
double free_mem = uv_get_free_memory();
double total_mem = uv_get_total_memory();
ASSERT(free_mem > 0);
ASSERT(total_mem > 0);
ASSERT(total_mem > free_mem);
return 0;
}

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

@ -61,12 +61,14 @@ TEST_DECLARE (idle_starvation)
TEST_DECLARE (loop_handles)
TEST_DECLARE (ref)
TEST_DECLARE (idle_ref)
TEST_DECLARE (get_loadavg)
TEST_DECLARE (async_ref)
TEST_DECLARE (prepare_ref)
TEST_DECLARE (check_ref)
TEST_DECLARE (unref_in_prepare_cb)
TEST_DECLARE (async)
TEST_DECLARE (get_currentexe)
TEST_DECLARE (get_memory)
TEST_DECLARE (hrtime)
TEST_DECLARE (getaddrinfo_basic)
TEST_DECLARE (getaddrinfo_concurrent)
@ -185,6 +187,10 @@ TASK_LIST_START
TEST_ENTRY (get_currentexe)
TEST_ENTRY (get_memory)
TEST_ENTRY (get_loadavg)
TEST_ENTRY (hrtime)
TEST_ENTRY (getaddrinfo_basic)

70
deps/uv/test/test-tcp-connect-error.c

@ -0,0 +1,70 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
#include <stdio.h>
#include <stdlib.h>
static int connect_cb_called = 0;
static int close_cb_called = 0;
static void connect_cb(uv_connect_t* handle, int status) {
ASSERT(handle != NULL);
connect_cb_called++;
}
static void close_cb(uv_handle_t* handle) {
ASSERT(handle != NULL);
close_cb_called++;
}
TEST_IMPL(tcp_connect_error_fault) {
char garbage[] = "blah blah blah blah blah blah blah blah blah blah blah blah";
struct sockaddr_in* garbage_addr;
uv_tcp_t server;
int r;
uv_connect_t req;
garbage_addr = (struct sockaddr_in*) &garbage;
r = uv_tcp_init(uv_default_loop(), &server);
ASSERT(r == 0);
r = uv_tcp_connect(&req, &server, *garbage_addr, connect_cb);
ASSERT(r == -1);
ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL);
uv_close((uv_handle_t*)&server, close_cb);
uv_run(uv_default_loop());
ASSERT(connect_cb_called == 0);
ASSERT(close_cb_called == 1);
return 0;
}

68
deps/uv/test/test-tcp-connect6-error.c

@ -0,0 +1,68 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
#include <stdio.h>
#include <stdlib.h>
static int connect_cb_called = 0;
static int close_cb_called = 0;
static void connect_cb(uv_connect_t* handle, int status) {
ASSERT(handle != NULL);
connect_cb_called++;
}
static void close_cb(uv_handle_t* handle) {
ASSERT(handle != NULL);
close_cb_called++;
}
TEST_IMPL(tcp_connect6_error_fault) {
char garbage[] = "blah blah blah blah blah blah blah blah blah blah blah blah";
struct sockaddr_in6* garbage_addr;
uv_tcp_t server;
int r;
uv_connect_t req;
garbage_addr = (struct sockaddr_in6*) &garbage;
r = uv_tcp_init(uv_default_loop(), &server);
ASSERT(r == 0);
r = uv_tcp_connect6(&req, &server, *garbage_addr, connect_cb);
ASSERT(r == -1);
ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL);
uv_close((uv_handle_t*)&server, close_cb);
uv_run(uv_default_loop());
ASSERT(connect_cb_called == 0);
ASSERT(close_cb_called == 1);
return 0;
}

20
deps/uv/uv.gyp

@ -215,7 +215,10 @@
'EIO_CONFIG_H="config_sunos.h"',
],
'direct_dependent_settings': {
'libraries': [ '-lrt' ],
'libraries': [
'-lsocket',
'-lnsl',
],
},
}],
[ 'OS=="freebsd"', {
@ -226,6 +229,9 @@
'EIO_CONFIG_H="config_freebsd.h"',
],
}],
[ 'OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
'sources': [ 'src/unix/kqueue.c' ],
}],
]
},
@ -238,6 +244,7 @@
'test/run-tests.c',
'test/runner.c',
'test/runner.h',
'test/test-get-loadavg.c',
'test/task.h',
'test/test-async.c',
'test/test-callback-stack.c',
@ -247,6 +254,7 @@
'test/test-fs.c',
'test/test-fs-event.c',
'test/test-get-currentexe.c',
'test/test-get-memory.c',
'test/test-getaddrinfo.c',
'test/test-gethostbyname.c',
'test/test-getsockname.c',
@ -263,6 +271,8 @@
'test/test-tcp-bind-error.c',
'test/test-tcp-bind6-error.c',
'test/test-tcp-close.c',
'test/test-tcp-connect-error.c',
'test/test-tcp-connect6-error.c',
'test/test-tcp-write-error.c',
'test/test-tcp-writealot.c',
'test/test-threadpool.c',
@ -287,7 +297,13 @@
'test/runner-unix.c',
'test/runner-unix.h',
]
}]
}],
[ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE
'defines': [
'__EXTENSIONS__',
'_XOPEN_SOURCE=500',
],
}],
],
'msvs-settings': {
'VCLinkerTool': {

Loading…
Cancel
Save