Browse Source

Upgrade libuv to 2806b0386b266ee7377459b49156a60a15b1dfea

v0.7.4-release
Bert Belder 14 years ago
parent
commit
9e77b1a82e
  1. 2
      deps/uv/config-unix.mk
  2. 24
      deps/uv/include/ev.h
  3. 41
      deps/uv/src/uv-unix.c
  4. 3
      deps/uv/src/win/pipe.c
  5. 7
      deps/uv/test/runner.c
  6. 5
      deps/uv/test/test-pipe-bind-error.c

2
deps/uv/config-unix.mk

@ -21,7 +21,7 @@
CC = $(PREFIX)gcc
AR = $(PREFIX)ar
E=
CSTDFLAG=--std=c89 -pedantic
CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
CFLAGS=-g
CPPFLAGS += -Isrc/ev
LINKFLAGS=-lm

24
deps/uv/include/ev.h

@ -48,6 +48,12 @@
EV_CPP(extern "C" {)
#ifdef __GNUC__
# define EV_MAYBE_UNUSED __attribute__ ((unused))
#else
# define EV_MAYBE_UNUSED
#endif
/*****************************************************************************/
/* pre-4.0 compatibility */
@ -539,7 +545,7 @@ void ev_set_syserr_cb (void (*cb)(const char *msg));
struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0));
EV_INLINE struct ev_loop *
ev_default_loop_uc_ (void)
EV_MAYBE_UNUSED ev_default_loop_uc_ (void)
{
extern struct ev_loop *ev_default_loop_ptr;
@ -547,7 +553,7 @@ ev_default_loop_uc_ (void)
}
EV_INLINE int
ev_is_default_loop (EV_P)
EV_MAYBE_UNUSED ev_is_default_loop (EV_P)
{
return EV_A == EV_DEFAULT_UC;
}
@ -807,14 +813,14 @@ void ev_async_send (EV_P_ ev_async *w);
#define EVUNLOOP_ONE EVBREAK_ONE
#define EVUNLOOP_ALL EVBREAK_ALL
#if EV_PROTOTYPES
EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); }
EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); }
EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); }
EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); }
EV_INLINE void EV_MAYBE_UNUSED ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); }
EV_INLINE void EV_MAYBE_UNUSED ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); }
EV_INLINE void EV_MAYBE_UNUSED ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); }
EV_INLINE void EV_MAYBE_UNUSED ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); }
#if EV_FEATURE_API
EV_INLINE unsigned int ev_loop_count (EV_P) { return ev_iteration (EV_A); }
EV_INLINE unsigned int ev_loop_depth (EV_P) { return ev_depth (EV_A); }
EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); }
EV_INLINE unsigned int EV_MAYBE_UNUSED ev_loop_count (EV_P) { return ev_iteration (EV_A); }
EV_INLINE unsigned int EV_MAYBE_UNUSED ev_loop_depth (EV_P) { return ev_depth (EV_A); }
EV_INLINE void EV_MAYBE_UNUSED ev_loop_verify (EV_P) { ev_verify (EV_A); }
#endif
#endif
#else

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

