Browse Source

deps: upgrade libuv to c43e851

v0.11.1-release
Ben Noordhuis 12 years ago
parent
commit
87f9ece334
  1. 2
      deps/uv/LICENSE
  2. 3
      deps/uv/config-unix.mk
  3. 129
      deps/uv/include/uv-private/ngx-queue.h
  4. 4
      deps/uv/include/uv-private/uv-darwin.h
  5. 2
      deps/uv/include/uv-private/uv-linux.h
  6. 48
      deps/uv/include/uv-private/uv-unix.h
  7. 1
      deps/uv/include/uv-private/uv-win.h
  8. 13
      deps/uv/include/uv.h
  9. 92
      deps/uv/src/queue.h
  10. 10
      deps/uv/src/unix/async.c
  11. 44
      deps/uv/src/unix/core.c
  12. 36
      deps/uv/src/unix/darwin.c
  13. 32
      deps/uv/src/unix/fsevents.c
  14. 60
      deps/uv/src/unix/getaddrinfo.c
  15. 14
      deps/uv/src/unix/kqueue.c
  16. 14
      deps/uv/src/unix/linux-core.c
  17. 16
      deps/uv/src/unix/linux-inotify.c
  18. 10
      deps/uv/src/unix/loop-watcher.c
  19. 26
      deps/uv/src/unix/loop.c
  20. 2
      deps/uv/src/unix/pipe.c
  21. 18
      deps/uv/src/unix/process.c
  22. 6
      deps/uv/src/unix/signal.c
  23. 54
      deps/uv/src/unix/stream.c
  24. 18
      deps/uv/src/unix/sunos.c
  25. 2
      deps/uv/src/unix/tcp.c
  26. 48
      deps/uv/src/unix/threadpool.c
  27. 46
      deps/uv/src/unix/udp.c
  28. 12
      deps/uv/src/uv-common.c
  29. 9
      deps/uv/src/uv-common.h
  30. 6
      deps/uv/src/version.c
  31. 8
      deps/uv/src/win/core.c
  32. 2
      deps/uv/src/win/handle-inl.h
  33. 29
      deps/uv/test/test-getaddrinfo.c
  34. 2
      deps/uv/test/test-list.h
  35. 4
      deps/uv/test/test-threadpool-cancel.c
  36. 2
      deps/uv/uv.gyp

2
deps/uv/LICENSE

@ -31,8 +31,6 @@ The externally maintained libraries used by libuv are:
- tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license. - tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license.
- ngx_queue.h (from Nginx), copyright Igor Sysoev. Two clause BSD license.
- inet_pton and inet_ntop implementations, contained in src/inet.c, are - inet_pton and inet_ntop implementations, contained in src/inet.c, are
copyright the Internet Systems Consortium, Inc., and licensed under the ISC copyright the Internet Systems Consortium, Inc., and licensed under the ISC
license. license.

3
deps/uv/config-unix.mk

@ -145,7 +145,8 @@ include/uv-private/uv-unix.h: \
include/uv-private/uv-linux.h \ include/uv-private/uv-linux.h \
include/uv-private/uv-sunos.h include/uv-private/uv-sunos.h
src/unix/internal.h: src/unix/linux-syscalls.h src/unix/internal.h: src/unix/linux-syscalls.h src/uv-common.h
src/uv-common.h: src/queue.h
src/.buildstamp src/unix/.buildstamp test/.buildstamp: src/.buildstamp src/unix/.buildstamp test/.buildstamp:
mkdir -p $(@D) mkdir -p $(@D)

129
deps/uv/include/uv-private/ngx-queue.h

@ -1,129 +0,0 @@
/*
* Copyright (C) Igor Sysoev
*/
#ifndef NGX_QUEUE_H_INCLUDED_
#define NGX_QUEUE_H_INCLUDED_
typedef struct ngx_queue_s ngx_queue_t;
struct ngx_queue_s {
ngx_queue_t *prev;
ngx_queue_t *next;
};
#define ngx_queue_init(q) \
do { \
(q)->prev = q; \
(q)->next = q; \
} \
while (0)
#define ngx_queue_empty(h) \
(h == (h)->prev)
#define ngx_queue_insert_head(h, x) \
do { \
(x)->next = (h)->next; \
(x)->next->prev = x; \
(x)->prev = h; \
(h)->next = x; \
} \
while (0)
#define ngx_queue_insert_after ngx_queue_insert_head
#define ngx_queue_insert_tail(h, x) \
do { \
(x)->prev = (h)->prev; \
(x)->prev->next = x; \
(x)->next = h; \
(h)->prev = x; \
} \
while (0)
#define ngx_queue_head(h) \
(h)->next
#define ngx_queue_last(h) \
(h)->prev
#define ngx_queue_sentinel(h) \
(h)
#define ngx_queue_next(q) \
(q)->next
#define ngx_queue_prev(q) \
(q)->prev
#if defined(NGX_DEBUG)
#define ngx_queue_remove(x) \
do { \
(x)->next->prev = (x)->prev; \
(x)->prev->next = (x)->next; \
(x)->prev = NULL; \
(x)->next = NULL; \
} \
while (0)
#else
#define ngx_queue_remove(x) \
do { \
(x)->next->prev = (x)->prev; \
(x)->prev->next = (x)->next; \
} \
while (0)
#endif
#define ngx_queue_split(h, q, n) \
do { \
(n)->prev = (h)->prev; \
(n)->prev->next = n; \
(n)->next = q; \
(h)->prev = (q)->prev; \
(h)->prev->next = h; \
(q)->prev = n; \
} \
while (0)
#define ngx_queue_add(h, n) \
do { \
(h)->prev->next = (n)->next; \
(n)->next->prev = (h)->prev; \
(h)->prev = (n)->prev; \
(h)->prev->next = h; \
} \
while (0)
#define ngx_queue_data(q, type, link) \
((type *) ((unsigned char *) q - offsetof(type, link)))
#define ngx_queue_foreach(q, h) \
for ((q) = ngx_queue_head(h); \
(q) != ngx_queue_sentinel(h) && !ngx_queue_empty(h); \
(q) = ngx_queue_next(q))
#endif /* NGX_QUEUE_H_INCLUDED_ */

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

@ -40,7 +40,7 @@
void* cf_loop; \ void* cf_loop; \
uv_mutex_t cf_mutex; \ uv_mutex_t cf_mutex; \
uv_sem_t cf_sem; \ uv_sem_t cf_sem; \
ngx_queue_t cf_signals; \ void* cf_signals[2]; \
#define UV_PLATFORM_FS_EVENT_FIELDS \ #define UV_PLATFORM_FS_EVENT_FIELDS \
uv__io_t event_watcher; \ uv__io_t event_watcher; \
@ -49,7 +49,7 @@
int cf_flags; \ int cf_flags; \
void* cf_eventstream; \ void* cf_eventstream; \
uv_async_t* cf_cb; \ uv_async_t* cf_cb; \
ngx_queue_t cf_events; \ void* cf_events[2]; \
uv_sem_t cf_sem; \ uv_sem_t cf_sem; \
uv_mutex_t cf_mutex; \ uv_mutex_t cf_mutex; \

2
deps/uv/include/uv-private/uv-linux.h

@ -28,7 +28,7 @@
int inotify_fd; \ int inotify_fd; \
#define UV_PLATFORM_FS_EVENT_FIELDS \ #define UV_PLATFORM_FS_EVENT_FIELDS \
ngx_queue_t watchers; \ void* watchers[2]; \
int wd; \ int wd; \
#endif /* UV_LINUX_H */ #endif /* UV_LINUX_H */

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

