Browse Source

Upgrade libuv to 90e15f1110

v0.7.4-release
Bert Belder 13 years ago
parent
commit
2f22024806
  1. 20
      deps/uv/build/gcc_version.py
  2. 15
      deps/uv/common.gypi
  3. 14
      deps/uv/include/uv-private/uv-unix.h
  4. 4
      deps/uv/include/uv-private/uv-win.h
  5. 323
      deps/uv/include/uv.h
  6. 3
      deps/uv/src/ares/config_win32/ares_config.h
  7. 4
      deps/uv/src/unix/core.c
  8. 59
      deps/uv/src/unix/dl.c
  9. 5
      deps/uv/src/unix/error.c
  10. 84
      deps/uv/src/unix/sunos.c
  11. 9
      deps/uv/src/uv-common.c
  12. 1
      deps/uv/src/uv-common.h
  13. 63
      deps/uv/src/win/dl.c
  14. 2
      deps/uv/src/win/error.c
  15. 2
      deps/uv/src/win/internal.h
  16. 4
      deps/uv/src/win/pipe.c
  17. 166
      deps/uv/src/win/tcp.c
  18. 2
      deps/uv/test/test-list.h
  19. 102
      deps/uv/test/test-multiple-listen.c
  20. 3
      deps/uv/test/test-stdio-over-pipes.c
  21. 17
      deps/uv/uv.gyp

20
deps/uv/build/gcc_version.py

@ -0,0 +1,20 @@
#!/usr/bin/env python
import os
import re
import subprocess
import sys
def DoMain(*args):
cc = os.environ.get('CC', 'gcc')
stdin, stderr = os.pipe()
subprocess.call([cc, '-v'], stderr=stderr)
output = os.read(stdin, 4096)
match = re.search("\ngcc version (\d+\.\d+\.\d+)", output)
if match:
print(match.group(1))
if __name__ == '__main__':
DoMain(*sys.argv)

15
deps/uv/common.gypi

