Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
uv: upgrade to 621a4e3
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Aug 28, 2012
1 parent 985e3a2 commit 4822d78
Show file tree
Hide file tree
Showing 29 changed files with 460 additions and 322 deletions.
6 changes: 6 additions & 0 deletions deps/uv/include/uv-private/uv-win.h
Expand Up @@ -67,6 +67,12 @@ typedef intptr_t ssize_t;
#define SIGKILL 9
#define SIGWINCH 28

/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */
/* unix-like platforms. However MinGW doesn't define it, so we do. */
#ifndef SIGABRT_COMPAT
# define SIGABRT_COMPAT 6
#endif

/*
* Guids and typedefs for winsock extension functions
* Mingw32 doesn't have these :-(
Expand Down
7 changes: 4 additions & 3 deletions deps/uv/include/uv.h
Expand Up @@ -120,9 +120,10 @@ extern "C" {
XX( 53, ENOTEMPTY, "directory not empty") \
XX( 54, ENOSPC, "no space left on device") \
XX( 55, EIO, "i/o error") \
XX( 56, EROFS, "read-only file system" ) \
XX( 57, ENODEV, "no such device" ) \
XX( 58, ECANCELED, "operation canceled" )
XX( 56, EROFS, "read-only file system") \
XX( 57, ENODEV, "no such device") \
XX( 58, ESPIPE, "invalid seek") \
XX( 59, ECANCELED, "operation canceled") \


#define UV_ERRNO_GEN(val, name, s) UV_##name = val,
Expand Down
1 change: 0 additions & 1 deletion deps/uv/src/fs-poll.c
Expand Up @@ -238,7 +238,6 @@ static int statbuf_eq(const uv_statbuf_t* a, const uv_statbuf_t* b) {
void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) {
assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(handle);
}

Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/unix/async.c
Expand Up @@ -55,7 +55,7 @@ inline static int uv__async_make_pending(volatile sig_atomic_t* ptr) {
return __sync_val_compare_and_swap(ptr, 0, 1) != 0;
#else
*ptr = 1;
return 1;
return 0;
#endif
}

Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/error.c
Expand Up @@ -68,6 +68,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EAFNOSUPPORT: return UV_EAFNOSUPPORT;
case EBADF: return UV_EBADF;
case EPIPE: return UV_EPIPE;
case ESPIPE: return UV_ESPIPE;
case EAGAIN: return UV_EAGAIN;
#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK: return UV_EAGAIN;
Expand Down
5 changes: 3 additions & 2 deletions deps/uv/src/unix/linux/linux-core.c
Expand Up @@ -469,8 +469,9 @@ static unsigned long read_cpufreq(unsigned int cpunum) {
if (fp == NULL)
return 0;

val = 0;
fscanf(fp, "%lu", &val);
if (fscanf(fp, "%lu", &val) != 1)
val = 0;

fclose(fp);

return val;
Expand Down
15 changes: 13 additions & 2 deletions deps/uv/src/unix/stream.c
Expand Up @@ -655,7 +655,13 @@ static void uv__write(uv_stream_t* stream) {
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = msg.msg_controllen;
*(int*) CMSG_DATA(cmsg) = fd_to_send;

/* silence aliasing warning */
{
void* pv = CMSG_DATA(cmsg);
int* pi = pv;
*pi = fd_to_send;
}

do {
n = sendmsg(stream->fd, &msg, 0);
Expand Down Expand Up @@ -909,7 +915,12 @@ static void uv__read(uv_stream_t* stream) {
fprintf(stderr, "(libuv) ignoring extra FD received\n");
}

stream->accepted_fd = *(int *) CMSG_DATA(cmsg);
/* silence aliasing warning */
{
void* pv = CMSG_DATA(cmsg);
int* pi = pv;
stream->accepted_fd = *pi;
}

} else {
fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n",
Expand Down
13 changes: 11 additions & 2 deletions deps/uv/src/unix/thread.c
Expand Up @@ -170,7 +170,10 @@ void uv_once(uv_once_t* guard, void (*callback)(void)) {
#if defined(__APPLE__) && defined(__MACH__)

int uv_sem_init(uv_sem_t* sem, unsigned int value) {
return semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value);
if (semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value))
return -1;
else
return 0;
}