@ -704,7 +704,7 @@ static uv_write_t* uv__write(uv_stream_t* stream) {
assert(req->write_index < req->bufcnt);
if (n < len) {
if ((size_t)n < len) {
buf->base += n;
buf->len -= n;
stream->write_queue_size -= n;
@ -717,7 +717,7 @@ static uv_write_t* uv__write(uv_stream_t* stream) {
/* Finished writing the buf at index req->write_index. */
req->write_index++;
assert(n >= len);
assert((size_t)n >= len);
n -= len;
assert(stream->write_queue_size >= len);
@ -1788,29 +1788,40 @@ int uv_pipe_init(uv_pipe_t* handle) {
int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
struct sockaddr_un sun;
const char* pipe_fname;
int saved_errno;
int sockfd;
int status;
int bound;
saved_errno = errno;
pipe_fname = NULL;
sockfd = -1;
status = -1;
bound = 0;
/* Already bound? */
if (handle->fd >= 0) {
uv_err_new_artificial((uv_handle_t*)handle, UV_EINVAL);
goto out;
}
/* Make a copy of the file name, it outlives this function's scope. */
if ((name = (const char*)strdup(name)) == NULL) {
if ((pipe_fname = strdup(name)) == NULL) {
uv_err_new((uv_handle_t*)handle, ENOMEM);
goto out;
}
/* We've got a copy, don't touch the original any more. */
name = NULL;
if ((sockfd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
uv_err_new((uv_handle_t*)handle, errno);
goto out;
}
memset(&sun, 0, sizeof sun);
uv__strlcpy(sun.sun_path, name, sizeof(sun.sun_path));
uv__strlcpy(sun.sun_path, pipe_fname, sizeof(sun.sun_path));
sun.sun_family = AF_UNIX;
if (bind(sockfd, (struct sockaddr*)&sun, sizeof sun) == -1) {
@ -1820,16 +1831,17 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
* on EADDRINUSE. Unlinking and trying to bind again opens
* a window for races with other threads and processes.
*/
uv_err_new((uv_handle_t*)handle, errno);
uv_err_new((uv_handle_t*)handle, (errno == ENOENT) ? EACCES : errno);
goto out;
#else
/*
* Try to re-purpose the socket. This is a potential race window.
*/
if (errno != EADDRINUSE
|| unlink(name) == -1
|| unlink(pipe_fname) == -1
|| bind(sockfd, (struct sockaddr*)&sun, sizeof sun) == -1) {
uv_err_new((uv_handle_t*)handle, errno);
/* Convert ENOENT to EACCES for compatibility with Windows. */
uv_err_new((uv_handle_t*)handle, (errno == ENOENT) ? EACCES : errno);
goto out;
}
#endif
@ -1837,7 +1849,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
bound = 1;
/* Success. */
handle->pipe_fname = name; /* Is a strdup'ed copy. */
handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */
handle->fd = sockfd;
status = 0;
@ -1846,10 +1858,11 @@ out:
if (status) {
if (bound) {
/* unlink() before close() to avoid races. */
unlink(name);
assert(pipe_fname != NULL);
unlink(pipe_fname);
}
uv__close(sockfd);
free((void*)name);
free((void*)pipe_fname);
}
errno = saved_errno;
@ -1862,6 +1875,13 @@ int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb) {
int status;
saved_errno = errno;
status = -1;
if (handle->fd == -1) {
uv_err_new_artificial((uv_handle_t*)handle, UV_ENOTCONN);
goto out;
}
assert(handle->fd >= 0);
if ((status = listen(handle->fd, SOMAXCONN)) == -1) {
uv_err_new((uv_handle_t*)handle, errno);
@ -1871,6 +1891,7 @@ int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb) {
ev_io_start(EV_DEFAULT_ &handle->read_watcher);
}
out:
errno = saved_errno;
return status;
}

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

@ -152,7 +152,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
handle->error = LOOP->last_error;
handle->flags |= UV_HANDLE_BIND_ERROR;
} else if (errno == ERROR_PATH_NOT_FOUND || errno == ERROR_INVALID_NAME) {
uv_set_error(UV_EADDRNOTAVAIL, errno);
uv_set_error(UV_EACCESS, errno);
} else {
uv_set_sys_error(errno);
}
@ -399,7 +399,6 @@ int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) {
}
/* Initialize the client handle and copy the pipeHandle to the client */
uv_pipe_init(client);
uv_connection_init((uv_stream_t*) client);
client->handle = req->pipeHandle;

7
deps/uv/test/runner.c

@ -88,6 +88,13 @@ int run_test(const char* test, int timeout, int benchmark_output) {
status = 255;
process_count = 0;
/* If it's a helper the user asks for, start it directly. */
for (task = TASKS; task->main; task++) {
if (task->is_helper && strcmp(test, task->process_name) == 0) {
return task->main();
}
}
/* Start the helpers first. */
for (task = TASKS; task->main; task++) {
if (strcmp(test, task->task_name) != 0) {

5
deps/uv/test/test-pipe-bind-error.c

@ -28,8 +28,7 @@
#ifdef _WIN32
# define BAD_PIPENAME "bad-pipe"
#else
/* TODO: define a bad pipe name for unix (see pipe_bind_error_addrnotavail) */
# define BAD_PIPENAME ""
# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there"
#endif
@ -89,7 +88,7 @@ TEST_IMPL(pipe_bind_error_addrnotavail) {
r = uv_pipe_bind(&server, BAD_PIPENAME);
ASSERT(r == -1);
ASSERT(uv_last_error().code == UV_EADDRNOTAVAIL);
ASSERT(uv_last_error().code == UV_EACCESS);
uv_close((uv_handle_t*)&server, close_cb);

Loading…
Cancel
Save