@ -114,9 +114,11 @@
], ],
}], }],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
'cflags': [ '-Wall', '-pthread', ], 'variables': {
'gcc_version%': '<!(python build/gcc_version.py)>)',
},
'cflags': [ '-Wall' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ], 'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
'ldflags': [ '-pthread', ],
'conditions': [ 'conditions': [
[ 'host_arch != target_arch and target_arch=="ia32"', { [ 'host_arch != target_arch and target_arch=="ia32"', {
'cflags': [ '-m32' ], 'cflags': [ '-m32' ],
@ -125,7 +127,14 @@
[ 'OS=="linux"', { [ 'OS=="linux"', {
'cflags': [ '-ansi' ], 'cflags': [ '-ansi' ],
}], }],
[ 'visibility=="hidden"', { [ 'OS=="solaris"', {
'cflags': [ '-pthreads' ],
'ldflags': [ '-pthreads' ],
}, {
'cflags': [ '-pthread' ],
'ldflags': [ '-pthread' ],
}],
[ 'visibility=="hidden" and gcc_version >= "4.0.0"', {
'cflags': [ '-fvisibility=hidden' ], 'cflags': [ '-fvisibility=hidden' ],
}], }],
], ],

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

@ -43,6 +43,10 @@ typedef struct {
typedef int uv_file; typedef int uv_file;
/* Platform-specific definitions for uv_dlopen support. */
typedef void* uv_lib_t;
#define UV_DYNAMIC /* empty */
#define UV_LOOP_PRIVATE_FIELDS \ #define UV_LOOP_PRIVATE_FIELDS \
ares_channel channel; \ ares_channel channel; \
/* \ /* \
@ -195,6 +199,16 @@ typedef int uv_file;
uv_fs_event_cb cb; \ uv_fs_event_cb cb; \
int fflags; \ int fflags; \
#elif defined(__sun)
#include <sys/port.h>
#include <port.h>
#define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io event_watcher; \
uv_fs_event_cb cb; \
file_obj_t fo; \
#else #else
/* Stub for platforms where the file watcher isn't implemented yet. */ /* Stub for platforms where the file watcher isn't implemented yet. */

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

@ -137,6 +137,10 @@ typedef struct uv_buf_t {
typedef int uv_file; typedef int uv_file;
/* Platform-specific definitions for uv_dlopen support. */
typedef HMODULE uv_lib_t;
#define UV_DYNAMIC FAR WINAPI
RB_HEAD(uv_timer_tree_s, uv_timer_s); RB_HEAD(uv_timer_tree_s, uv_timer_s);
#define UV_LOOP_PRIVATE_FIELDS \ #define UV_LOOP_PRIVATE_FIELDS \

323
deps/uv/include/uv.h

@ -27,10 +27,29 @@
extern "C" { extern "C" {
#endif #endif
#ifdef _WIN32
/* Windows - set up dll import/export decorators. */
# if defined(BUILDING_UV_SHARED)
/* Building shared library. Export everything from c-ares as well. */
# define UV_EXTERN __declspec(dllexport)
# define CARES_BUILDING_LIBRARY 1
# elif defined(USING_UV_SHARED)
/* Using shared library. Use shared c-ares as well. */
# define UV_EXTERN __declspec(dllimport)
# else
/* Building static library. Build c-ares statically as well. */
# define UV_EXTERN /* nothing */
# define CARES_STATICLIB 1
# endif
#else
/* Unix. TODO: symbol hiding */
# define UV_EXTERN /* nothing */
#endif
#define UV_VERSION_MAJOR 0 #define UV_VERSION_MAJOR 0
#define UV_VERSION_MINOR 1 #define UV_VERSION_MINOR 1
#define CARES_STATICLIB 1
#include <stdint.h> /* int64_t */ #include <stdint.h> /* int64_t */
#include <sys/types.h> /* size_t */ #include <sys/types.h> /* size_t */
@ -52,6 +71,7 @@ typedef enum {
UV_UNKNOWN = -1, UV_UNKNOWN = -1,
UV_OK = 0, UV_OK = 0,
UV_EOF, UV_EOF,
UV_EADDRINFO,
UV_EACCESS, UV_EACCESS,
UV_EAGAIN, UV_EAGAIN,
UV_EADDRINUSE, UV_EADDRINUSE,
@ -170,30 +190,30 @@ typedef struct uv_work_s uv_work_t;
* All callbacks in libuv are made asynchronously. That is they are never * All callbacks in libuv are made asynchronously. That is they are never
* made by the function that takes them as a parameter. * made by the function that takes them as a parameter.
*/ */
uv_loop_t* uv_loop_new(); UV_EXTERN uv_loop_t* uv_loop_new();
void uv_loop_delete(uv_loop_t*); UV_EXTERN void uv_loop_delete(uv_loop_t*);
/* /*
* Returns the default loop. * Returns the default loop.
*/ */
uv_loop_t* uv_default_loop(); UV_EXTERN uv_loop_t* uv_default_loop();
/* /*
* This function starts the event loop. It blocks until the reference count * This function starts the event loop. It blocks until the reference count
* of the loop drops to zero. * of the loop drops to zero.
*/ */
int uv_run(uv_loop_t*); UV_EXTERN int uv_run (uv_loop_t*);
/* /*
* Manually modify the event loop's reference count. Useful if the user wants * Manually modify the event loop's reference count. Useful if the user wants
* to have a handle or timeout that doesn't keep the loop alive. * to have a handle or timeout that doesn't keep the loop alive.
*/ */
void uv_ref(uv_loop_t*); UV_EXTERN void uv_ref(uv_loop_t*);
void uv_unref(uv_loop_t*); UV_EXTERN void uv_unref(uv_loop_t*);
void uv_update_time(uv_loop_t*); UV_EXTERN void uv_update_time(uv_loop_t*);
int64_t uv_now(uv_loop_t*); UV_EXTERN int64_t uv_now(uv_loop_t*);
/* /*
@ -260,9 +280,9 @@ struct uv_err_s {
* On error the user should then call uv_last_error() to determine * On error the user should then call uv_last_error() to determine
* the error code. * the error code.
*/ */
uv_err_t uv_last_error(uv_loop_t*); UV_EXTERN uv_err_t uv_last_error(uv_loop_t*);
char* uv_strerror(uv_err_t err); UV_EXTERN const char* uv_strerror(uv_err_t err);
const char* uv_err_name(uv_err_t err); UV_EXTERN const char* uv_err_name(uv_err_t err);
#define UV_REQ_FIELDS \ #define UV_REQ_FIELDS \
@ -291,7 +311,8 @@ UV_PRIVATE_REQ_TYPES
* initialized stream. req should be an uninitalized shutdown request * initialized stream. req should be an uninitalized shutdown request
* struct. The cb is a called after shutdown is complete. * struct. The cb is a called after shutdown is complete.
*/ */
int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb); UV_EXTERN int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle,
uv_shutdown_cb cb);
struct uv_shutdown_s { struct uv_shutdown_s {
UV_REQ_FIELDS UV_REQ_FIELDS
@ -320,7 +341,7 @@ struct uv_handle_s {
* Returns 1 if the prepare/check/idle handle has been started, 0 otherwise. * Returns 1 if the prepare/check/idle handle has been started, 0 otherwise.
* For other handle types this always returns 1. * For other handle types this always returns 1.
*/ */
int uv_is_active(uv_handle_t* handle); UV_EXTERN int uv_is_active(uv_handle_t* handle);
/* /*
* Request handle to be closed. close_cb will be called asynchronously after * Request handle to be closed. close_cb will be called asynchronously after
@ -330,7 +351,7 @@ int uv_is_active(uv_handle_t* handle);
* close_cb will still be deferred to the next iteration of the event loop. * close_cb will still be deferred to the next iteration of the event loop.
* It gives you a chance to free up any resources associated with the handle. * It gives you a chance to free up any resources associated with the handle.
*/ */
void uv_close(uv_handle_t* handle, uv_close_cb close_cb); UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
/* /*
@ -339,7 +360,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
* base and len members of the uv_buf_t struct. The user is responsible for * base and len members of the uv_buf_t struct. The user is responsible for
* freeing base after the uv_buf_t is done. Return struct passed by value. * freeing base after the uv_buf_t is done. Return struct passed by value.
*/ */
uv_buf_t uv_buf_init(char* base, size_t len); UV_EXTERN uv_buf_t uv_buf_init(char* base, size_t len);
#define UV_STREAM_FIELDS \ #define UV_STREAM_FIELDS \
@ -364,7 +385,7 @@ struct uv_stream_s {
UV_STREAM_FIELDS UV_STREAM_FIELDS
}; };
int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
/* /*
* This call is used in conjunction with uv_listen() to accept incoming * This call is used in conjunction with uv_listen() to accept incoming
@ -377,7 +398,7 @@ int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
* once, it may fail. It is suggested to only call uv_accept once per * once, it may fail. It is suggested to only call uv_accept once per
* uv_connection_cb call. * uv_connection_cb call.
*/ */
int uv_accept(uv_stream_t* server, uv_stream_t* client); UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client);
/* /*
* Read data from an incoming stream. The callback will be made several * Read data from an incoming stream. The callback will be made several
@ -389,15 +410,17 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client);
* eof; it happens when libuv requested a buffer through the alloc callback * eof; it happens when libuv requested a buffer through the alloc callback
* but then decided that it didn't need that buffer. * but then decided that it didn't need that buffer.
*/ */
int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb); UV_EXTERN int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb,
uv_read_cb read_cb);
int uv_read_stop(uv_stream_t*); UV_EXTERN int uv_read_stop(uv_stream_t*);
/* /*
* Extended read methods for receiving handles over a pipe. The pipe must be * Extended read methods for receiving handles over a pipe. The pipe must be
* initialized with ipc == 1. * initialized with ipc == 1.
*/ */
int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read2_cb read_cb); UV_EXTERN int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb,
uv_read2_cb read_cb);
/* /*
@ -418,11 +441,11 @@ int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read2_cb read_cb);
* uv_write(req, stream, b, 2); * uv_write(req, stream, b, 2);
* *
*/ */
int uv_write(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt, UV_EXTERN int uv_write(uv_write_t* req, uv_stream_t* handle,
uv_write_cb cb); uv_buf_t bufs[], int bufcnt, uv_write_cb cb);
int uv_write2(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt, UV_EXTERN int uv_write2(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[],
uv_stream_t* send_handle, uv_write_cb cb); int bufcnt, uv_stream_t* send_handle, uv_write_cb cb);
/* uv_write_t is a subclass of uv_req_t */ /* uv_write_t is a subclass of uv_req_t */
struct uv_write_s { struct uv_write_s {
@ -446,21 +469,24 @@ struct uv_tcp_s {
UV_TCP_PRIVATE_FIELDS UV_TCP_PRIVATE_FIELDS
}; };
int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
/* Enable/disable Nagle's algorithm. */ /* Enable/disable Nagle's algorithm. */
int uv_tcp_nodelay(uv_tcp_t* handle, int enable); UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
/* Enable/disable TCP keep-alive. /* Enable/disable TCP keep-alive.
* *
* `ms` is the initial delay in seconds, ignored when `enable` is zero. * `ms` is the initial delay in seconds, ignored when `enable` is zero.
*/ */
int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay); UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, int enable,
unsigned int delay);
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in); UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in);
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6); UV_EXTERN int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6);
int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name, int* namelen); UV_EXTERN int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name, int* namelen); int* namelen);
UV_EXTERN int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
int* namelen);
/* /*
* uv_tcp_connect, uv_tcp_connect6 * uv_tcp_connect, uv_tcp_connect6
@ -468,9 +494,9 @@ int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name, int* namelen);
* initialized TCP handle and an uninitialized uv_connect_t*. The callback * initialized TCP handle and an uninitialized uv_connect_t*. The callback
* will be made when the connection is estabished. * will be made when the connection is estabished.
*/ */
int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, UV_EXTERN int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
struct sockaddr_in address, uv_connect_cb cb); struct sockaddr_in address, uv_connect_cb cb);
int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle, UV_EXTERN int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
struct sockaddr_in6 address, uv_connect_cb cb); struct sockaddr_in6 address, uv_connect_cb cb);
/* uv_connect_t is a subclass of uv_req_t */ /* uv_connect_t is a subclass of uv_req_t */
@ -537,7 +563,7 @@ struct uv_udp_send_s {
* Initialize a new UDP handle. The actual socket is created lazily. * Initialize a new UDP handle. The actual socket is created lazily.
* Returns 0 on success. * Returns 0 on success.
*/ */
int uv_udp_init(uv_loop_t*, uv_udp_t* handle); UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
/* /*
* Bind to a IPv4 address and port. * Bind to a IPv4 address and port.
@ -550,7 +576,8 @@ int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned flags); UV_EXTERN int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
unsigned flags);
/* /*
* Bind to a IPv6 address and port. * Bind to a IPv6 address and port.
@ -563,14 +590,17 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr, unsigned flags);
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags); UV_EXTERN int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen); unsigned flags);
UV_EXTERN int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name,
int* namelen);
/* /*
* Set membership for a multicast address * Set membership for a multicast address
* *
* Arguments: * Arguments:
* handle UDP handle. Should have been initialized with `uv_udp_init`. * handle UDP handle. Should have been initialized with
* `uv_udp_init`.
* multicast_addr multicast address to set membership for * multicast_addr multicast address to set membership for
* interface_addr interface address * interface_addr interface address
* membership Should be UV_JOIN_GROUP or UV_LEAVE_GROUP * membership Should be UV_JOIN_GROUP or UV_LEAVE_GROUP
@ -578,8 +608,9 @@ int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen);
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
const char* interface_addr, uv_membership membership); const char* multicast_addr, const char* interface_addr,
uv_membership membership);
/* /*
* Send data. If the socket has not previously been bound with `uv_udp_bind` * Send data. If the socket has not previously been bound with `uv_udp_bind`
@ -597,8 +628,9 @@ int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr,
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[], UV_EXTERN int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle,
int bufcnt, struct sockaddr_in addr, uv_udp_send_cb send_cb); uv_buf_t bufs[], int bufcnt, struct sockaddr_in addr,
uv_udp_send_cb send_cb);
/* /*
* Send data. If the socket has not previously been bound with `uv_udp_bind6`, * Send data. If the socket has not previously been bound with `uv_udp_bind6`,
@ -615,8 +647,9 @@ int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_send6(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[], UV_EXTERN int uv_udp_send6(uv_udp_send_t* req, uv_udp_t* handle,
int bufcnt, struct sockaddr_in6 addr, uv_udp_send_cb send_cb); uv_buf_t bufs[], int bufcnt, struct sockaddr_in6 addr,
uv_udp_send_cb send_cb);
/* /*
* Receive data. If the socket has not previously been bound with `uv_udp_bind` * Receive data. If the socket has not previously been bound with `uv_udp_bind`
@ -631,7 +664,7 @@ int uv_udp_send6(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
uv_udp_recv_cb recv_cb); uv_udp_recv_cb recv_cb);
/* /*
@ -643,7 +676,7 @@ int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
* Returns: * Returns:
* 0 on success, -1 on error. * 0 on success, -1 on error.
*/ */
int uv_udp_recv_stop(uv_udp_t* handle); UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
/* /*
@ -668,23 +701,23 @@ struct uv_tty_s {
* *
* TTY streams which are not readable have blocking writes. * TTY streams which are not readable have blocking writes.
*/ */
int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
/* /*
* Set mode. 0 for normal, 1 for raw. * Set mode. 0 for normal, 1 for raw.
*/ */
int uv_tty_set_mode(uv_tty_t*, int mode); UV_EXTERN int uv_tty_set_mode(uv_tty_t*, int mode);
/* /*
* To be called when the program exits. Resets TTY settings to default * To be called when the program exits. Resets TTY settings to default
* values for the next process to take over. * values for the next process to take over.
*/ */
void uv_tty_reset_mode(); UV_EXTERN void uv_tty_reset_mode();
/* /*
* Gets the current Window size. On success zero is returned. * Gets the current Window size. On success zero is returned.
*/ */
int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
/* /*
* Used to detect what type of stream should be used with a given file * Used to detect what type of stream should be used with a given file
@ -692,7 +725,7 @@ int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
* type of the stdio streams. * type of the stdio streams.
* For isatty() functionality use this function and test for UV_TTY. * For isatty() functionality use this function and test for UV_TTY.
*/ */
uv_handle_type uv_guess_handle(uv_file file); UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
/* /*
* uv_pipe_t is a subclass of uv_stream_t * uv_pipe_t is a subclass of uv_stream_t
@ -711,16 +744,16 @@ struct uv_pipe_s {
* Initialize a pipe. The last argument is a boolean to indicate if * Initialize a pipe. The last argument is a boolean to indicate if
* this pipe will be used for handle passing between processes. * this pipe will be used for handle passing between processes.
*/ */
int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
/* /*
* Opens an existing file descriptor or HANDLE as a pipe. * Opens an existing file descriptor or HANDLE as a pipe.
*/ */
void uv_pipe_open(uv_pipe_t*, uv_file file); UV_EXTERN void uv_pipe_open(uv_pipe_t*, uv_file file);
int uv_pipe_bind(uv_pipe_t* handle, const char* name); UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, UV_EXTERN int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
const char* name, uv_connect_cb cb); const char* name, uv_connect_cb cb);
@ -736,11 +769,11 @@ struct uv_prepare_s {
UV_PREPARE_PRIVATE_FIELDS UV_PREPARE_PRIVATE_FIELDS
}; };
int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare);
int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb);
int uv_prepare_stop(uv_prepare_t* prepare); UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare);
/* /*
@ -754,11 +787,11 @@ struct uv_check_s {
UV_CHECK_PRIVATE_FIELDS UV_CHECK_PRIVATE_FIELDS
}; };
int uv_check_init(uv_loop_t*, uv_check_t* check); UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check);
int uv_check_start(uv_check_t* check, uv_check_cb cb); UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb);
int uv_check_stop(uv_check_t* check); UV_EXTERN int uv_check_stop(uv_check_t* check);
/* /*
@ -774,11 +807,11 @@ struct uv_idle_s {
UV_IDLE_PRIVATE_FIELDS UV_IDLE_PRIVATE_FIELDS
}; };
int uv_idle_init(uv_loop_t*, uv_idle_t* idle); UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle);
int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb);
int uv_idle_stop(uv_idle_t* idle); UV_EXTERN int uv_idle_stop(uv_idle_t* idle);
/* /*
@ -796,14 +829,15 @@ struct uv_async_s {
UV_ASYNC_PRIVATE_FIELDS UV_ASYNC_PRIVATE_FIELDS
}; };
int uv_async_init(uv_loop_t*, uv_async_t* async, uv_async_cb async_cb); UV_EXTERN int uv_async_init(uv_loop_t*, uv_async_t* async,
uv_async_cb async_cb);
/* /*
* This can be called from other threads to wake up a libuv thread. * This can be called from other threads to wake up a libuv thread.
* *
* libuv is single threaded at the moment. * libuv is single threaded at the moment.
*/ */
int uv_async_send(uv_async_t* async); UV_EXTERN int uv_async_send(uv_async_t* async);
/* /*
@ -817,19 +851,19 @@ struct uv_timer_s {
UV_TIMER_PRIVATE_FIELDS UV_TIMER_PRIVATE_FIELDS
}; };
int uv_timer_init(uv_loop_t*, uv_timer_t* timer); UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* timer);
int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb, int64_t timeout, UV_EXTERN int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb,
int64_t repeat); int64_t timeout, int64_t repeat);
int uv_timer_stop(uv_timer_t* timer); UV_EXTERN int uv_timer_stop(uv_timer_t* timer);
/* /*
* Stop the timer, and if it is repeating restart it using the repeat value * Stop the timer, and if it is repeating restart it using the repeat value
* as the timeout. If the timer has never been started before it returns -1 and * as the timeout. If the timer has never been started before it returns -1 and
* sets the error to UV_EINVAL. * sets the error to UV_EINVAL.
*/ */
int uv_timer_again(uv_timer_t* timer); UV_EXTERN int uv_timer_again(uv_timer_t* timer);
/* /*
* Set the repeat value. Note that if the repeat value is set from a timer * Set the repeat value. Note that if the repeat value is set from a timer
@ -837,19 +871,17 @@ int uv_timer_again(uv_timer_t* timer);
* before, it will have been stopped. If it was repeating, then the old repeat * before, it will have been stopped. If it was repeating, then the old repeat
* value will have been used to schedule the next timeout. * value will have been used to schedule the next timeout.
*/ */
void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat); UV_EXTERN void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat);
int64_t uv_timer_get_repeat(uv_timer_t* timer); UV_EXTERN int64_t uv_timer_get_repeat(uv_timer_t* timer);
/* c-ares integration initialize and terminate */ /* c-ares integration initialize and terminate */
int uv_ares_init_options(uv_loop_t*, UV_EXTERN int uv_ares_init_options(uv_loop_t*,
ares_channel *channelptr, ares_channel *channelptr, struct ares_options *options, int optmask);
struct ares_options *options,
int optmask);
/* TODO remove the loop argument from this function? */ /* TODO remove the loop argument from this function? */
void uv_ares_destroy(uv_loop_t*, ares_channel channel); UV_EXTERN void uv_ares_destroy(uv_loop_t*, ares_channel channel);
/* /*
@ -877,14 +909,11 @@ struct uv_getaddrinfo_s {
* *
* On error NXDOMAIN the status code will be non-zero and UV_ENOENT returned. * On error NXDOMAIN the status code will be non-zero and UV_ENOENT returned.
*/ */
int uv_getaddrinfo(uv_loop_t*, UV_EXTERN int uv_getaddrinfo(uv_loop_t*, uv_getaddrinfo_t* handle,
uv_getaddrinfo_t* handle, uv_getaddrinfo_cb getaddrinfo_cb, const char* node, const char* service,
uv_getaddrinfo_cb getaddrinfo_cb, const struct addrinfo* hints);
const char* node,
const char* service,
const struct addrinfo* hints);
void uv_freeaddrinfo(struct addrinfo* ai); UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);
/* uv_spawn() options */ /* uv_spawn() options */
typedef struct uv_process_options_s { typedef struct uv_process_options_s {
@ -934,13 +963,14 @@ struct uv_process_s {
}; };
/* Initializes uv_process_t and starts the process. */ /* Initializes uv_process_t and starts the process. */
int uv_spawn(uv_loop_t*, uv_process_t*, uv_process_options_t options); UV_EXTERN int uv_spawn(uv_loop_t*, uv_process_t*,
uv_process_options_t options);
/* /*
* Kills the process with the specified signal. The user must still * Kills the process with the specified signal. The user must still
* call uv_close on the process. * call uv_close on the process.
*/ */
int uv_process_kill(uv_process_t*, int signum); UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
/* /*
@ -955,8 +985,8 @@ struct uv_work_s {
}; };
/* Queues a work request to execute asynchronously on the thread pool. */ /* Queues a work request to execute asynchronously on the thread pool. */
int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
uv_after_work_cb after_work_cb); uv_work_cb work_cb, uv_after_work_cb after_work_cb);
@ -1018,58 +1048,66 @@ struct uv_fs_s {
UV_FS_PRIVATE_FIELDS UV_FS_PRIVATE_FIELDS
}; };
void uv_fs_req_cleanup(uv_fs_t* req); UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb); UV_EXTERN int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file,
uv_fs_cb cb);
int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, UV_EXTERN int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path,
int mode, uv_fs_cb cb); int flags, int mode, uv_fs_cb cb);
int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, UV_EXTERN int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file,
size_t length, off_t offset, uv_fs_cb cb); void* buf, size_t length, off_t offset, uv_fs_cb cb);
int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb); UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb);
int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf, UV_EXTERN int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file,
size_t length, off_t offset, uv_fs_cb cb); void* buf, size_t length, off_t offset, uv_fs_cb cb);
int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
int mode, uv_fs_cb cb);
UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb); uv_fs_cb cb);
int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb); UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req,
const char* path, int flags, uv_fs_cb cb);
int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, UV_EXTERN int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb); uv_fs_cb cb);
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb); UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file,
uv_fs_cb cb);
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, UV_EXTERN int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, uv_fs_cb cb); const char* new_path, uv_fs_cb cb);
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb); UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file,
uv_fs_cb cb);
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb); UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file,
uv_fs_cb cb);
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
off_t offset, uv_fs_cb cb); off_t offset, uv_fs_cb cb);
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb); uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb);
int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb); int mode, uv_fs_cb cb);
int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, UV_EXTERN int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path,
double mtime, uv_fs_cb cb); double atime, double mtime, uv_fs_cb cb);
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, UV_EXTERN int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file,
double mtime, uv_fs_cb cb); double atime, double mtime, uv_fs_cb cb);
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb); UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb);
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, UV_EXTERN int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, uv_fs_cb cb); const char* new_path, uv_fs_cb cb);
/* /*
@ -1078,20 +1116,20 @@ int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
*/ */
#define UV_FS_SYMLINK_DIR 0x0001 #define UV_FS_SYMLINK_DIR 0x0001
int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, int flags, uv_fs_cb cb); const char* new_path, int flags, uv_fs_cb cb);
int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb); uv_fs_cb cb);
int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file,
uv_fs_cb cb); int mode, uv_fs_cb cb);
int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid, UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,
int gid, uv_fs_cb cb); int uid, int gid, uv_fs_cb cb);
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid, UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,
int gid, uv_fs_cb cb); int uid, int gid, uv_fs_cb cb);
enum uv_fs_event { enum uv_fs_event {
@ -1112,32 +1150,32 @@ struct uv_fs_event_s {
* See: http://en.wikipedia.org/wiki/Load_(computing) * See: http://en.wikipedia.org/wiki/Load_(computing)
* (Returns [0,0,0] for windows and cygwin) * (Returns [0,0,0] for windows and cygwin)
*/ */
void uv_loadavg(double avg[3]); UV_EXTERN void uv_loadavg(double avg[3]);
/* /*
* If filename is a directory then we will watch for all events in that * 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 * directory. If filename is a file - we will only get events from that
* file. Subdirectories are not watched. * file. Subdirectories are not watched.
*/ */
int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle, UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
const char* filename, uv_fs_event_cb cb); const char* filename, uv_fs_event_cb cb);
/* Utility */ /* Utility */
/* Convert string ip addresses to binary structures */ /* Convert string ip addresses to binary structures */
struct sockaddr_in uv_ip4_addr(const char* ip, int port); UV_EXTERN struct sockaddr_in uv_ip4_addr(const char* ip, int port);
struct sockaddr_in6 uv_ip6_addr(const char* ip, int port); UV_EXTERN struct sockaddr_in6 uv_ip6_addr(const char* ip, int port);
/* Convert binary addresses to strings */ /* Convert binary addresses to strings */
int uv_ip4_name(struct sockaddr_in* src, char* dst, size_t size); UV_EXTERN int uv_ip4_name(struct sockaddr_in* src, char* dst, size_t size);
int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size); UV_EXTERN int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size);
/* Gets the executable path */ /* Gets the executable path */
int uv_exepath(char* buffer, size_t* size); UV_EXTERN int uv_exepath(char* buffer, size_t* size);
/* Gets memory info in bytes */ /* Gets memory info in bytes */
uint64_t uv_get_free_memory(void); UV_EXTERN uint64_t uv_get_free_memory(void);
uint64_t uv_get_total_memory(void); UV_EXTERN uint64_t uv_get_total_memory(void);
/* /*
* Returns the current high-resolution real time. This is expressed in * Returns the current high-resolution real time. This is expressed in
@ -1148,7 +1186,20 @@ uint64_t uv_get_total_memory(void);
* Note not every platform can support nanosecond resolution; however, this * Note not every platform can support nanosecond resolution; however, this
* value will always be in nanoseconds. * value will always be in nanoseconds.
*/ */
extern uint64_t uv_hrtime(void); UV_EXTERN extern uint64_t uv_hrtime(void);
/*
* Opens a shared library. The filename is in utf-8. On success, -1 is
* and the variable pointed by library receives a handle to the library.
*/
UV_EXTERN uv_err_t uv_dlopen(const char* filename, uv_lib_t* library);
UV_EXTERN uv_err_t uv_dlclose(uv_lib_t library);
/*
* Retrieves a data pointer from a dynamic library.
*/
UV_EXTERN uv_err_t uv_dlsym(uv_lib_t library, const char* name, void** ptr);
/* the presence of these unions force similar struct layout */ /* the presence of these unions force similar struct layout */

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