Expand All @@ -187,7 +190,13 @@ void uv_sem_post(uv_sem_t* sem) {


void uv_sem_wait(uv_sem_t* sem) {
if (semaphore_wait(*sem))
int r;

do
r = semaphore_wait(*sem);
while (r == KERN_ABORTED);

if (r != KERN_SUCCESS)
abort();
}

Expand Down
7 changes: 6 additions & 1 deletion deps/uv/src/unix/udp.c
Expand Up @@ -86,6 +86,10 @@ void uv__udp_finish_close(uv_udp_t* handle) {
req = ngx_queue_data(q, uv_udp_send_t, queue);
uv__req_unregister(handle->loop, req);

if (req->bufs != req->bufsml)
free(req->bufs);
req->bufs = NULL;

if (req->send_cb) {
/* FIXME proper error code like UV_EABORTED */
uv__set_artificial_error(handle->loop, UV_EINTR);
Expand Down Expand Up @@ -171,6 +175,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) {

if (req->bufs != req->bufsml)
free(req->bufs);
req->bufs = NULL;

if (req->send_cb == NULL)
continue;
Expand Down Expand Up @@ -375,7 +380,7 @@ static int uv__bind(uv_udp_t* handle,


static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, int domain) {
struct sockaddr_storage taddr;
unsigned char taddr[sizeof(struct sockaddr_in6)];
socklen_t addrlen;

assert(domain == AF_INET || domain == AF_INET6);
Expand Down
16 changes: 11 additions & 5 deletions deps/uv/src/uv-common.h
Expand Up @@ -53,12 +53,14 @@
enum {
UV__HANDLE_INTERNAL = 0x8000,
UV__HANDLE_ACTIVE = 0x4000,
UV__HANDLE_REF = 0x2000
UV__HANDLE_REF = 0x2000,
UV__HANDLE_CLOSING = 0 /* no-op on unix */
};
#else
# define UV__HANDLE_INTERNAL 0x80
# define UV__HANDLE_ACTIVE 0x40
# define UV__HANDLE_REF 0x20
# define UV__HANDLE_CLOSING 0x01
#endif

extern const uv_err_t uv_ok_;
Expand Down Expand Up @@ -129,28 +131,32 @@ UNUSED static int uv__is_active(const uv_handle_t* h) {

UNUSED static void uv__handle_start(uv_handle_t* h) {
if (h->flags & UV__HANDLE_ACTIVE) return;
if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
h->flags |= UV__HANDLE_ACTIVE;
if (h->flags & UV__HANDLE_CLOSING) return;
if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
}
#define uv__handle_start(h) uv__handle_start((uv_handle_t*)(h))

UNUSED static void uv__handle_stop(uv_handle_t* h) {
if (!(h->flags & UV__HANDLE_ACTIVE)) return;
if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_ACTIVE;
if (h->flags & UV__HANDLE_CLOSING) return;
if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
}
#define uv__handle_stop(h) uv__handle_stop((uv_handle_t*)(h))

UNUSED static void uv__handle_ref(uv_handle_t* h) {
if (h->flags & UV__HANDLE_REF) return;
if (h->flags & UV__HANDLE_ACTIVE) uv__active_handle_add(h);
if (h->flags & (UV__HANDLE_ACTIVE | UV__HANDLE_CLOSING))
uv__active_handle_add(h);
h->flags |= UV__HANDLE_REF;
}
#define uv__handle_ref(h) uv__handle_ref((uv_handle_t*)(h))

UNUSED static void uv__handle_unref(uv_handle_t* h) {
if (!(h->flags & UV__HANDLE_REF)) return;
if (h->flags & UV__HANDLE_ACTIVE) uv__active_handle_rm(h);
if (h->flags & (UV__HANDLE_ACTIVE | UV__HANDLE_CLOSING))
uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_REF;
}
#define uv__handle_unref(h) uv__handle_unref((uv_handle_t*)(h))
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/src/win/async.c
Expand Up @@ -32,7 +32,6 @@ void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
!handle->async_sent) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(handle);
}
}
Expand Down Expand Up @@ -61,7 +60,7 @@ void uv_async_close(uv_loop_t* loop, uv_async_t* handle) {
uv_want_endgame(loop, (uv_handle_t*) handle);
}

uv__handle_start(handle);
uv__handle_closing(handle);
}


Expand Down
3 changes: 1 addition & 2 deletions deps/uv/src/win/fs-event.c
Expand Up @@ -470,15 +470,14 @@ void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
uv_want_endgame(loop, (uv_handle_t*)handle);
}

uv__handle_start(handle);
uv__handle_closing(handle);
}