@ -22,8 +22,6 @@
#ifndef UV_UNIX_H #ifndef UV_UNIX_H
#define UV_UNIX_H #define UV_UNIX_H
#include "ngx-queue.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -72,8 +70,8 @@ typedef struct uv__io_s uv__io_t;
struct uv__io_s { struct uv__io_s {
uv__io_cb cb; uv__io_cb cb;
ngx_queue_t pending_queue; void* pending_queue[2];
ngx_queue_t watcher_queue; void* watcher_queue[2];
unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
unsigned int events; /* Current event mask. */ unsigned int events; /* Current event mask. */
int fd; int fd;
@ -94,7 +92,7 @@ struct uv__work {
void (*work)(struct uv__work *w); void (*work)(struct uv__work *w);
void (*done)(struct uv__work *w, int status); void (*done)(struct uv__work *w, int status);
struct uv_loop_s* loop; struct uv_loop_s* loop;
ngx_queue_t wq; void* wq[2];
}; };
#ifndef UV_PLATFORM_SEM_T #ifndef UV_PLATFORM_SEM_T
@ -163,20 +161,20 @@ typedef struct {
#define UV_LOOP_PRIVATE_FIELDS \ #define UV_LOOP_PRIVATE_FIELDS \
unsigned long flags; \ unsigned long flags; \
int backend_fd; \ int backend_fd; \
ngx_queue_t pending_queue; \ void* pending_queue[2]; \
ngx_queue_t watcher_queue; \ void* watcher_queue[2]; \
uv__io_t** watchers; \ uv__io_t** watchers; \
unsigned int nwatchers; \ unsigned int nwatchers; \
unsigned int nfds; \ unsigned int nfds; \
ngx_queue_t wq; \ void* wq[2]; \
uv_mutex_t wq_mutex; \ uv_mutex_t wq_mutex; \
uv_async_t wq_async; \ uv_async_t wq_async; \
uv_handle_t* closing_handles; \ uv_handle_t* closing_handles; \
ngx_queue_t process_handles[1]; \ void* process_handles[1][2]; \
ngx_queue_t prepare_handles; \ void* prepare_handles[2]; \
ngx_queue_t check_handles; \ void* check_handles[2]; \
ngx_queue_t idle_handles; \ void* idle_handles[2]; \
ngx_queue_t async_handles; \ void* async_handles[2]; \
struct uv__async async_watcher; \ struct uv__async async_watcher; \
/* RB_HEAD(uv__timers, uv_timer_s) */ \ /* RB_HEAD(uv__timers, uv_timer_s) */ \
struct uv__timers { \ struct uv__timers { \
@ -197,7 +195,7 @@ typedef struct {
#define UV_PRIVATE_REQ_TYPES /* empty */ #define UV_PRIVATE_REQ_TYPES /* empty */
#define UV_WRITE_PRIVATE_FIELDS \ #define UV_WRITE_PRIVATE_FIELDS \
ngx_queue_t queue; \ void* queue[2]; \
int write_index; \ int write_index; \
uv_buf_t* bufs; \ uv_buf_t* bufs; \
int bufcnt; \ int bufcnt; \
@ -205,12 +203,12 @@ typedef struct {
uv_buf_t bufsml[4]; \ uv_buf_t bufsml[4]; \
#define UV_CONNECT_PRIVATE_FIELDS \ #define UV_CONNECT_PRIVATE_FIELDS \
ngx_queue_t queue; \ void* queue[2]; \
#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ #define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
#define UV_UDP_SEND_PRIVATE_FIELDS \ #define UV_UDP_SEND_PRIVATE_FIELDS \
ngx_queue_t queue; \ void* queue[2]; \
struct sockaddr_in6 addr; \ struct sockaddr_in6 addr; \
int bufcnt; \ int bufcnt; \
uv_buf_t* bufs; \ uv_buf_t* bufs; \
@ -226,8 +224,8 @@ typedef struct {
uv_connect_t *connect_req; \ uv_connect_t *connect_req; \
uv_shutdown_t *shutdown_req; \ uv_shutdown_t *shutdown_req; \
uv__io_t io_watcher; \ uv__io_t io_watcher; \
ngx_queue_t write_queue; \ void* write_queue[2]; \
ngx_queue_t write_completed_queue; \ void* write_completed_queue[2]; \
uv_connection_cb connection_cb; \ uv_connection_cb connection_cb; \
int delayed_error; \ int delayed_error; \
int accepted_fd; \ int accepted_fd; \
@ -239,8 +237,8 @@ typedef struct {
uv_alloc_cb alloc_cb; \ uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \ uv_udp_recv_cb recv_cb; \
uv__io_t io_watcher; \ uv__io_t io_watcher; \
ngx_queue_t write_queue; \ void* write_queue[2]; \
ngx_queue_t write_completed_queue; \ void* write_completed_queue[2]; \
#define UV_PIPE_PRIVATE_FIELDS \ #define UV_PIPE_PRIVATE_FIELDS \
const char* pipe_fname; /* strdup'ed */ const char* pipe_fname; /* strdup'ed */
@ -250,19 +248,19 @@ typedef struct {
#define UV_PREPARE_PRIVATE_FIELDS \ #define UV_PREPARE_PRIVATE_FIELDS \
uv_prepare_cb prepare_cb; \ uv_prepare_cb prepare_cb; \
ngx_queue_t queue; void* queue[2]; \
#define UV_CHECK_PRIVATE_FIELDS \ #define UV_CHECK_PRIVATE_FIELDS \
uv_check_cb check_cb; \ uv_check_cb check_cb; \
ngx_queue_t queue; void* queue[2]; \
#define UV_IDLE_PRIVATE_FIELDS \ #define UV_IDLE_PRIVATE_FIELDS \
uv_idle_cb idle_cb; \ uv_idle_cb idle_cb; \
ngx_queue_t queue; void* queue[2]; \
#define UV_ASYNC_PRIVATE_FIELDS \ #define UV_ASYNC_PRIVATE_FIELDS \
uv_async_cb async_cb; \ uv_async_cb async_cb; \
ngx_queue_t queue; \ void* queue[2]; \
int pending; \ int pending; \
#define UV_TIMER_PRIVATE_FIELDS \ #define UV_TIMER_PRIVATE_FIELDS \
@ -288,7 +286,7 @@ typedef struct {
int retcode; int retcode;
#define UV_PROCESS_PRIVATE_FIELDS \ #define UV_PROCESS_PRIVATE_FIELDS \
ngx_queue_t queue; \ void* queue[2]; \
int errorno; \ int errorno; \
#define UV_FS_PRIVATE_FIELDS \ #define UV_FS_PRIVATE_FIELDS \

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

@ -45,7 +45,6 @@ typedef intptr_t ssize_t;
#endif #endif
#include "tree.h" #include "tree.h"
#include "ngx-queue.h"
#define MAX_PIPENAME_LEN 256 #define MAX_PIPENAME_LEN 256

13
deps/uv/include/uv.h

@ -45,11 +45,6 @@ extern "C" {
# define UV_EXTERN /* nothing */ # define UV_EXTERN /* nothing */
#endif #endif
#define UV_VERSION_MAJOR 0
#define UV_VERSION_MINOR 10
#if defined(_MSC_VER) && _MSC_VER < 1600 #if defined(_MSC_VER) && _MSC_VER < 1600
# include "uv-private/stdint-msvc2008.h" # include "uv-private/stdint-msvc2008.h"
#else #else
@ -434,7 +429,7 @@ UV_EXTERN const char* uv_err_name(uv_err_t err);
/* read-only */ \ /* read-only */ \
uv_req_type type; \ uv_req_type type; \
/* private */ \ /* private */ \
ngx_queue_t active_queue; \ void* active_queue[2]; \
UV_REQ_PRIVATE_FIELDS \ UV_REQ_PRIVATE_FIELDS \
/* Abstract base class of all requests. */ /* Abstract base class of all requests. */
@ -474,7 +469,7 @@ struct uv_shutdown_s {
uv_loop_t* loop; \ uv_loop_t* loop; \
uv_handle_type type; \ uv_handle_type type; \
/* private */ \ /* private */ \
ngx_queue_t handle_queue; \ void* handle_queue[2]; \
UV_HANDLE_PRIVATE_FIELDS \ UV_HANDLE_PRIVATE_FIELDS \
/* The abstract base class of all handles. */ /* The abstract base class of all handles. */
@ -1958,8 +1953,8 @@ struct uv_loop_s {
uv_err_t last_err; uv_err_t last_err;
/* Loop reference counting */ /* Loop reference counting */
unsigned int active_handles; unsigned int active_handles;
ngx_queue_t handle_queue; void* handle_queue[2];
ngx_queue_t active_reqs; void* active_reqs[2];
/* Internal flag to signal loop stop */ /* Internal flag to signal loop stop */
unsigned int stop_flag; unsigned int stop_flag;
UV_LOOP_PRIVATE_FIELDS UV_LOOP_PRIVATE_FIELDS

92
deps/uv/src/queue.h

@ -0,0 +1,92 @@
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef QUEUE_H_
#define QUEUE_H_
typedef void *QUEUE[2];
/* Private macros. */
#define QUEUE_NEXT(q) ((*(q))[0])
#define QUEUE_PREV(q) ((*(q))[1])
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT((QUEUE *) QUEUE_PREV(q)))
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV((QUEUE *) QUEUE_NEXT(q)))
/* Public macros. */
#define QUEUE_DATA(ptr, type, field) \
((type *) ((char *) (ptr) - ((long) &((type *) 0)->field)))
#define QUEUE_FOREACH(q, h) \
for ((q) = (*(h))[0]; (q) != (h); (q) = (*(q))[0])
#define QUEUE_EMPTY(q) \
(QUEUE_NEXT(q) == (q))
#define QUEUE_HEAD(q) \
(QUEUE_NEXT(q))
#define QUEUE_INIT(q) \
do { \
QUEUE_NEXT(q) = (q); \
QUEUE_PREV(q) = (q); \
} \
while (0)
#define QUEUE_ADD(h, n) \
do { \
QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \
QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \
QUEUE_PREV(h) = QUEUE_PREV(n); \
QUEUE_PREV_NEXT(h) = (h); \
} \
while (0)
#define QUEUE_SPLIT(h, q, n) \
do { \
QUEUE_PREV(n) = QUEUE_PREV(h); \
QUEUE_PREV_NEXT(n) = (n); \
QUEUE_NEXT(n) = (q); \
QUEUE_PREV(h) = QUEUE_PREV(q); \
QUEUE_PREV_NEXT(h) = (h); \
QUEUE_PREV(q) = (n); \
} \
while (0)
#define QUEUE_INSERT_HEAD(h, q) \
do { \
QUEUE_NEXT(q) = QUEUE_NEXT(h); \
QUEUE_PREV(q) = (h); \
QUEUE_NEXT_PREV(q) = (q); \
QUEUE_NEXT(h) = (q); \
} \
while (0)
#define QUEUE_INSERT_TAIL(h, q) \
do { \
QUEUE_NEXT(q) = (h); \
QUEUE_PREV(q) = QUEUE_PREV(h); \
QUEUE_PREV_NEXT(q) = (q); \
QUEUE_PREV(h) = (q); \
} \
while (0)
#define QUEUE_REMOVE(q) \
do { \
QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \
QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \
} \
while (0)
#endif /* QUEUE_H_ */

10
deps/uv/src/unix/async.c

@ -46,7 +46,7 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {
handle->async_cb = async_cb; handle->async_cb = async_cb;
handle->pending = 0; handle->pending = 0;
ngx_queue_insert_tail(&loop->async_handles, &handle->queue); QUEUE_INSERT_TAIL(&loop->async_handles, &handle->queue);
uv__handle_start(handle); uv__handle_start(handle);
return 0; return 0;
@ -62,7 +62,7 @@ int uv_async_send(uv_async_t* handle) {
void uv__async_close(uv_async_t* handle) { void uv__async_close(uv_async_t* handle) {
ngx_queue_remove(&handle->queue); QUEUE_REMOVE(&handle->queue);
uv__handle_stop(handle); uv__handle_stop(handle);
} }
@ -70,11 +70,11 @@ void uv__async_close(uv_async_t* handle) {
static void uv__async_event(uv_loop_t* loop, static void uv__async_event(uv_loop_t* loop,
struct uv__async* w, struct uv__async* w,
unsigned int nevents) { unsigned int nevents) {
ngx_queue_t* q; QUEUE* q;
uv_async_t* h; uv_async_t* h;
ngx_queue_foreach(q, &loop->async_handles) { QUEUE_FOREACH(q, &loop->async_handles) {
h = ngx_queue_data(q, uv_async_t, queue); h = QUEUE_DATA(q, uv_async_t, queue);
if (!h->pending) continue; if (!h->pending) continue;
h->pending = 0; h->pending = 0;
h->async_cb(h, 0); h->async_cb(h, 0);

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

@ -198,7 +198,7 @@ static void uv__finish_close(uv_handle_t* handle) {
} }
uv__handle_unref(handle); uv__handle_unref(handle);
ngx_queue_remove(&handle->handle_queue); QUEUE_REMOVE(&handle->handle_queue);
if (handle->close_cb) { if (handle->close_cb) {
handle->close_cb(handle); handle->close_cb(handle);
@ -276,7 +276,7 @@ int uv_backend_timeout(const uv_loop_t* loop) {
if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop)) if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop))
return 0; return 0;
if (!ngx_queue_empty(&loop->idle_handles)) if (!QUEUE_EMPTY(&loop->idle_handles))
return 0; return 0;
if (loop->closing_handles) if (loop->closing_handles)
@ -566,15 +566,15 @@ void uv_disable_stdio_inheritance(void) {
static void uv__run_pending(uv_loop_t* loop) { static void uv__run_pending(uv_loop_t* loop) {
ngx_queue_t* q; QUEUE* q;
uv__io_t* w; uv__io_t* w;
while (!ngx_queue_empty(&loop->pending_queue)) { while (!QUEUE_EMPTY(&loop->pending_queue)) {
q = ngx_queue_head(&loop->pending_queue); q = QUEUE_HEAD(&loop->pending_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
ngx_queue_init(q); QUEUE_INIT(q);
w = ngx_queue_data(q, uv__io_t, pending_queue); w = QUEUE_DATA(q, uv__io_t, pending_queue);
w->cb(loop, w, UV__POLLOUT); w->cb(loop, w, UV__POLLOUT);
} }
} }
@ -616,8 +616,8 @@ static void maybe_resize(uv_loop_t* loop, unsigned int len) {
void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) { void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) {
assert(cb != NULL); assert(cb != NULL);
assert(fd >= -1); assert(fd >= -1);
ngx_queue_init(&w->pending_queue); QUEUE_INIT(&w->pending_queue);
ngx_queue_init(&w->watcher_queue); QUEUE_INIT(&w->watcher_queue);
w->cb = cb; w->cb = cb;
w->fd = fd; w->fd = fd;
w->events = 0; w->events = 0;
@ -645,16 +645,16 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
* short-circuit here if the event mask is unchanged. * short-circuit here if the event mask is unchanged.
*/ */
if (w->events == w->pevents) { if (w->events == w->pevents) {
if (w->events == 0 && !ngx_queue_empty(&w->watcher_queue)) { if (w->events == 0 && !QUEUE_EMPTY(&w->watcher_queue)) {
ngx_queue_remove(&w->watcher_queue); QUEUE_REMOVE(&w->watcher_queue);
ngx_queue_init(&w->watcher_queue); QUEUE_INIT(&w->watcher_queue);
} }
return; return;
} }
#endif #endif
if (ngx_queue_empty(&w->watcher_queue)) if (QUEUE_EMPTY(&w->watcher_queue))
ngx_queue_insert_tail(&loop->watcher_queue, &w->watcher_queue); QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
if (loop->watchers[w->fd] == NULL) { if (loop->watchers[w->fd] == NULL) {
loop->watchers[w->fd] = w; loop->watchers[w->fd] = w;
@ -679,8 +679,8 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
w->pevents &= ~events; w->pevents &= ~events;
if (w->pevents == 0) { if (w->pevents == 0) {
ngx_queue_remove(&w->watcher_queue); QUEUE_REMOVE(&w->watcher_queue);
ngx_queue_init(&w->watcher_queue); QUEUE_INIT(&w->watcher_queue);
if (loop->watchers[w->fd] != NULL) { if (loop->watchers[w->fd] != NULL) {
assert(loop->watchers[w->fd] == w); assert(loop->watchers[w->fd] == w);
@ -690,20 +690,20 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
w->events = 0; w->events = 0;
} }
} }
else if (ngx_queue_empty(&w->watcher_queue)) else if (QUEUE_EMPTY(&w->watcher_queue))
ngx_queue_insert_tail(&loop->watcher_queue, &w->watcher_queue); QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
} }
void uv__io_close(uv_loop_t* loop, uv__io_t* w) { void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT); uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT);
ngx_queue_remove(&w->pending_queue); QUEUE_REMOVE(&w->pending_queue);
} }
void uv__io_feed(uv_loop_t* loop, uv__io_t* w) { void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
if (ngx_queue_empty(&w->pending_queue)) if (QUEUE_EMPTY(&w->pending_queue))
ngx_queue_insert_tail(&loop->pending_queue, &w->pending_queue); QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue);
} }

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

@ -45,7 +45,7 @@ typedef struct uv__cf_loop_signal_s uv__cf_loop_signal_t;
struct uv__cf_loop_signal_s { struct uv__cf_loop_signal_s {
void* arg; void* arg;
cf_loop_signal_cb cb; cf_loop_signal_cb cb;
ngx_queue_t member; QUEUE member;
}; };
@ -61,7 +61,7 @@ int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
return r; return r;
if ((r = uv_sem_init(&loop->cf_sem, 0))) if ((r = uv_sem_init(&loop->cf_sem, 0)))
return r; return r;
ngx_queue_init(&loop->cf_signals); QUEUE_INIT(&loop->cf_signals);
memset(&ctx, 0, sizeof(ctx)); memset(&ctx, 0, sizeof(ctx));
ctx.info = loop; ctx.info = loop;
@ -80,7 +80,7 @@ int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
void uv__platform_loop_delete(uv_loop_t* loop) { void uv__platform_loop_delete(uv_loop_t* loop) {
ngx_queue_t* item; QUEUE* item;
uv__cf_loop_signal_t* s; uv__cf_loop_signal_t* s;
assert(loop->cf_loop != NULL); assert(loop->cf_loop != NULL);
@ -92,12 +92,12 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
uv_mutex_destroy(&loop->cf_mutex); uv_mutex_destroy(&loop->cf_mutex);
/* Free any remaining data */ /* Free any remaining data */
while (!ngx_queue_empty(&loop->cf_signals)) { while (!QUEUE_EMPTY(&loop->cf_signals)) {
item = ngx_queue_head(&loop->cf_signals); item = QUEUE_HEAD(&loop->cf_signals);
s = ngx_queue_data(item, uv__cf_loop_signal_t, member); s = QUEUE_DATA(item, uv__cf_loop_signal_t, member);
ngx_queue_remove(item); QUEUE_REMOVE(item);
free(s); free(s);
} }
} }
@ -127,27 +127,27 @@ void uv__cf_loop_runner(void* arg) {
void uv__cf_loop_cb(void* arg) { void uv__cf_loop_cb(void* arg) {
uv_loop_t* loop; uv_loop_t* loop;
ngx_queue_t* item; QUEUE* item;
ngx_queue_t split_head; QUEUE split_head;
uv__cf_loop_signal_t* s; uv__cf_loop_signal_t* s;
loop = arg; loop = arg;
uv_mutex_lock(&loop->cf_mutex); uv_mutex_lock(&loop->cf_mutex);
ngx_queue_init(&split_head); QUEUE_INIT(&split_head);
if (!ngx_queue_empty(&loop->cf_signals)) { if (!QUEUE_EMPTY(&loop->cf_signals)) {
ngx_queue_t* split_pos = ngx_queue_next(&loop->cf_signals); QUEUE* split_pos = QUEUE_HEAD(&loop->cf_signals);
ngx_queue_split(&loop->cf_signals, split_pos, &split_head); QUEUE_SPLIT(&loop->cf_signals, split_pos, &split_head);
} }
uv_mutex_unlock(&loop->cf_mutex); uv_mutex_unlock(&loop->cf_mutex);
while (!ngx_queue_empty(&split_head)) { while (!QUEUE_EMPTY(&split_head)) {
item = ngx_queue_head(&split_head); item = QUEUE_HEAD(&split_head);
s = ngx_queue_data(item, uv__cf_loop_signal_t, member); s = QUEUE_DATA(item, uv__cf_loop_signal_t, member);
s->cb(s->arg); s->cb(s->arg);
ngx_queue_remove(item); QUEUE_REMOVE(item);
free(s); free(s);
} }
} }
@ -165,7 +165,7 @@ void uv__cf_loop_signal(uv_loop_t* loop, cf_loop_signal_cb cb, void* arg) {
item->cb = cb; item->cb = cb;
uv_mutex_lock(&loop->cf_mutex); uv_mutex_lock(&loop->cf_mutex);
ngx_queue_insert_tail(&loop->cf_signals, &item->member); QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member);
uv_mutex_unlock(&loop->cf_mutex); uv_mutex_unlock(&loop->cf_mutex);
assert(loop->cf_loop != NULL); assert(loop->cf_loop != NULL);

32
deps/uv/src/unix/fsevents.c

@ -44,28 +44,28 @@ typedef struct uv__fsevents_event_s uv__fsevents_event_t;
struct uv__fsevents_event_s { struct uv__fsevents_event_s {
int events; int events;
ngx_queue_t member; QUEUE member;
char path[1]; char path[1];
}; };
#define UV__FSEVENTS_WALK(handle, block) \ #define UV__FSEVENTS_WALK(handle, block) \
{ \ { \
ngx_queue_t* curr; \ QUEUE* curr; \
ngx_queue_t split_head; \ QUEUE split_head; \
uv__fsevents_event_t* event; \ uv__fsevents_event_t* event; \
uv_mutex_lock(&(handle)->cf_mutex); \ uv_mutex_lock(&(handle)->cf_mutex); \
ngx_queue_init(&split_head); \ QUEUE_INIT(&split_head); \
if (!ngx_queue_empty(&(handle)->cf_events)) { \ if (!QUEUE_EMPTY(&(handle)->cf_events)) { \
ngx_queue_t* split_pos = ngx_queue_next(&(handle)->cf_events); \ QUEUE* split_pos = QUEUE_HEAD(&(handle)->cf_events); \
ngx_queue_split(&(handle)->cf_events, split_pos, &split_head); \ QUEUE_SPLIT(&(handle)->cf_events, split_pos, &split_head); \
} \ } \
uv_mutex_unlock(&(handle)->cf_mutex); \ uv_mutex_unlock(&(handle)->cf_mutex); \
while (!ngx_queue_empty(&split_head)) { \ while (!QUEUE_EMPTY(&split_head)) { \
curr = ngx_queue_head(&split_head); \ curr = QUEUE_HEAD(&split_head); \
/* Invoke callback */ \ /* Invoke callback */ \
event = ngx_queue_data(curr, uv__fsevents_event_t, member); \ event = QUEUE_DATA(curr, uv__fsevents_event_t, member); \
ngx_queue_remove(curr); \ QUEUE_REMOVE(curr); \
/* Invoke block code, but only if handle wasn't closed */ \ /* Invoke block code, but only if handle wasn't closed */ \
if (((handle)->flags & (UV_CLOSING | UV_CLOSED)) == 0) \ if (((handle)->flags & (UV_CLOSING | UV_CLOSED)) == 0) \
block \ block \
@ -105,7 +105,7 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
char* pos; char* pos;
uv_fs_event_t* handle; uv_fs_event_t* handle;
uv__fsevents_event_t* event; uv__fsevents_event_t* event;
ngx_queue_t add_list; QUEUE add_list;
int kFSEventsModified; int kFSEventsModified;
int kFSEventsRenamed; int kFSEventsRenamed;
@ -120,7 +120,7 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
handle = info; handle = info;
paths = eventPaths; paths = eventPaths;
ngx_queue_init(&add_list); QUEUE_INIT(&add_list);
for (i = 0; i < numEvents; i++) { for (i = 0; i < numEvents; i++) {
/* Ignore system events */ /* Ignore system events */
@ -180,10 +180,10 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
else else
event->events = UV_RENAME; event->events = UV_RENAME;
ngx_queue_insert_tail(&add_list, &event->member); QUEUE_INSERT_TAIL(&add_list, &event->member);
} }
uv_mutex_lock(&handle->cf_mutex); uv_mutex_lock(&handle->cf_mutex);
ngx_queue_add(&handle->cf_events, &add_list); QUEUE_ADD(&handle->cf_events, &add_list);
uv_mutex_unlock(&handle->cf_mutex); uv_mutex_unlock(&handle->cf_mutex);
uv_async_send(handle->cf_cb); uv_async_send(handle->cf_cb);
@ -257,7 +257,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
uv_mutex_init(&handle->cf_mutex); uv_mutex_init(&handle->cf_mutex);
uv_sem_init(&handle->cf_sem, 0); uv_sem_init(&handle->cf_sem, 0);
ngx_queue_init(&handle->cf_events); QUEUE_INIT(&handle->cf_events);
uv__cf_loop_signal(handle->loop, uv__fsevents_schedule, handle); uv__cf_loop_signal(handle->loop, uv__fsevents_schedule, handle);

60
deps/uv/src/unix/getaddrinfo.c

@ -38,22 +38,24 @@ static void uv__getaddrinfo_work(struct uv__work* w) {
static void uv__getaddrinfo_done(struct uv__work* w, int status) { static void uv__getaddrinfo_done(struct uv__work* w, int status) {
uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req); uv_getaddrinfo_t* req;
struct addrinfo *res = req->res; struct addrinfo *res;
#if defined(__sun)
size_t hostlen; size_t hostlen;
if (req->hostname) req = container_of(w, uv_getaddrinfo_t, work_req);
hostlen = strlen(req->hostname); uv__req_unregister(req->loop, req);
else
hostlen = 0;
#endif
res = req->res;
req->res = NULL; req->res = NULL;
uv__req_unregister(req->loop, req); (void) &hostlen; /* Silence unused variable warning. */
hostlen = 0;
#if defined(__sun)
if (req->hostname != NULL)
hostlen = strlen(req->hostname);
#endif
/* see initialization in uv_getaddrinfo() */ /* See initialization in uv_getaddrinfo(). */
if (req->hints) if (req->hints)
free(req->hints); free(req->hints);
else if (req->service) else if (req->service)
@ -67,30 +69,34 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
req->service = NULL; req->service = NULL;
req->hostname = NULL; req->hostname = NULL;
if (status == -UV_ECANCELED) {
assert(req->retcode == 0);
req->retcode = UV_ECANCELED;
uv__set_artificial_error(req->loop, UV_ECANCELED);
req->cb(req, -1, NULL);
return;
}
if (req->retcode == 0) { if (req->retcode == 0) {
/* OK */ req->cb(req, 0, res);
#if defined(EAI_NODATA) /* FreeBSD deprecated EAI_NODATA */ return;
} else if (req->retcode == EAI_NONAME || req->retcode == EAI_NODATA) { }
#else
} else if (req->retcode == EAI_NONAME) { if (req->retcode == EAI_NONAME)
#endif uv__set_sys_error(req->loop, ENOENT);
uv__set_sys_error(req->loop, ENOENT); /* FIXME compatibility hack */ #if defined(EAI_NODATA) /* Newer FreeBSDs don't have EAI_NODATA. */
#if defined(__sun) else if (req->retcode == EAI_NODATA)
} else if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) { uv__set_sys_error(req->loop, ENOENT);
#elif defined(__sun)
if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) {
uv__set_sys_error(req->loop, ENOENT); uv__set_sys_error(req->loop, ENOENT);
#endif #endif
} else { else {
req->loop->last_err.code = UV_EADDRINFO; req->loop->last_err.code = UV_EADDRINFO;
req->loop->last_err.sys_errno_ = req->retcode; req->loop->last_err.sys_errno_ = req->retcode;
} }
if (status == -UV_ECANCELED) { req->cb(req, -1, res);
assert(req->retcode == 0);
req->retcode = UV_ECANCELED;
uv__set_artificial_error(req->loop, UV_ECANCELED);
}
req->cb(req, req->retcode, res);
} }

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

@ -55,7 +55,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
struct timespec spec; struct timespec spec;
unsigned int nevents; unsigned int nevents;
unsigned int revents; unsigned int revents;
ngx_queue_t* q; QUEUE* q;
uint64_t base; uint64_t base;
uint64_t diff; uint64_t diff;
uv__io_t* w; uv__io_t* w;
@ -68,18 +68,18 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
int i; int i;
if (loop->nfds == 0) { if (loop->nfds == 0) {
assert(ngx_queue_empty(&loop->watcher_queue)); assert(QUEUE_EMPTY(&loop->watcher_queue));
return; return;
} }
nevents = 0; nevents = 0;
while (!ngx_queue_empty(&loop->watcher_queue)) { while (!QUEUE_EMPTY(&loop->watcher_queue)) {
q = ngx_queue_head(&loop->watcher_queue); q = QUEUE_HEAD(&loop->watcher_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
ngx_queue_init(q); QUEUE_INIT(q);
w = ngx_queue_data(q, uv__io_t, watcher_queue); w = QUEUE_DATA(q, uv__io_t, watcher_queue);
assert(w->pevents != 0); assert(w->pevents != 0);
assert(w->fd >= 0); assert(w->fd >= 0);
assert(w->fd < (int) loop->nwatchers); assert(w->fd < (int) loop->nwatchers);

14
deps/uv/src/unix/linux-core.c

@ -101,7 +101,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
struct uv__epoll_event events[1024]; struct uv__epoll_event events[1024];
struct uv__epoll_event* pe; struct uv__epoll_event* pe;
struct uv__epoll_event e; struct uv__epoll_event e;
ngx_queue_t* q; QUEUE* q;
uv__io_t* w; uv__io_t* w;
uint64_t base; uint64_t base;
uint64_t diff; uint64_t diff;
@ -113,16 +113,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
int i; int i;
if (loop->nfds == 0) { if (loop->nfds == 0) {
assert(ngx_queue_empty(&loop->watcher_queue)); assert(QUEUE_EMPTY(&loop->watcher_queue));
return; return;
} }
while (!ngx_queue_empty(&loop->watcher_queue)) { while (!QUEUE_EMPTY(&loop->watcher_queue)) {
q = ngx_queue_head(&loop->watcher_queue); q = QUEUE_HEAD(&loop->watcher_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
ngx_queue_init(q); QUEUE_INIT(q);
w = ngx_queue_data(q, uv__io_t, watcher_queue); w = QUEUE_DATA(q, uv__io_t, watcher_queue);
assert(w->pevents != 0); assert(w->pevents != 0);
assert(w->fd >= 0); assert(w->fd >= 0);
assert(w->fd < (int) loop->nwatchers); assert(w->fd < (int) loop->nwatchers);

16
deps/uv/src/unix/linux-inotify.c

@ -34,7 +34,7 @@
struct watcher_list { struct watcher_list {
RB_ENTRY(watcher_list) entry; RB_ENTRY(watcher_list) entry;
ngx_queue_t watchers; QUEUE watchers;
char* path; char* path;
int wd; int wd;
}; };
@ -119,7 +119,7 @@ static void uv__inotify_read(uv_loop_t* loop,
const struct uv__inotify_event* e; const struct uv__inotify_event* e;
struct watcher_list* w; struct watcher_list* w;
uv_fs_event_t* h; uv_fs_event_t* h;
ngx_queue_t* q; QUEUE* q;
const char* path; const char* path;
ssize_t size; ssize_t size;
const char *p; const char *p;
@ -158,8 +158,8 @@ static void uv__inotify_read(uv_loop_t* loop,
*/ */
path = e->len ? (const char*) (e + 1) : basename_r(w->path); path = e->len ? (const char*) (e + 1) : basename_r(w->path);
ngx_queue_foreach(q, &w->watchers) { QUEUE_FOREACH(q, &w->watchers) {
h = ngx_queue_data(q, uv_fs_event_t, watchers); h = QUEUE_DATA(q, uv_fs_event_t, watchers);
h->cb(h, path, events, 0); h->cb(h, path, events, 0);
} }
} }
@ -201,13 +201,13 @@ int uv_fs_event_init(uv_loop_t* loop,
w->wd = wd; w->wd = wd;
w->path = strcpy((char*)(w + 1), path); w->path = strcpy((char*)(w + 1), path);
ngx_queue_init(&w->watchers); QUEUE_INIT(&w->watchers);
RB_INSERT(watcher_root, CAST(&loop->inotify_watchers), w); RB_INSERT(watcher_root, CAST(&loop->inotify_watchers), w);
no_insert: no_insert:
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
uv__handle_start(handle); /* FIXME shouldn't start automatically */ uv__handle_start(handle); /* FIXME shouldn't start automatically */
ngx_queue_insert_tail(&w->watchers, &handle->watchers); QUEUE_INSERT_TAIL(&w->watchers, &handle->watchers);
handle->filename = w->path; handle->filename = w->path;
handle->cb = cb; handle->cb = cb;
handle->wd = wd; handle->wd = wd;
@ -225,9 +225,9 @@ void uv__fs_event_close(uv_fs_event_t* handle) {
handle->wd = -1; handle->wd = -1;
handle->filename = NULL; handle->filename = NULL;
uv__handle_stop(handle); uv__handle_stop(handle);
ngx_queue_remove(&handle->watchers); QUEUE_REMOVE(&handle->watchers);
if (ngx_queue_empty(&w->watchers)) { if (QUEUE_EMPTY(&w->watchers)) {
/* No watchers left for this path. Clean up. */ /* No watchers left for this path. Clean up. */
RB_REMOVE(watcher_root, CAST(&handle->loop->inotify_watchers), w); RB_REMOVE(watcher_root, CAST(&handle->loop->inotify_watchers), w);
uv__inotify_rm_watch(handle->loop->inotify_fd, w->wd); uv__inotify_rm_watch(handle->loop->inotify_fd, w->wd);

10
deps/uv/src/unix/loop-watcher.c

@ -33,7 +33,7 @@
if (uv__is_active(handle)) return 0; \ if (uv__is_active(handle)) return 0; \
if (cb == NULL) \ if (cb == NULL) \
return uv__set_artificial_error(handle->loop, UV_EINVAL); \ return uv__set_artificial_error(handle->loop, UV_EINVAL); \
ngx_queue_insert_head(&handle->loop->name##_handles, &handle->queue); \ QUEUE_INSERT_HEAD(&handle->loop->name##_handles, &handle->queue); \
handle->name##_cb = cb; \ handle->name##_cb = cb; \
uv__handle_start(handle); \ uv__handle_start(handle); \
return 0; \ return 0; \
@ -41,16 +41,16 @@
\ \
int uv_##name##_stop(uv_##name##_t* handle) { \ int uv_##name##_stop(uv_##name##_t* handle) { \
if (!uv__is_active(handle)) return 0; \ if (!uv__is_active(handle)) return 0; \
ngx_queue_remove(&handle->queue); \ QUEUE_REMOVE(&handle->queue); \
uv__handle_stop(handle); \ uv__handle_stop(handle); \
return 0; \ return 0; \
} \ } \
\ \
void uv__run_##name(uv_loop_t* loop) { \ void uv__run_##name(uv_loop_t* loop) { \
uv_##name##_t* h; \ uv_##name##_t* h; \
ngx_queue_t* q; \ QUEUE* q; \
ngx_queue_foreach(q, &loop->name##_handles) { \ QUEUE_FOREACH(q, &loop->name##_handles) { \
h = ngx_queue_data(q, uv_##name##_t, queue); \ h = QUEUE_DATA(q, uv_##name##_t, queue); \
h->name##_cb(h, 0); \ h->name##_cb(h, 0); \
} \ } \
} \ } \

26
deps/uv/src/unix/loop.c

@ -34,19 +34,19 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
memset(loop, 0, sizeof(*loop)); memset(loop, 0, sizeof(*loop));
RB_INIT(&loop->timer_handles); RB_INIT(&loop->timer_handles);
ngx_queue_init(&loop->wq); QUEUE_INIT(&loop->wq);
ngx_queue_init(&loop->active_reqs); QUEUE_INIT(&loop->active_reqs);
ngx_queue_init(&loop->idle_handles); QUEUE_INIT(&loop->idle_handles);
ngx_queue_init(&loop->async_handles); QUEUE_INIT(&loop->async_handles);
ngx_queue_init(&loop->check_handles); QUEUE_INIT(&loop->check_handles);
ngx_queue_init(&loop->prepare_handles); QUEUE_INIT(&loop->prepare_handles);
ngx_queue_init(&loop->handle_queue); QUEUE_INIT(&loop->handle_queue);
loop->nfds = 0; loop->nfds = 0;
loop->watchers = NULL; loop->watchers = NULL;
loop->nwatchers = 0; loop->nwatchers = 0;
ngx_queue_init(&loop->pending_queue); QUEUE_INIT(&loop->pending_queue);
ngx_queue_init(&loop->watcher_queue); QUEUE_INIT(&loop->watcher_queue);
loop->closing_handles = NULL; loop->closing_handles = NULL;
loop->time = uv__hrtime() / 1000000; loop->time = uv__hrtime() / 1000000;
@ -67,7 +67,7 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
loop->child_watcher.flags |= UV__HANDLE_INTERNAL; loop->child_watcher.flags |= UV__HANDLE_INTERNAL;
for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++)
ngx_queue_init(loop->process_handles + i); QUEUE_INIT(loop->process_handles + i);
if (uv_mutex_init(&loop->wq_mutex)) if (uv_mutex_init(&loop->wq_mutex))
abort(); abort();
@ -98,13 +98,13 @@ void uv__loop_delete(uv_loop_t* loop) {
} }
uv_mutex_lock(&loop->wq_mutex); uv_mutex_lock(&loop->wq_mutex);
assert(ngx_queue_empty(&loop->wq) && "thread pool work queue not empty!"); assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!");
uv_mutex_unlock(&loop->wq_mutex); uv_mutex_unlock(&loop->wq_mutex);
uv_mutex_destroy(&loop->wq_mutex); uv_mutex_destroy(&loop->wq_mutex);
#if 0 #if 0
assert(ngx_queue_empty(&loop->pending_queue)); assert(QUEUE_EMPTY(&loop->pending_queue));
assert(ngx_queue_empty(&loop->watcher_queue)); assert(QUEUE_EMPTY(&loop->watcher_queue));
assert(loop->nfds == 0); assert(loop->nfds == 0);
#endif #endif

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

@ -214,7 +214,7 @@ out:
uv__req_init(handle->loop, req, UV_CONNECT); uv__req_init(handle->loop, req, UV_CONNECT);
req->handle = (uv_stream_t*)handle; req->handle = (uv_stream_t*)handle;
req->cb = cb; req->cb = cb;
ngx_queue_init(&req->queue); QUEUE_INIT(&req->queue);
/* Force callback to run on next tick in case of error. */ /* Force callback to run on next tick in case of error. */
if (err != 0) if (err != 0)

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

@ -41,7 +41,7 @@ extern char **environ;
#endif #endif
static ngx_queue_t* uv__process_queue(uv_loop_t* loop, int pid) { static QUEUE* uv__process_queue(uv_loop_t* loop, int pid) {
assert(pid > 0); assert(pid > 0);
return loop->process_handles + pid % ARRAY_SIZE(loop->process_handles); return loop->process_handles + pid % ARRAY_SIZE(loop->process_handles);
} }
@ -49,13 +49,13 @@ static ngx_queue_t* uv__process_queue(uv_loop_t* loop, int pid) {
static uv_process_t* uv__process_find(uv_loop_t* loop, int pid) { static uv_process_t* uv__process_find(uv_loop_t* loop, int pid) {
uv_process_t* handle; uv_process_t* handle;
ngx_queue_t* h; QUEUE* h;
ngx_queue_t* q; QUEUE* q;
h = uv__process_queue(loop, pid); h = uv__process_queue(loop, pid);
ngx_queue_foreach(q, h) { QUEUE_FOREACH(q, h) {
handle = ngx_queue_data(q, uv_process_t, queue); handle = QUEUE_DATA(q, uv_process_t, queue);
if (handle->pid == pid) return handle; if (handle->pid == pid) return handle;
} }
@ -351,7 +351,7 @@ int uv_spawn(uv_loop_t* loop,
int signal_pipe[2] = { -1, -1 }; int signal_pipe[2] = { -1, -1 };
int (*pipes)[2]; int (*pipes)[2];
int stdio_count; int stdio_count;
ngx_queue_t* q; QUEUE* q;
ssize_t r; ssize_t r;
pid_t pid; pid_t pid;
int i; int i;
@ -364,7 +364,7 @@ int uv_spawn(uv_loop_t* loop,
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS)));
uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS); uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS);
ngx_queue_init(&process->queue); QUEUE_INIT(&process->queue);
stdio_count = options.stdio_count; stdio_count = options.stdio_count;
if (stdio_count < 3) if (stdio_count < 3)
@ -449,7 +449,7 @@ int uv_spawn(uv_loop_t* loop,
} }
q = uv__process_queue(loop, pid); q = uv__process_queue(loop, pid);
ngx_queue_insert_tail(q, &process->queue); QUEUE_INSERT_TAIL(q, &process->queue);
process->pid = pid; process->pid = pid;
process->exit_cb = options.exit_cb; process->exit_cb = options.exit_cb;
@ -496,6 +496,6 @@ uv_err_t uv_kill(int pid, int signum) {
void uv__process_close(uv_process_t* handle) { void uv__process_close(uv_process_t* handle) {
/* TODO stop signal watcher when this is the last handle */ /* TODO stop signal watcher when this is the last handle */
ngx_queue_remove(&handle->queue); QUEUE_REMOVE(&handle->queue);
uv__handle_stop(handle); uv__handle_stop(handle);
} }

6
deps/uv/src/unix/signal.c

@ -223,14 +223,14 @@ static int uv__signal_loop_once_init(uv_loop_t* loop) {
void uv__signal_loop_cleanup(uv_loop_t* loop) { void uv__signal_loop_cleanup(uv_loop_t* loop) {
ngx_queue_t* q; QUEUE* q;
/* Stop all the signal watchers that are still attached to this loop. This /* Stop all the signal watchers that are still attached to this loop. This
* ensures that the (shared) signal tree doesn't contain any invalid entries * ensures that the (shared) signal tree doesn't contain any invalid entries
* entries, and that signal handlers are removed when appropriate. * entries, and that signal handlers are removed when appropriate.
*/ */
ngx_queue_foreach(q, &loop->handle_queue) { QUEUE_FOREACH(q, &loop->handle_queue) {
uv_handle_t* handle = ngx_queue_data(q, uv_handle_t, handle_queue); uv_handle_t* handle = QUEUE_DATA(q, uv_handle_t, handle_queue);
if (handle->type == UV_SIGNAL) if (handle->type == UV_SIGNAL)
uv__signal_stop((uv_signal_t*) handle); uv__signal_stop((uv_signal_t*) handle);

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

@ -109,8 +109,8 @@ void uv__stream_init(uv_loop_t* loop,
stream->shutdown_req = NULL; stream->shutdown_req = NULL;
stream->accepted_fd = -1; stream->accepted_fd = -1;
stream->delayed_error = 0; stream->delayed_error = 0;
ngx_queue_init(&stream->write_queue); QUEUE_INIT(&stream->write_queue);
ngx_queue_init(&stream->write_completed_queue); QUEUE_INIT(&stream->write_completed_queue);
stream->write_queue_size = 0; stream->write_queue_size = 0;
if (loop->emfile_fd == -1) if (loop->emfile_fd == -1)
@ -373,7 +373,7 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) {
void uv__stream_destroy(uv_stream_t* stream) { void uv__stream_destroy(uv_stream_t* stream) {
uv_write_t* req; uv_write_t* req;
ngx_queue_t* q; QUEUE* q;
assert(!uv__io_active(&stream->io_watcher, UV__POLLIN | UV__POLLOUT)); assert(!uv__io_active(&stream->io_watcher, UV__POLLIN | UV__POLLOUT));
assert(stream->flags & UV_CLOSED); assert(stream->flags & UV_CLOSED);
@ -385,11 +385,11 @@ void uv__stream_destroy(uv_stream_t* stream) {
stream->connect_req = NULL; stream->connect_req = NULL;
} }
while (!ngx_queue_empty(&stream->write_queue)) { while (!QUEUE_EMPTY(&stream->write_queue)) {
q = ngx_queue_head(&stream->write_queue); q = QUEUE_HEAD(&stream->write_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
req = ngx_queue_data(q, uv_write_t, queue); req = QUEUE_DATA(q, uv_write_t, queue);
uv__req_unregister(stream->loop, req); uv__req_unregister(stream->loop, req);
if (req->bufs != req->bufsml) if (req->bufs != req->bufsml)
@ -401,11 +401,11 @@ void uv__stream_destroy(uv_stream_t* stream) {
} }
} }
while (!ngx_queue_empty(&stream->write_completed_queue)) { while (!QUEUE_EMPTY(&stream->write_completed_queue)) {
q = ngx_queue_head(&stream->write_completed_queue); q = QUEUE_HEAD(&stream->write_completed_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
req = ngx_queue_data(q, uv_write_t, queue); req = QUEUE_DATA(q, uv_write_t, queue);
uv__req_unregister(stream->loop, req); uv__req_unregister(stream->loop, req);
if (req->cb) { if (req->cb) {
@ -638,7 +638,7 @@ int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {
static void uv__drain(uv_stream_t* stream) { static void uv__drain(uv_stream_t* stream) {
uv_shutdown_t* req; uv_shutdown_t* req;
assert(ngx_queue_empty(&stream->write_queue)); assert(QUEUE_EMPTY(&stream->write_queue));
assert(stream->write_queue_size == 0); assert(stream->write_queue_size == 0);
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT);
@ -685,7 +685,7 @@ static void uv__write_req_finish(uv_write_t* req) {
uv_stream_t* stream = req->handle; uv_stream_t* stream = req->handle;
/* Pop the req off tcp->write_queue. */ /* Pop the req off tcp->write_queue. */
ngx_queue_remove(&req->queue); QUEUE_REMOVE(&req->queue);
if (req->bufs != req->bufsml) { if (req->bufs != req->bufsml) {
free(req->bufs); free(req->bufs);
} }
@ -694,7 +694,7 @@ static void uv__write_req_finish(uv_write_t* req) {
/* Add it to the write_completed_queue where it will have its /* Add it to the write_completed_queue where it will have its
* callback called in the near future. * callback called in the near future.
*/ */
ngx_queue_insert_tail(&stream->write_completed_queue, &req->queue); QUEUE_INSERT_TAIL(&stream->write_completed_queue, &req->queue);
uv__io_feed(stream->loop, &stream->io_watcher); uv__io_feed(stream->loop, &stream->io_watcher);
} }
@ -716,7 +716,7 @@ static int uv__handle_fd(uv_handle_t* handle) {
static void uv__write(uv_stream_t* stream) { static void uv__write(uv_stream_t* stream) {
struct iovec* iov; struct iovec* iov;
ngx_queue_t* q; QUEUE* q;
uv_write_t* req; uv_write_t* req;
int iovcnt; int iovcnt;
ssize_t n; ssize_t n;
@ -725,13 +725,13 @@ start:
assert(uv__stream_fd(stream) >= 0); assert(uv__stream_fd(stream) >= 0);
if (ngx_queue_empty(&stream->write_queue)) { if (QUEUE_EMPTY(&stream->write_queue)) {
assert(stream->write_queue_size == 0); assert(stream->write_queue_size == 0);
return; return;
} }
q = ngx_queue_head(&stream->write_queue); q = QUEUE_HEAD(&stream->write_queue);
req = ngx_queue_data(q, uv_write_t, queue); req = QUEUE_DATA(q, uv_write_t, queue);
assert(req->handle == stream); assert(req->handle == stream);
/* /*
@ -863,13 +863,13 @@ start:
static void uv__write_callbacks(uv_stream_t* stream) { static void uv__write_callbacks(uv_stream_t* stream) {
uv_write_t* req; uv_write_t* req;
ngx_queue_t* q; QUEUE* q;
while (!ngx_queue_empty(&stream->write_completed_queue)) { while (!QUEUE_EMPTY(&stream->write_completed_queue)) {
/* Pop a req off write_completed_queue. */ /* Pop a req off write_completed_queue. */
q = ngx_queue_head(&stream->write_completed_queue); q = QUEUE_HEAD(&stream->write_completed_queue);
req = ngx_queue_data(q, uv_write_t, queue); req = QUEUE_DATA(q, uv_write_t, queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
uv__req_unregister(stream->loop, req); uv__req_unregister(stream->loop, req);
/* NOTE: call callback AFTER freeing the request data. */ /* NOTE: call callback AFTER freeing the request data. */
@ -879,10 +879,10 @@ static void uv__write_callbacks(uv_stream_t* stream) {
} }
} }
assert(ngx_queue_empty(&stream->write_completed_queue)); assert(QUEUE_EMPTY(&stream->write_completed_queue));
/* Write queue drained. */ /* Write queue drained. */
if (ngx_queue_empty(&stream->write_queue)) if (QUEUE_EMPTY(&stream->write_queue))
uv__drain(stream); uv__drain(stream);
} }
@ -1200,7 +1200,7 @@ int uv_write2(uv_write_t* req,
req->handle = stream; req->handle = stream;
req->error = 0; req->error = 0;
req->send_handle = send_handle; req->send_handle = send_handle;
ngx_queue_init(&req->queue); QUEUE_INIT(&req->queue);
if (bufcnt <= (int) ARRAY_SIZE(req->bufsml)) if (bufcnt <= (int) ARRAY_SIZE(req->bufsml))
req->bufs = req->bufsml; req->bufs = req->bufsml;
@ -1213,7 +1213,7 @@ int uv_write2(uv_write_t* req,
stream->write_queue_size += uv__buf_count(bufs, bufcnt); stream->write_queue_size += uv__buf_count(bufs, bufcnt);
/* Append the request to write_queue. */ /* Append the request to write_queue. */
ngx_queue_insert_tail(&stream->write_queue, &req->queue); QUEUE_INSERT_TAIL(&stream->write_queue, &req->queue);
/* If the queue was empty when this function began, we should attempt to /* If the queue was empty when this function began, we should attempt to
* do the write immediately. Otherwise start the write_watcher and wait * do the write immediately. Otherwise start the write_watcher and wait

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

@ -91,7 +91,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
struct port_event events[1024]; struct port_event events[1024];
struct port_event* pe; struct port_event* pe;
struct timespec spec; struct timespec spec;
ngx_queue_t* q; QUEUE* q;
uv__io_t* w; uv__io_t* w;
uint64_t base; uint64_t base;
uint64_t diff; uint64_t diff;
@ -103,16 +103,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
int fd; int fd;
if (loop->nfds == 0) { if (loop->nfds == 0) {
assert(ngx_queue_empty(&loop->watcher_queue)); assert(QUEUE_EMPTY(&loop->watcher_queue));
return; return;
} }
while (!ngx_queue_empty(&loop->watcher_queue)) { while (!QUEUE_EMPTY(&loop->watcher_queue)) {
q = ngx_queue_head(&loop->watcher_queue); q = QUEUE_HEAD(&loop->watcher_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
ngx_queue_init(q); QUEUE_INIT(q);
w = ngx_queue_data(q, uv__io_t, watcher_queue); w = QUEUE_DATA(q, uv__io_t, watcher_queue);
assert(w->pevents != 0); assert(w->pevents != 0);
if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0)) if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0))
@ -190,8 +190,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
nevents++; nevents++;
/* Events Ports operates in oneshot mode, rearm timer on next run. */ /* Events Ports operates in oneshot mode, rearm timer on next run. */
if (w->pevents != 0 && ngx_queue_empty(&w->watcher_queue)) if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue))
ngx_queue_insert_tail(&loop->watcher_queue, &w->watcher_queue); QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
} }
if (nevents != 0) { if (nevents != 0) {

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

@ -116,7 +116,7 @@ static int uv__connect(uv_connect_t* req,
uv__req_init(handle->loop, req, UV_CONNECT); uv__req_init(handle->loop, req, UV_CONNECT);
req->cb = cb; req->cb = cb;
req->handle = (uv_stream_t*) handle; req->handle = (uv_stream_t*) handle;
ngx_queue_init(&req->queue); QUEUE_INIT(&req->queue);
handle->connect_req = req; handle->connect_req = req;
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT); uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT);

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

@ -30,8 +30,8 @@ static uv_mutex_t mutex;
static unsigned int nthreads; static unsigned int nthreads;
static uv_thread_t* threads; static uv_thread_t* threads;
static uv_thread_t default_threads[4]; static uv_thread_t default_threads[4];
static ngx_queue_t exit_message; static QUEUE exit_message;
static ngx_queue_t wq; static QUEUE wq;
static volatile int initialized; static volatile int initialized;
@ -45,23 +45,23 @@ static void uv__cancelled(struct uv__work* w) {
*/ */
static void worker(void* arg) { static void worker(void* arg) {
struct uv__work* w; struct uv__work* w;
ngx_queue_t* q; QUEUE* q;
(void) arg; (void) arg;
for (;;) { for (;;) {
uv_mutex_lock(&mutex); uv_mutex_lock(&mutex);
while (ngx_queue_empty(&wq)) while (QUEUE_EMPTY(&wq))
uv_cond_wait(&cond, &mutex); uv_cond_wait(&cond, &mutex);
q = ngx_queue_head(&wq); q = QUEUE_HEAD(&wq);
if (q == &exit_message) if (q == &exit_message)
uv_cond_signal(&cond); uv_cond_signal(&cond);
else { else {
ngx_queue_remove(q); QUEUE_REMOVE(q);
ngx_queue_init(q); /* Signal uv_cancel() that the work req is QUEUE_INIT(q); /* Signal uv_cancel() that the work req is
executing. */ executing. */
} }
@ -70,22 +70,22 @@ static void worker(void* arg) {
if (q == &exit_message) if (q == &exit_message)
break; break;
w = ngx_queue_data(q, struct uv__work, wq); w = QUEUE_DATA(q, struct uv__work, wq);
w->work(w); w->work(w);
uv_mutex_lock(&w->loop->wq_mutex); uv_mutex_lock(&w->loop->wq_mutex);
w->work = NULL; /* Signal uv_cancel() that the work req is done w->work = NULL; /* Signal uv_cancel() that the work req is done
executing. */ executing. */
ngx_queue_insert_tail(&w->loop->wq, &w->wq); QUEUE_INSERT_TAIL(&w->loop->wq, &w->wq);
uv_async_send(&w->loop->wq_async); uv_async_send(&w->loop->wq_async);
uv_mutex_unlock(&w->loop->wq_mutex); uv_mutex_unlock(&w->loop->wq_mutex);
} }
} }
static void post(ngx_queue_t* q) { static void post(QUEUE* q) {
uv_mutex_lock(&mutex); uv_mutex_lock(&mutex);
ngx_queue_insert_tail(&wq, q); QUEUE_INSERT_TAIL(&wq, q);
uv_cond_signal(&cond); uv_cond_signal(&cond);
uv_mutex_unlock(&mutex); uv_mutex_unlock(&mutex);
} }
@ -119,7 +119,7 @@ static void init_once(void) {
if (uv_mutex_init(&mutex)) if (uv_mutex_init(&mutex))
abort(); abort();
ngx_queue_init(&wq); QUEUE_INIT(&wq);
for (i = 0; i < nthreads; i++) for (i = 0; i < nthreads; i++)
if (uv_thread_create(threads + i, worker, NULL)) if (uv_thread_create(threads + i, worker, NULL))
@ -174,9 +174,9 @@ static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) {
uv_mutex_lock(&mutex); uv_mutex_lock(&mutex);
uv_mutex_lock(&w->loop->wq_mutex); uv_mutex_lock(&w->loop->wq_mutex);
cancelled = !ngx_queue_empty(&w->wq) && w->work != NULL; cancelled = !QUEUE_EMPTY(&w->wq) && w->work != NULL;
if (cancelled) if (cancelled)
ngx_queue_remove(&w->wq); QUEUE_REMOVE(&w->wq);
uv_mutex_unlock(&w->loop->wq_mutex); uv_mutex_unlock(&w->loop->wq_mutex);
uv_mutex_unlock(&mutex); uv_mutex_unlock(&mutex);
@ -186,7 +186,7 @@ static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) {
w->work = uv__cancelled; w->work = uv__cancelled;
uv_mutex_lock(&loop->wq_mutex); uv_mutex_lock(&loop->wq_mutex);
ngx_queue_insert_tail(&loop->wq, &w->wq); QUEUE_INSERT_TAIL(&loop->wq, &w->wq);
uv_async_send(&loop->wq_async); uv_async_send(&loop->wq_async);
uv_mutex_unlock(&loop->wq_mutex); uv_mutex_unlock(&loop->wq_mutex);
@ -197,23 +197,23 @@ static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) {
void uv__work_done(uv_async_t* handle, int status) { void uv__work_done(uv_async_t* handle, int status) {
struct uv__work* w; struct uv__work* w;
uv_loop_t* loop; uv_loop_t* loop;
ngx_queue_t* q; QUEUE* q;
ngx_queue_t wq; QUEUE wq;
int err; int err;
loop = container_of(handle, uv_loop_t, wq_async); loop = container_of(handle, uv_loop_t, wq_async);
ngx_queue_init(&wq); QUEUE_INIT(&wq);
uv_mutex_lock(&loop->wq_mutex); uv_mutex_lock(&loop->wq_mutex);
if (!ngx_queue_empty(&loop->wq)) { if (!QUEUE_EMPTY(&loop->wq)) {
q = ngx_queue_head(&loop->wq); q = QUEUE_HEAD(&loop->wq);
ngx_queue_split(&loop->wq, q, &wq); QUEUE_SPLIT(&loop->wq, q, &wq);
} }
uv_mutex_unlock(&loop->wq_mutex); uv_mutex_unlock(&loop->wq_mutex);
while (!ngx_queue_empty(&wq)) { while (!QUEUE_EMPTY(&wq)) {
q = ngx_queue_head(&wq); q = QUEUE_HEAD(&wq);
ngx_queue_remove(q); QUEUE_REMOVE(q);
w = container_of(q, struct uv__work, wq); w = container_of(q, struct uv__work, wq);
err = (w->work == uv__cancelled) ? -UV_ECANCELED : 0; err = (w->work == uv__cancelled) ? -UV_ECANCELED : 0;

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

@ -54,18 +54,18 @@ void uv__udp_close(uv_udp_t* handle) {
void uv__udp_finish_close(uv_udp_t* handle) { void uv__udp_finish_close(uv_udp_t* handle) {
uv_udp_send_t* req; uv_udp_send_t* req;
ngx_queue_t* q; QUEUE* q;
assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT)); assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT));
assert(handle->io_watcher.fd == -1); assert(handle->io_watcher.fd == -1);
uv__udp_run_completed(handle); uv__udp_run_completed(handle);
while (!ngx_queue_empty(&handle->write_queue)) { while (!QUEUE_EMPTY(&handle->write_queue)) {
q = ngx_queue_head(&handle->write_queue); q = QUEUE_HEAD(&handle->write_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
req = ngx_queue_data(q, uv_udp_send_t, queue); req = QUEUE_DATA(q, uv_udp_send_t, queue);
uv__req_unregister(handle->loop, req); uv__req_unregister(handle->loop, req);
if (req->bufs != req->bufsml) if (req->bufs != req->bufsml)
@ -87,15 +87,15 @@ void uv__udp_finish_close(uv_udp_t* handle) {
static void uv__udp_run_pending(uv_udp_t* handle) { static void uv__udp_run_pending(uv_udp_t* handle) {
uv_udp_send_t* req; uv_udp_send_t* req;
ngx_queue_t* q; QUEUE* q;
struct msghdr h; struct msghdr h;
ssize_t size; ssize_t size;
while (!ngx_queue_empty(&handle->write_queue)) { while (!QUEUE_EMPTY(&handle->write_queue)) {
q = ngx_queue_head(&handle->write_queue); q = QUEUE_HEAD(&handle->write_queue);
assert(q != NULL); assert(q != NULL);
req = ngx_queue_data(q, uv_udp_send_t, queue); req = QUEUE_DATA(q, uv_udp_send_t, queue);
assert(req != NULL); assert(req != NULL);
memset(&h, 0, sizeof h); memset(&h, 0, sizeof h);
@ -136,21 +136,21 @@ static void uv__udp_run_pending(uv_udp_t* handle) {
* why we don't handle partial writes. Just pop the request * why we don't handle partial writes. Just pop the request
* off the write queue and onto the completed queue, done. * off the write queue and onto the completed queue, done.
*/ */
ngx_queue_remove(&req->queue); QUEUE_REMOVE(&req->queue);
ngx_queue_insert_tail(&handle->write_completed_queue, &req->queue); QUEUE_INSERT_TAIL(&handle->write_completed_queue, &req->queue);
} }
} }
static void uv__udp_run_completed(uv_udp_t* handle) { static void uv__udp_run_completed(uv_udp_t* handle) {
uv_udp_send_t* req; uv_udp_send_t* req;
ngx_queue_t* q; QUEUE* q;
while (!ngx_queue_empty(&handle->write_completed_queue)) { while (!QUEUE_EMPTY(&handle->write_completed_queue)) {
q = ngx_queue_head(&handle->write_completed_queue); q = QUEUE_HEAD(&handle->write_completed_queue);
ngx_queue_remove(q); QUEUE_REMOVE(q);
req = ngx_queue_data(q, uv_udp_send_t, queue); req = QUEUE_DATA(q, uv_udp_send_t, queue);
uv__req_unregister(handle->loop, req); uv__req_unregister(handle->loop, req);
if (req->bufs != req->bufsml) if (req->bufs != req->bufsml)
@ -263,8 +263,8 @@ static void uv__udp_sendmsg(uv_loop_t* loop,
assert(handle->type == UV_UDP); assert(handle->type == UV_UDP);
assert(revents & UV__POLLOUT); assert(revents & UV__POLLOUT);
assert(!ngx_queue_empty(&handle->write_queue) assert(!QUEUE_EMPTY(&handle->write_queue)
|| !ngx_queue_empty(&handle->write_completed_queue)); || !QUEUE_EMPTY(&handle->write_completed_queue));
/* Write out pending data first. */ /* Write out pending data first. */
uv__udp_run_pending(handle); uv__udp_run_pending(handle);
@ -272,11 +272,11 @@ static void uv__udp_sendmsg(uv_loop_t* loop,
/* Drain 'request completed' queue. */ /* Drain 'request completed' queue. */
uv__udp_run_completed(handle); uv__udp_run_completed(handle);
if (!ngx_queue_empty(&handle->write_completed_queue)) { if (!QUEUE_EMPTY(&handle->write_completed_queue)) {
/* Schedule completion callbacks. */ /* Schedule completion callbacks. */
uv__io_feed(handle->loop, &handle->io_watcher); uv__io_feed(handle->loop, &handle->io_watcher);
} }
else if (ngx_queue_empty(&handle->write_queue)) { else if (QUEUE_EMPTY(&handle->write_queue)) {
/* Pending queue and completion queue empty, stop watcher. */ /* Pending queue and completion queue empty, stop watcher. */
uv__io_stop(loop, &handle->io_watcher, UV__POLLOUT); uv__io_stop(loop, &handle->io_watcher, UV__POLLOUT);
@ -441,7 +441,7 @@ static int uv__send(uv_udp_send_t* req,
} }
memcpy(req->bufs, bufs, bufcnt * sizeof(bufs[0])); memcpy(req->bufs, bufs, bufcnt * sizeof(bufs[0]));
ngx_queue_insert_tail(&handle->write_queue, &req->queue); QUEUE_INSERT_TAIL(&handle->write_queue, &req->queue);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT); uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT);
uv__handle_start(handle); uv__handle_start(handle);
@ -454,8 +454,8 @@ int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
handle->alloc_cb = NULL; handle->alloc_cb = NULL;
handle->recv_cb = NULL; handle->recv_cb = NULL;
uv__io_init(&handle->io_watcher, uv__udp_io, -1); uv__io_init(&handle->io_watcher, uv__udp_io, -1);
ngx_queue_init(&handle->write_queue); QUEUE_INIT(&handle->write_queue);
ngx_queue_init(&handle->write_completed_queue); QUEUE_INIT(&handle->write_completed_queue);
return 0; return 0;
} }

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

@ -361,11 +361,11 @@ unsigned long uv_thread_self(void) {
void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
ngx_queue_t* q; QUEUE* q;
uv_handle_t* h; uv_handle_t* h;
ngx_queue_foreach(q, &loop->handle_queue) { QUEUE_FOREACH(q, &loop->handle_queue) {
h = ngx_queue_data(q, uv_handle_t, handle_queue); h = QUEUE_DATA(q, uv_handle_t, handle_queue);
if (h->flags & UV__HANDLE_INTERNAL) continue; if (h->flags & UV__HANDLE_INTERNAL) continue;
walk_cb(h, arg); walk_cb(h, arg);
} }
@ -375,14 +375,14 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
#ifndef NDEBUG #ifndef NDEBUG
static void uv__print_handles(uv_loop_t* loop, int only_active) { static void uv__print_handles(uv_loop_t* loop, int only_active) {
const char* type; const char* type;
ngx_queue_t* q; QUEUE* q;
uv_handle_t* h; uv_handle_t* h;
if (loop == NULL) if (loop == NULL)
loop = uv_default_loop(); loop = uv_default_loop();
ngx_queue_foreach(q, &loop->handle_queue) { QUEUE_FOREACH(q, &loop->handle_queue) {
h = ngx_queue_data(q, uv_handle_t, handle_queue); h = QUEUE_DATA(q, uv_handle_t, handle_queue);
if (only_active && !uv__is_active(h)) if (only_active && !uv__is_active(h))
continue; continue;

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

@ -38,6 +38,7 @@
#include "uv.h" #include "uv.h"
#include "tree.h" #include "tree.h"
#include "queue.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
@ -116,18 +117,18 @@ void uv__fs_poll_close(uv_fs_poll_t* handle);
#define uv__has_active_reqs(loop) \ #define uv__has_active_reqs(loop) \
(ngx_queue_empty(&(loop)->active_reqs) == 0) (QUEUE_EMPTY(&(loop)->active_reqs) == 0)
#define uv__req_register(loop, req) \ #define uv__req_register(loop, req) \
do { \ do { \
ngx_queue_insert_tail(&(loop)->active_reqs, &(req)->active_queue); \ QUEUE_INSERT_TAIL(&(loop)->active_reqs, &(req)->active_queue); \
} \ } \
while (0) while (0)
#define uv__req_unregister(loop, req) \ #define uv__req_unregister(loop, req) \
do { \ do { \
assert(uv__has_active_reqs(loop)); \ assert(uv__has_active_reqs(loop)); \
ngx_queue_remove(&(req)->active_queue); \ QUEUE_REMOVE(&(req)->active_queue); \
} \ } \
while (0) while (0)
@ -196,7 +197,7 @@ void uv__fs_poll_close(uv_fs_poll_t* handle);
(h)->loop = (loop_); \ (h)->loop = (loop_); \
(h)->type = (type_); \ (h)->type = (type_); \
(h)->flags = UV__HANDLE_REF; /* Ref the loop when active. */ \ (h)->flags = UV__HANDLE_REF; /* Ref the loop when active. */ \
ngx_queue_insert_tail(&(loop_)->handle_queue, &(h)->handle_queue); \ QUEUE_INSERT_TAIL(&(loop_)->handle_queue, &(h)->handle_queue); \
uv__handle_platform_init(h); \ uv__handle_platform_init(h); \
} \ } \
while (0) while (0)

6
deps/uv/src/version.c

@ -27,9 +27,9 @@
*/ */
#define UV_VERSION_MAJOR 0 #define UV_VERSION_MAJOR 0
#define UV_VERSION_MINOR 10 #define UV_VERSION_MINOR 11
#define UV_VERSION_PATCH 3 #define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_IS_RELEASE 0
#define UV_VERSION ((UV_VERSION_MAJOR << 16) | \ #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \

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

@ -92,8 +92,8 @@ static void uv_loop_init(uv_loop_t* loop) {
loop->time = 0; loop->time = 0;
uv_update_time(loop); uv_update_time(loop);
ngx_queue_init(&loop->handle_queue); QUEUE_INIT(&loop->handle_queue);
ngx_queue_init(&loop->active_reqs); QUEUE_INIT(&loop->active_reqs);
loop->active_handles = 0; loop->active_handles = 0;
loop->pending_reqs_tail = NULL; loop->pending_reqs_tail = NULL;
@ -253,7 +253,7 @@ static void uv_poll_ex(uv_loop_t* loop, int block) {
static int uv__loop_alive(uv_loop_t* loop) { static int uv__loop_alive(uv_loop_t* loop) {
return loop->active_handles > 0 || return loop->active_handles > 0 ||
!ngx_queue_empty(&loop->active_reqs) || !QUEUE_EMPTY(&loop->active_reqs) ||
loop->endgame_handles != NULL; loop->endgame_handles != NULL;
} }
@ -291,7 +291,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
loop->endgame_handles == NULL && loop->endgame_handles == NULL &&
!loop->stop_flag && !loop->stop_flag &&
(loop->active_handles > 0 || (loop->active_handles > 0 ||
!ngx_queue_empty(&loop->active_reqs)) && !QUEUE_EMPTY(&loop->active_reqs)) &&
!(mode & UV_RUN_NOWAIT)); !(mode & UV_RUN_NOWAIT));
uv_check_invoke(loop); uv_check_invoke(loop);

2
deps/uv/src/win/handle-inl.h

@ -74,7 +74,7 @@
#define uv__handle_close(handle) \ #define uv__handle_close(handle) \
do { \ do { \
ngx_queue_remove(&(handle)->handle_queue); \ QUEUE_REMOVE(&(handle)->handle_queue); \
uv__active_handle_rm((uv_handle_t*) (handle)); \ uv__active_handle_rm((uv_handle_t*) (handle)); \
\ \
(handle)->flags |= UV_HANDLE_CLOSED; \ (handle)->flags |= UV_HANDLE_CLOSED; \

29
deps/uv/test/test-getaddrinfo.c

@ -33,6 +33,18 @@ static int getaddrinfo_cbs = 0;
static uv_getaddrinfo_t* getaddrinfo_handle; static uv_getaddrinfo_t* getaddrinfo_handle;
static uv_getaddrinfo_t getaddrinfo_handles[CONCURRENT_COUNT]; static uv_getaddrinfo_t getaddrinfo_handles[CONCURRENT_COUNT];
static int callback_counts[CONCURRENT_COUNT]; static int callback_counts[CONCURRENT_COUNT];
static int fail_cb_called;
static void getaddrinfo_fail_cb(uv_getaddrinfo_t* req,
int status,
struct addrinfo* res) {
ASSERT(fail_cb_called == 0);
ASSERT(status == -1);
ASSERT(res == NULL);
uv_freeaddrinfo(res); /* Should not crash. */
fail_cb_called++;
}
static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle, static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle,
@ -68,6 +80,23 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle,
} }
TEST_IMPL(getaddrinfo_fail) {
uv_getaddrinfo_t req;
ASSERT(0 == uv_getaddrinfo(uv_default_loop(),
&req,
getaddrinfo_fail_cb,
"xyzzy.xyzzy.xyzzy",
NULL,
NULL));
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
ASSERT(fail_cb_called == 1);
MAKE_VALGRIND_HAPPY();
return 0;
}
TEST_IMPL(getaddrinfo_basic) { TEST_IMPL(getaddrinfo_basic) {
int r; int r;
getaddrinfo_handle = (uv_getaddrinfo_t*)malloc(sizeof(uv_getaddrinfo_t)); getaddrinfo_handle = (uv_getaddrinfo_t*)malloc(sizeof(uv_getaddrinfo_t));

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

@ -136,6 +136,7 @@ TEST_DECLARE (process_title)
TEST_DECLARE (cwd_and_chdir) TEST_DECLARE (cwd_and_chdir)
TEST_DECLARE (get_memory) TEST_DECLARE (get_memory)
TEST_DECLARE (hrtime) TEST_DECLARE (hrtime)
TEST_DECLARE (getaddrinfo_fail)
TEST_DECLARE (getaddrinfo_basic) TEST_DECLARE (getaddrinfo_basic)
TEST_DECLARE (getaddrinfo_concurrent) TEST_DECLARE (getaddrinfo_concurrent)
TEST_DECLARE (getsockname_tcp) TEST_DECLARE (getsockname_tcp)
@ -398,6 +399,7 @@ TASK_LIST_START
TEST_ENTRY (hrtime) TEST_ENTRY (hrtime)
TEST_ENTRY (getaddrinfo_fail)
TEST_ENTRY (getaddrinfo_basic) TEST_ENTRY (getaddrinfo_basic)
TEST_ENTRY (getaddrinfo_concurrent) TEST_ENTRY (getaddrinfo_concurrent)

4
deps/uv/test/test-threadpool-cancel.c

@ -121,7 +121,9 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* req,
int status, int status,
struct addrinfo* res) { struct addrinfo* res) {
ASSERT(UV_ECANCELED == uv_last_error(req->loop).code); ASSERT(UV_ECANCELED == uv_last_error(req->loop).code);
ASSERT(UV_ECANCELED == status); ASSERT(status == -1);
ASSERT(res == NULL);
uv_freeaddrinfo(res); /* Should not crash. */
getaddrinfo_cb_called++; getaddrinfo_cb_called++;
} }

2
deps/uv/uv.gyp

@ -50,10 +50,10 @@
'sources': [ 'sources': [
'common.gypi', 'common.gypi',
'include/uv.h', 'include/uv.h',
'include/uv-private/ngx-queue.h',
'include/uv-private/tree.h', 'include/uv-private/tree.h',
'src/fs-poll.c', 'src/fs-poll.c',
'src/inet.c', 'src/inet.c',
'src/queue.h',
'src/uv-common.c', 'src/uv-common.c',
'src/uv-common.h', 'src/uv-common.h',
'src/version.c' 'src/version.c'

Loading…
Cancel
Save