@ -4,9 +4,6 @@
/* when building c-ares library */ /* when building c-ares library */
#define CARES_BUILDING_LIBRARY 1 #define CARES_BUILDING_LIBRARY 1
/* when not building a shared library */
#define CARES_STATICLIB 1
/* Copyright (C) 2004 - 2008 by Daniel Stenberg et al /* Copyright (C) 2004 - 2008 by Daniel Stenberg et al
* *
* Permission to use, copy, modify, and distribute this software and its * Permission to use, copy, modify, and distribute this software and its

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

@ -594,8 +594,8 @@ static int uv_getaddrinfo_done(eio_req* req) {
free(handle->hostname); free(handle->hostname);
if (handle->retcode != 0) { if (handle->retcode != 0) {
/* TODO how to display gai error strings? */ handle->loop->last_err.code = UV_EADDRINFO;
uv__set_sys_error(handle->loop, handle->retcode); handle->loop->last_err.sys_errno_ = handle->retcode;
} }
handle->cb(handle, handle->retcode, res); handle->cb(handle, handle->retcode, res);

59
deps/uv/src/unix/dl.c

@ -0,0 +1,59 @@
/* 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 <dlfcn.h>
#include <errno.h>
static const uv_err_t uv_ok_ = { UV_OK, 0 };
uv_err_t uv_dlopen(const char* filename, uv_lib_t* library) {
void* handle = dlopen(filename, RTLD_LAZY);
if (handle == NULL) {
return uv__new_sys_error(errno);
}
*library = handle;
return uv_ok_;
}
uv_err_t uv_dlclose(uv_lib_t library) {
if (dlclose(library) != 0) {
return uv__new_sys_error(errno);
}
return uv_ok_;
}
uv_err_t uv_dlsym(uv_lib_t library, const char* name, void** ptr) {
void* address = dlsym(library, name);
if (address == NULL) {
return uv__new_sys_error(errno);
}
*ptr = (void*) address;
return uv_ok_;
}

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

@ -118,7 +118,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
* a) rely on what the system provides us * a) rely on what the system provides us
* b) reverse-map the error codes * b) reverse-map the error codes
*/ */
char* uv_strerror(uv_err_t err) { const char* uv_strerror(uv_err_t err) {
int errorno; int errorno;
if (err.sys_errno_) if (err.sys_errno_)
@ -126,6 +126,9 @@ char* uv_strerror(uv_err_t err) {
else else
errorno = uv__translate_lib_error(err.code); errorno = uv__translate_lib_error(err.code);
if (err.code == UV_EADDRINFO)
return gai_strerror(errorno);
if (errorno == -1) if (errorno == -1)
return "Unknown error"; return "Unknown error";
else else

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

@ -23,13 +23,17 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h>
#include <sys/loadavg.h> #include <sys/loadavg.h>
#include <sys/time.h>
#include <sys/port.h>
#include <unistd.h> #include <unistd.h>
#include <kstat.h> #include <kstat.h>
#include <port.h>
uint64_t uv_hrtime() { uint64_t uv_hrtime() {
@ -81,15 +85,87 @@ void uv_loadavg(double avg[3]) {
} }
static void uv__fs_event_rearm(uv_fs_event_t *handle) {
if (port_associate(handle->fd,
PORT_SOURCE_FILE,
(uintptr_t) &handle->fo,
FILE_ATTRIB | FILE_MODIFIED,
NULL) == -1) {
uv__set_sys_error(handle->loop, errno);
}
}
static void uv__fs_event_read(EV_P_ ev_io* w, int revents) {
uv_fs_event_t *handle;
timespec_t timeout;
port_event_t pe;
int events;
int r;
handle = container_of(w, uv_fs_event_t, event_watcher);
do {
/* TODO use port_getn() */
do {
memset(&timeout, 0, sizeof timeout);
r = port_get(handle->fd, &pe, &timeout);
}
while (r == -1 && errno == EINTR);
if (r == -1 && errno == ETIME)
break;
assert((r == 0) && "unexpected port_get() error");
events = 0;
if (pe.portev_events & (FILE_ATTRIB | FILE_MODIFIED))
events |= UV_CHANGE;
if (pe.portev_events & ~(FILE_ATTRIB | FILE_MODIFIED))
events |= UV_RENAME;
assert(events != 0);
handle->cb(handle, NULL, events, 0);
}
while (handle->fd != -1);
if (handle->fd != -1)
uv__fs_event_rearm(handle);
}
int uv_fs_event_init(uv_loop_t* loop, int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle, uv_fs_event_t* handle,
const char* filename, const char* filename,
uv_fs_event_cb cb) { uv_fs_event_cb cb) {
uv__set_sys_error(loop, ENOSYS); int portfd;
return -1;
if ((portfd = port_create()) == -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->fd = portfd;
handle->cb = cb;
memset(&handle->fo, 0, sizeof handle->fo);
handle->fo.fo_name = handle->filename;
uv__fs_event_rearm(handle);
ev_io_init(&handle->event_watcher, uv__fs_event_read, portfd, EV_READ);
ev_io_start(loop->ev, &handle->event_watcher);
return 0;
} }
void uv__fs_event_destroy(uv_fs_event_t* handle) { void uv__fs_event_destroy(uv_fs_event_t* handle) {
assert(0 && "implement me"); ev_io_stop(handle->loop->ev, &handle->event_watcher);
uv__close(handle->fd);
handle->fd = -1;
free(handle->filename);
handle->filename = NULL;
handle->fo.fo_name = NULL;
} }

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

@ -53,6 +53,7 @@ const char* uv_err_name(uv_err_t err) {
case UV_UNKNOWN: return "UNKNOWN"; case UV_UNKNOWN: return "UNKNOWN";
case UV_OK: return "OK"; case UV_OK: return "OK";
case UV_EOF: return "EOF"; case UV_EOF: return "EOF";
case UV_EADDRINFO: return "EADDRINFO";
case UV_EACCESS: return "EACCESS"; case UV_EACCESS: return "EACCESS";
case UV_EAGAIN: return "EAGAIN"; case UV_EAGAIN: return "EAGAIN";
case UV_EADDRINUSE: return "EADDRINUSE"; case UV_EADDRINUSE: return "EADDRINUSE";
@ -115,6 +116,14 @@ void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code) {
} }
uv_err_t uv__new_sys_error(int sys_error) {
uv_err_t error;
error.code = uv_translate_sys_error(sys_error);
error.sys_errno_ = sys_error;
return error;
}
uv_err_t uv_last_error(uv_loop_t* loop) { uv_err_t uv_last_error(uv_loop_t* loop) {
return loop->last_err; return loop->last_err;
} }

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

@ -52,6 +52,7 @@ 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_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_sys_error(uv_loop_t* loop, int sys_error);
void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code); void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code);
uv_err_t uv__new_sys_error(int sys_error);
int uv__tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr); 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__tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr);