void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
!handle->req_pending) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);

if (handle->buffer) {
_aligned_free(handle->buffer);
Expand Down
17 changes: 16 additions & 1 deletion deps/uv/src/win/handle-inl.h
Expand Up @@ -59,12 +59,27 @@
} while (0)


#define uv__handle_closing(handle) \
do { \
assert(!((handle)->flags & UV__HANDLE_CLOSING)); \
(handle)->flags |= UV__HANDLE_CLOSING; \
if ((handle)->flags & UV__HANDLE_ACTIVE) { \
(handle)->flags &= ~UV__HANDLE_ACTIVE; \
} else if ((handle)->flags & UV__HANDLE_REF) { \
uv__active_handle_add((uv_handle_t*) (handle)); \
} \
} while (0)


#define uv__handle_close(handle) \
do { \
ngx_queue_remove(&(handle)->handle_queue); \
(handle)->flags |= UV_HANDLE_CLOSED; \
if (handle->flags & UV__HANDLE_REF) { \
uv__active_handle_rm((uv_handle_t*) (handle)); \
} \
if ((handle)->close_cb) { \
(handle)->close_cb((uv_handle_t*)(handle)); \
(handle)->close_cb((uv_handle_t*) (handle)); \
} \
} while (0)

Expand Down
11 changes: 5 additions & 6 deletions deps/uv/src/win/handle.c
Expand Up @@ -71,7 +71,6 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
return;
}

handle->flags |= UV_HANDLE_CLOSING;
handle->close_cb = cb;

/* Handle-specific close actions */
Expand All @@ -98,25 +97,25 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {

case UV_TIMER:
uv_timer_stop((uv_timer_t*)handle);
uv__handle_start(handle);
uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;

case UV_PREPARE:
uv_prepare_stop((uv_prepare_t*)handle);
uv__handle_start(handle);
uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;

case UV_CHECK:
uv_check_stop((uv_check_t*)handle);
uv__handle_start(handle);
uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;

case UV_IDLE:
uv_idle_stop((uv_idle_t*)handle);
uv__handle_start(handle);
uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;

Expand All @@ -138,7 +137,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {

case UV_FS_POLL:
uv__fs_poll_close((uv_fs_poll_t*) handle);
uv__handle_start(handle);
uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;

Expand Down
1 change: 0 additions & 1 deletion deps/uv/src/win/loop-watcher.c
Expand Up @@ -30,7 +30,6 @@ void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
handle->flags |= UV_HANDLE_CLOSED;
uv__handle_stop(handle);
uv__handle_close(handle);
}
}
Expand Down
3 changes: 1 addition & 2 deletions deps/uv/src/win/pipe.c
Expand Up @@ -357,7 +357,6 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);

if (handle->flags & UV_HANDLE_CONNECTION) {
if (handle->pending_ipc_info.socket_info) {
Expand Down Expand Up @@ -660,7 +659,7 @@ void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle) {
uv_want_endgame(loop, (uv_handle_t*) handle);
}

uv__handle_start(handle);
uv__handle_closing(handle);
}


Expand Down
5 changes: 2 additions & 3 deletions deps/uv/src/win/poll.c
Expand Up @@ -230,7 +230,7 @@ static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {

static void uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
handle->events = 0;
uv__handle_start(handle);
uv__handle_closing(handle);

if (handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 0) {
Expand Down Expand Up @@ -477,7 +477,7 @@ static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {

static void uv__slow_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
handle->events = 0;
uv__handle_start(handle);
uv__handle_closing(handle);

if (handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 0) {
Expand Down Expand Up @@ -611,6 +611,5 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) {
assert(handle->submitted_events_1 == 0);
assert(handle->submitted_events_2 == 0);

uv__handle_stop(handle);
uv__handle_close(handle);
}
4 changes: 1 addition & 3 deletions deps/uv/src/win/process.c
Expand Up @@ -700,7 +700,7 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) {


void uv_process_close(uv_loop_t* loop, uv_process_t* handle) {
uv__handle_start(handle);
uv__handle_closing(handle);

if (handle->wait_handle != INVALID_HANDLE_VALUE) {
/* This blocks until either the wait was cancelled, or the callback has */
Expand All @@ -725,8 +725,6 @@ void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle) {
assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));

uv__handle_stop(handle);

/* Clean-up the process handle. */
CloseHandle(handle->process_handle);

Expand Down

0 comments on commit 4822d78

Please sign in to comment.