63
deps/uv/src/win/dl.c

@ -0,0 +1,63 @@
/* 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"
uv_err_t uv_dlopen(const char* filename, uv_lib_t* library) {
wchar_t filename_w[32768];
HMODULE handle;
if (!uv_utf8_to_utf16(filename,
filename_w,
sizeof(filename_w) / sizeof(wchar_t))) {
return uv__new_sys_error(GetLastError());
}
handle = LoadLibraryW(filename_w);
if (handle == NULL) {
return uv__new_sys_error(GetLastError());
}
*library = handle;
return uv_ok_;
}
uv_err_t uv_dlclose(uv_lib_t library) {
if (!FreeLibrary(library)) {
return uv__new_sys_error(GetLastError());
}
return uv_ok_;
}
uv_err_t uv_dlsym(uv_lib_t library, const char* name, void** ptr) {
FARPROC proc = GetProcAddress(library, name);
if (proc == NULL) {
return uv__new_sys_error(GetLastError());
}
*ptr = (void*) proc;
return uv_ok_;
}

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

@ -70,7 +70,7 @@ void uv_fatal_error(const int errorno, const char* syscall) {
/* TODO: thread safety */ /* TODO: thread safety */
static char* last_err_str_ = NULL; static char* last_err_str_ = NULL;
char* uv_strerror(uv_err_t err) { const char* uv_strerror(uv_err_t err) {
if (last_err_str_ != NULL) { if (last_err_str_ != NULL) {
LocalFree(last_err_str_); LocalFree(last_err_str_);
} }

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

@ -69,6 +69,8 @@ void uv_process_timers(uv_loop_t* loop);
#define UV_HANDLE_TTY_SAVED_POSITION 0x0400000 #define UV_HANDLE_TTY_SAVED_POSITION 0x0400000
#define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x0800000 #define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x0800000
#define UV_HANDLE_SHARED_TCP_SERVER 0x1000000 #define UV_HANDLE_SHARED_TCP_SERVER 0x1000000
#define UV_HANDLE_TCP_NODELAY 0x2000000
#define UV_HANDLE_TCP_KEEPALIVE 0x4000000
void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle); void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle);
void uv_process_endgames(uv_loop_t* loop); void uv_process_endgames(uv_loop_t* loop);

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

@ -956,7 +956,9 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req,
return -1; return -1;
} }
if (send_handle && send_handle->type != UV_TCP) { /* Only TCP server handles are supported for sharing. */
if (send_handle && (send_handle->type != UV_TCP ||
send_handle->flags & UV_HANDLE_CONNECTION)) {
uv__set_artificial_error(loop, UV_ENOTSUP); uv__set_artificial_error(loop, UV_ENOTSUP);
return -1; return -1;
} }

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

@ -46,6 +46,42 @@ static char uv_zero_[] = "";
static unsigned int active_tcp_streams = 0; static unsigned int active_tcp_streams = 0;
static int uv__tcp_nodelay(uv_tcp_t* handle, SOCKET socket, int enable) {
if (setsockopt(socket,
IPPROTO_TCP,
TCP_NODELAY,
(const char*)&enable,
sizeof enable) == -1) {
uv__set_sys_error(handle->loop, errno);
return -1;
}
return 0;
}
static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsigned int delay) {
if (setsockopt(socket,
SOL_SOCKET,
SO_KEEPALIVE,
(const char*)&enable,
sizeof enable) == -1) {
uv__set_sys_error(handle->loop, errno);
return -1;
}
if (enable && setsockopt(socket,
IPPROTO_TCP,
TCP_KEEPALIVE,
(const char*)&delay,
sizeof delay) == -1) {
uv__set_sys_error(handle->loop, errno);
return -1;
}
return 0;
}
static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle, static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
SOCKET socket, int imported) { SOCKET socket, int imported) {
DWORD yes = 1; DWORD yes = 1;
@ -89,6 +125,17 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle,
} }
} }
if ((handle->flags & UV_HANDLE_TCP_NODELAY) &&
uv__tcp_nodelay(handle, socket, 1)) {
return -1;
}
/* TODO: Use stored delay. */
if ((handle->flags & UV_HANDLE_TCP_KEEPALIVE) &&
uv__tcp_keepalive(handle, socket, 1, 60)) {
return -1;
}
handle->socket = socket; handle->socket = socket;
return 0; return 0;
@ -402,13 +449,6 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
return -1; return -1;
} }
if (handle->flags & UV_HANDLE_LISTENING ||
handle->flags & UV_HANDLE_READING) {
/* Already listening. */
uv__set_sys_error(loop, WSAEALREADY);
return -1;
}
if (!(handle->flags & UV_HANDLE_BOUND) && if (!(handle->flags & UV_HANDLE_BOUND) &&
uv_tcp_bind(handle, uv_addr_ip4_any_) < 0) uv_tcp_bind(handle, uv_addr_ip4_any_) < 0)
return -1; return -1;
@ -429,31 +469,32 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
handle->flags |= UV_HANDLE_LISTENING; handle->flags |= UV_HANDLE_LISTENING;
handle->connection_cb = cb; handle->connection_cb = cb;
assert(!handle->accept_reqs); if(!handle->accept_reqs) {
handle->accept_reqs = (uv_tcp_accept_t*) handle->accept_reqs = (uv_tcp_accept_t*)
malloc(uv_simultaneous_server_accepts * sizeof(uv_tcp_accept_t)); malloc(uv_simultaneous_server_accepts * sizeof(uv_tcp_accept_t));
if (!handle->accept_reqs) { if (!handle->accept_reqs) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
} }
for (i = 0; i < uv_simultaneous_server_accepts; i++) { for (i = 0; i < uv_simultaneous_server_accepts; i++) {
req = &handle->accept_reqs[i]; req = &handle->accept_reqs[i];
uv_req_init(loop, (uv_req_t*)req); uv_req_init(loop, (uv_req_t*)req);
req->type = UV_ACCEPT; req->type = UV_ACCEPT;
req->accept_socket = INVALID_SOCKET; req->accept_socket = INVALID_SOCKET;
req->data = handle; req->data = handle;
req->wait_handle = INVALID_HANDLE_VALUE; req->wait_handle = INVALID_HANDLE_VALUE;
if (handle->flags & UV_HANDLE_EMULATE_IOCP) { if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
req->event_handle = CreateEvent(NULL, 0, 0, NULL); req->event_handle = CreateEvent(NULL, 0, 0, NULL);
if (!req->event_handle) { if (!req->event_handle) {
uv_fatal_error(GetLastError(), "CreateEvent"); uv_fatal_error(GetLastError(), "CreateEvent");
}
} else {
req->event_handle = NULL;
} }
} else {
req->event_handle = NULL;
}
uv_tcp_queue_accept(handle, req); uv_tcp_queue_accept(handle, req);
}
} }
return 0; return 0;
@ -961,38 +1002,61 @@ int uv_tcp_import(uv_tcp_t* tcp, WSAPROTOCOL_INFOW* socket_protocol_info) {
int uv_tcp_nodelay(uv_tcp_t* handle, int enable) { int uv_tcp_nodelay(uv_tcp_t* handle, int enable) {
uv__set_artificial_error(handle->loop, UV_ENOSYS); if (handle->socket != INVALID_SOCKET &&
return -1; uv__tcp_nodelay(handle, handle->socket, enable)) {
return -1;
}
if (enable) {
handle->flags |= UV_HANDLE_TCP_NODELAY;
} else {
handle->flags &= ~UV_HANDLE_TCP_NODELAY;
}
return 0;
} }
int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) {
uv__set_artificial_error(handle->loop, UV_ENOSYS); if (handle->socket != INVALID_SOCKET &&
return -1; uv__tcp_keepalive(handle, handle->socket, enable, delay)) {
return -1;
}
if (enable) {
handle->flags |= UV_HANDLE_TCP_KEEPALIVE;
} else {
handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE;
}
/* TODO: Store delay if handle->socket isn't created yet. */
return 0;
} }
int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid,
LPWSAPROTOCOL_INFOW protocol_info) { LPWSAPROTOCOL_INFOW protocol_info) {
if (!(handle->flags & UV_HANDLE_CONNECTION)) { assert(!(handle->flags & UV_HANDLE_CONNECTION));
/*
* We're about to share the socket with another process. Because /*
* this is a server socket, we assume that the other process will * We're about to share the socket with another process. Because
* be accepting conections on this socket. So, before sharing the * this is a listening socket, we assume that the other process will
* socket with another process, we call listen here in the parent * be accepting conections on it. So, before sharing the socket
* process. This needs to be modified if the socket is shared with * with another process, we call listen here in the parent process.
* another process for anything other than accepting connections. * This needs to be modified if the socket is shared with
*/ * another process for anything other than accepting connections.
*/
if (!(handle->flags & UV_HANDLE_LISTENING)) {
if (!(handle->flags & UV_HANDLE_BOUND)) { if (!(handle->flags & UV_HANDLE_LISTENING)) {
uv__set_artificial_error(handle->loop, UV_EINVAL); if (!(handle->flags & UV_HANDLE_BOUND)) {
return -1; uv__set_artificial_error(handle->loop, UV_EINVAL);
} return -1;
if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) { }
uv__set_sys_error(handle->loop, WSAGetLastError()); if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) {
return -1; uv__set_sys_error(handle->loop, WSAGetLastError());
} return -1;
} }
handle->flags |= UV_HANDLE_SHARED_TCP_SERVER; handle->flags |= UV_HANDLE_SHARED_TCP_SERVER;

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

@ -29,6 +29,7 @@ TEST_DECLARE (tcp_ref)
TEST_DECLARE (tcp_ref2) TEST_DECLARE (tcp_ref2)
TEST_DECLARE (pipe_ping_pong) TEST_DECLARE (pipe_ping_pong)
TEST_DECLARE (delayed_accept) TEST_DECLARE (delayed_accept)
TEST_DECLARE (multiple_listen)
TEST_DECLARE (tcp_writealot) TEST_DECLARE (tcp_writealot)
TEST_DECLARE (tcp_bind_error_addrinuse) TEST_DECLARE (tcp_bind_error_addrinuse)
TEST_DECLARE (tcp_bind_error_addrnotavail_1) TEST_DECLARE (tcp_bind_error_addrnotavail_1)
@ -139,6 +140,7 @@ TASK_LIST_START
TEST_HELPER (pipe_ping_pong, pipe_echo_server) TEST_HELPER (pipe_ping_pong, pipe_echo_server)
TEST_ENTRY (delayed_accept) TEST_ENTRY (delayed_accept)
TEST_ENTRY (multiple_listen)
TEST_ENTRY (tcp_writealot) TEST_ENTRY (tcp_writealot)
TEST_HELPER (tcp_writealot, tcp4_echo_server) TEST_HELPER (tcp_writealot, tcp4_echo_server)

102
deps/uv/test/test-multiple-listen.c

@ -0,0 +1,102 @@
/* 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 connection_cb_called = 0;
static int close_cb_called = 0;
static int connect_cb_called = 0;
static uv_tcp_t server;
static uv_tcp_t client;
static void close_cb(uv_handle_t* handle) {
ASSERT(handle != NULL);
close_cb_called++;
}
static void connection_cb(uv_stream_t* tcp, int status) {
ASSERT(status == 0);
uv_close((uv_handle_t*)&server, close_cb);
connection_cb_called++;
}
static void start_server() {
struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", TEST_PORT);
int r;
r = uv_tcp_init(uv_default_loop(), &server);
ASSERT(r == 0);
r = uv_tcp_bind(&server, addr);
ASSERT(r == 0);
r = uv_listen((uv_stream_t*)&server, 128, connection_cb);
ASSERT(r == 0);
r = uv_listen((uv_stream_t*)&server, 128, connection_cb);
ASSERT(r == 0);
}
static void connect_cb(uv_connect_t* req, int status) {
ASSERT(req != NULL);
ASSERT(status == 0);
free(req);
uv_close((uv_handle_t*)&client, close_cb);
connect_cb_called++;
}
static void client_connect() {
struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
uv_connect_t* connect_req = malloc(sizeof *connect_req);
int r;
ASSERT(connect_req != NULL);
r = uv_tcp_init(uv_default_loop(), &client);
ASSERT(r == 0);
r = uv_tcp_connect(connect_req, &client, addr, connect_cb);
ASSERT(r == 0);
}
TEST_IMPL(multiple_listen) {
start_server();
client_connect();
uv_run(uv_default_loop());
ASSERT(connection_cb_called == 1);
ASSERT(connect_cb_called == 1);
ASSERT(close_cb_called == 2);
return 0;
}

3
deps/uv/test/test-stdio-over-pipes.c

@ -22,6 +22,9 @@
#include "uv.h" #include "uv.h"
#include "task.h" #include "task.h"
#include <stdlib.h>
#include <string.h>
static char exepath[1024]; static char exepath[1024];
static size_t exepath_size = 1024; static size_t exepath_size = 1024;

17
deps/uv/uv.gyp

@ -8,6 +8,15 @@
'_GNU_SOURCE', '_GNU_SOURCE',
'EIO_STACKSIZE=262144' 'EIO_STACKSIZE=262144'
], ],
'conditions': [
['OS=="solaris"', {
'cflags': ['-pthreads'],
'ldlags': ['-pthreads'],
}, {
'cflags': ['-pthread'],
'ldlags': ['-pthread'],
}],
],
}], }],
], ],
}, },
@ -29,6 +38,7 @@
'HAVE_CONFIG_H' 'HAVE_CONFIG_H'
], ],
'sources': [ 'sources': [
'common.gypi',
'include/ares.h', 'include/ares.h',
'include/ares_version.h', 'include/ares_version.h',
'include/uv.h', 'include/uv.h',
@ -120,6 +130,7 @@
'src/win/async.c', 'src/win/async.c',
'src/win/cares.c', 'src/win/cares.c',
'src/win/core.c', 'src/win/core.c',
'src/win/dl.c',
'src/win/error.c', 'src/win/error.c',
'src/win/fs.c', 'src/win/fs.c',
'src/win/fs-event.c', 'src/win/fs-event.c',
@ -172,6 +183,7 @@
'src/unix/tty.c', 'src/unix/tty.c',
'src/unix/stream.c', 'src/unix/stream.c',
'src/unix/cares.c', 'src/unix/cares.c',
'src/unix/dl.c',
'src/unix/error.c', 'src/unix/error.c',
'src/unix/process.c', 'src/unix/process.c',
'src/unix/internal.h', 'src/unix/internal.h',
@ -280,6 +292,7 @@
'test/test-ipc.c', 'test/test-ipc.c',
'test/test-list.h', 'test/test-list.h',
'test/test-loop-handles.c', 'test/test-loop-handles.c',
'test/test-multiple-listen.c',
'test/test-pass-always.c', 'test/test-pass-always.c',
'test/test-ping-pong.c', 'test/test-ping-pong.c',
'test/test-pipe-bind-error.c', 'test/test-pipe-bind-error.c',
@ -313,11 +326,10 @@
'libraries': [ 'ws2_32.lib' ] 'libraries': [ 'ws2_32.lib' ]
}, { # POSIX }, { # POSIX
'defines': [ '_GNU_SOURCE' ], 'defines': [ '_GNU_SOURCE' ],
'ldflags': [ '-pthread' ],
'sources': [ 'sources': [
'test/runner-unix.c', 'test/runner-unix.c',
'test/runner-unix.h', 'test/runner-unix.h',
] ],
}], }],
[ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE
'defines': [ 'defines': [
@ -365,7 +377,6 @@
'libraries': [ 'ws2_32.lib' ] 'libraries': [ 'ws2_32.lib' ]
}, { # POSIX }, { # POSIX
'defines': [ '_GNU_SOURCE' ], 'defines': [ '_GNU_SOURCE' ],
'ldflags': [ '-pthread' ],
'sources': [ 'sources': [
'test/runner-unix.c', 'test/runner-unix.c',
'test/runner-unix.h', 'test/runner-unix.h',

Loading…
Cancel
Save