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

Commit

Permalink
Browse files Browse the repository at this point in the history
Upgrade uv to 604802a
  • Loading branch information
isaacs committed May 24, 2012
1 parent b4ed3c1 commit 24de89b
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 160 deletions.
1 change: 1 addition & 0 deletions deps/uv/config-unix.mk
Expand Up @@ -33,6 +33,7 @@ OBJS += src/unix/dl.o
OBJS += src/unix/error.o
OBJS += src/unix/fs.o
OBJS += src/unix/loop.o
OBJS += src/unix/loop-watcher.o
OBJS += src/unix/pipe.o
OBJS += src/unix/poll.o
OBJS += src/unix/process.o
Expand Down
19 changes: 11 additions & 8 deletions deps/uv/include/uv-private/uv-unix.h
Expand Up @@ -131,10 +131,9 @@ struct uv__io_s {

#define UV_UDP_SEND_PRIVATE_FIELDS \
ngx_queue_t queue; \
struct sockaddr_storage addr; \
socklen_t addrlen; \
uv_buf_t* bufs; \
struct sockaddr_in6 addr; \
int bufcnt; \
uv_buf_t* bufs; \
ssize_t status; \
uv_udp_send_cb send_cb; \
uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \
Expand All @@ -144,7 +143,6 @@ struct uv__io_s {

/* TODO: union or classes please! */
#define UV_HANDLE_PRIVATE_FIELDS \
int fd; \
int flags; \
uv_handle_t* next_pending; \

Expand All @@ -156,10 +154,10 @@ struct uv__io_s {
uv__io_t write_watcher; \
ngx_queue_t write_queue; \
ngx_queue_t write_completed_queue; \
int delayed_error; \
uv_connection_cb connection_cb; \
int delayed_error; \
int accepted_fd; \
int blocking;
int fd; \


/* UV_TCP */
Expand All @@ -168,6 +166,7 @@ struct uv__io_s {

/* UV_UDP */
#define UV_UDP_PRIVATE_FIELDS \
int fd; \
uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \
uv__io_t read_watcher; \
Expand All @@ -183,6 +182,7 @@ struct uv__io_s {

/* UV_POLL */
#define UV_POLL_PRIVATE_FIELDS \
int fd; \
uv__io_t io_watcher;


Expand Down Expand Up @@ -248,7 +248,8 @@ struct uv__io_s {
struct uv_fs_event_s* rbe_parent; \
int rbe_color; \
} node; \
uv_fs_event_cb cb;
uv_fs_event_cb cb; \
int fd; \

#elif defined(__APPLE__) \
|| defined(__FreeBSD__) \
Expand All @@ -260,14 +261,16 @@ struct uv__io_s {
ev_io event_watcher; \
uv_fs_event_cb cb; \
int fflags; \
int fd;

#elif defined(__sun)

#ifdef PORT_SOURCE_FILE
# define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io event_watcher; \
uv_fs_event_cb cb; \
file_obj_t fo;
file_obj_t fo; \
int fd;
#else /* !PORT_SOURCE_FILE */
# define UV_FS_EVENT_PRIVATE_FIELDS
#endif
Expand Down
40 changes: 22 additions & 18 deletions deps/uv/include/uv.h
Expand Up @@ -230,14 +230,17 @@ UV_EXTERN uv_loop_t* uv_default_loop(void);

/*
* This function starts the event loop. It blocks until the reference count
* of the loop drops to zero.
* of the loop drops to zero. Always returns zero.
*/
UV_EXTERN int uv_run (uv_loop_t*);
UV_EXTERN int uv_run(uv_loop_t*);

/*
* This function polls for new events without blocking.
* Poll for new events once. Note that this function blocks if there are no
* pending events. Returns zero when done (no active handles or requests left),
* or non-zero if more events are expected (meaning you should call
* uv_run_once() again sometime in the future).
*/
UV_EXTERN int uv_run_once (uv_loop_t*);
UV_EXTERN int uv_run_once(uv_loop_t*);

/*
* Manually modify the event loop's reference count. Useful if the user wants
Expand Down Expand Up @@ -338,13 +341,13 @@ UV_EXTERN const char* uv_err_name(uv_err_t err);
#endif

#define UV_REQ_FIELDS \
/* read-only */ \
uv_req_type type; \
/* public */ \
void* data; \
UV_REQ_EXTRA_FIELDS \
/* private */ \
UV_REQ_PRIVATE_FIELDS
UV_REQ_PRIVATE_FIELDS \
/* read-only */ \
uv_req_type type; \

/* Abstract base class of all requests. */
struct uv_req_s {
Expand Down Expand Up @@ -381,16 +384,17 @@ struct uv_shutdown_s {
# define UV_HANDLE_EXTRA_FIELDS
#endif

#define UV_HANDLE_FIELDS \
/* read-only */ \
uv_loop_t* loop; \
uv_handle_type type; \
/* public */ \
uv_close_cb close_cb; \
void* data; \
UV_HANDLE_EXTRA_FIELDS \
/* private */ \
UV_HANDLE_PRIVATE_FIELDS
#define UV_HANDLE_FIELDS \
/* read-only */ \
uv_loop_t* loop; \
/* public */ \
uv_close_cb close_cb; \
void* data; \
/* read-only */ \
uv_handle_type type; \
/* private */ \
UV_HANDLE_PRIVATE_FIELDS \
UV_HANDLE_EXTRA_FIELDS \

/* The abstract base class of all handles. */
struct uv_handle_s {
Expand Down Expand Up @@ -1362,8 +1366,8 @@ typedef enum {
/* uv_fs_t is a subclass of uv_req_t */
struct uv_fs_s {
UV_REQ_FIELDS
uv_loop_t* loop;
uv_fs_type fs_type;
uv_loop_t* loop;
uv_fs_cb cb;
ssize_t result;
void* ptr;
Expand Down
20 changes: 13 additions & 7 deletions deps/uv/src/unix/core.c
Expand Up @@ -235,8 +235,7 @@ int uv_run(uv_loop_t* loop) {


int uv_run_once(uv_loop_t* loop) {
uv__run(loop);
return 0;
return uv__run(loop);
}


Expand Down Expand Up @@ -269,8 +268,8 @@ void uv__finish_close(uv_handle_t* handle) {
case UV_NAMED_PIPE:
case UV_TCP:
case UV_TTY:
assert(!ev_is_active(&((uv_stream_t*)handle)->read_watcher));
assert(!ev_is_active(&((uv_stream_t*)handle)->write_watcher));
assert(!uv__io_active(&((uv_stream_t*)handle)->read_watcher));
assert(!uv__io_active(&((uv_stream_t*)handle)->write_watcher));
assert(((uv_stream_t*)handle)->fd == -1);
uv__stream_destroy((uv_stream_t*)handle);
break;
Expand Down Expand Up @@ -318,6 +317,7 @@ static int uv_getaddrinfo_done(eio_req* req_) {
uv_getaddrinfo_t* req = req_->data;
struct addrinfo *res = req->res;
#if __sun
uv_getaddrinfo_t* handle = req->data;
size_t hostlen = strlen(handle->hostname);
#endif

Expand Down Expand Up @@ -446,14 +446,18 @@ int uv__socket(int domain, int type, int protocol) {
}


int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
int uv__accept(int sockfd) {
int peerfd;

assert(sockfd >= 0);

while (1) {
#if __linux__
peerfd = uv__accept4(sockfd, saddr, &slen, UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC);
peerfd = uv__accept4(sockfd,
NULL,
NULL,
UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC);

if (peerfd != -1)
break;

Expand All @@ -464,7 +468,9 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
break;
#endif

if ((peerfd = accept(sockfd, saddr, &slen)) == -1) {
peerfd = accept(sockfd, NULL, NULL);

if (peerfd == -1) {
if (errno == EINTR)
continue;
else
Expand Down
15 changes: 8 additions & 7 deletions deps/uv/src/unix/internal.h
Expand Up @@ -84,17 +84,18 @@

/* flags */
enum {
UV_CLOSING = 0x01, /* uv_close() called but not finished. */
UV_CLOSED = 0x02, /* close(2) finished. */
UV_CLOSING = 0x01, /* uv_close() called but not finished. */
UV_CLOSED = 0x02, /* close(2) finished. */
UV_STREAM_READING = 0x04, /* uv_read_start() called. */
UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */
UV_STREAM_SHUT = 0x10, /* Write side closed. */
UV_STREAM_READABLE = 0x20, /* The stream is readable */
UV_STREAM_WRITABLE = 0x40, /* The stream is writable */
UV_TCP_NODELAY = 0x080, /* Disable Nagle. */
UV_TCP_KEEPALIVE = 0x100, /* Turn on keep-alive. */
UV_TIMER_REPEAT = 0x100,
UV__PENDING = 0x800
UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */
UV_TCP_NODELAY = 0x100, /* Disable Nagle. */
UV_TCP_KEEPALIVE = 0x200, /* Turn on keep-alive. */
UV_TIMER_REPEAT = 0x100,
UV__PENDING = 0x800
};

inline static int uv__has_pending_handles(const uv_loop_t* loop) {
Expand Down Expand Up @@ -155,7 +156,7 @@ void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream,
int uv__stream_open(uv_stream_t*, int fd, int flags);
void uv__stream_destroy(uv_stream_t* stream);
void uv__server_io(uv_loop_t* loop, uv__io_t* watcher, int events);
int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t len);
int uv__accept(int sockfd);
int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
socklen_t addrlen, uv_connect_cb cb);

Expand Down
37 changes: 0 additions & 37 deletions deps/uv/src/unix/loop.c
Expand Up @@ -77,40 +77,3 @@ void uv__loop_delete(uv_loop_t* loop) {
close(loop->fs_fd);
#endif
}


#define X(name, type) \
int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
uv__handle_init(loop, (uv_handle_t*)handle, type); \
loop->counters.name##_init++; \
handle->name##_cb = NULL; \
return 0; \
} \
int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \
if (uv__is_active(handle)) return 0; \
ngx_queue_insert_head(&handle->loop->name##_handles, &handle->queue); \
handle->name##_cb = cb; \
uv__handle_start(handle); \
return 0; \
} \
int uv_##name##_stop(uv_##name##_t* handle) { \
if (!uv__is_active(handle)) return 0; \
ngx_queue_remove(&handle->queue); \
uv__handle_stop(handle); \
return 0; \
} \
void uv__run_##name(uv_loop_t* loop) { \
uv_##name##_t* h; \
ngx_queue_t* q; \
ngx_queue_foreach(q, &loop->name##_handles) { \
h = ngx_queue_data(q, uv_##name##_t, queue); \
if (h->name##_cb) h->name##_cb(h, 0); \
} \
} \
void uv__##name##_close(uv_##name##_t* handle) { \
uv_##name##_stop(handle); \
}
X(idle, UV_IDLE)
X(check, UV_CHECK)
X(prepare, UV_PREPARE)
#undef X
23 changes: 5 additions & 18 deletions deps/uv/src/unix/pipe.c
Expand Up @@ -81,22 +81,10 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
uv_strlcpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;

if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr) == -1) {
/* On EADDRINUSE:
*
* We hold the file lock so there is no other process listening
* on the socket. Ergo, it's stale - remove it.
*
* This assumes that the other process uses locking too
* but that's a good enough assumption for now.
*/
if (errno != EADDRINUSE
|| unlink(pipe_fname) == -1
|| bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr) == -1) {
/* Convert ENOENT to EACCES for compatibility with Windows. */
uv__set_sys_error(handle->loop, (errno == ENOENT) ? EACCES : errno);
goto out;
}
if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) {
/* Convert ENOENT to EACCES for compatibility with Windows. */
uv__set_sys_error(handle->loop, (errno == ENOENT) ? EACCES : errno);
goto out;
}
bound = 1;

Expand Down Expand Up @@ -241,7 +229,6 @@ void uv_pipe_connect(uv_connect_t* req,

/* TODO merge with uv__server_io()? */
static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events) {
struct sockaddr_un saddr;
uv_pipe_t* pipe;
int saved_errno;
int sockfd;
Expand All @@ -251,7 +238,7 @@ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events) {

assert(pipe->type == UV_NAMED_PIPE);

sockfd = uv__accept(pipe->fd, (struct sockaddr *)&saddr, sizeof saddr);
sockfd = uv__accept(pipe->fd);
if (sockfd == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
uv__set_sys_error(pipe->loop, errno);
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/poll.c
Expand Up @@ -100,6 +100,7 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {
if (pevents & UV_WRITABLE)
events |= UV__IO_WRITE;

uv__io_stop(handle->loop, &handle->io_watcher);
uv__io_set(&handle->io_watcher, uv__poll_io, handle->fd, events);
uv__io_start(handle->loop, &handle->io_watcher);

Expand Down

2 comments on commit 24de89b

@shigeki
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isaacs build was failed because of missing loop-watcher.c

  CC(target) /home/ohtsu/tmp/github/node/out/Release/obj.target/uv/deps/uv/src/unix/fs.o
  CC(target) /home/ohtsu/tmp/github/node/out/Release/obj.target/uv/deps/uv/src/unix/loop.o
make[1]: *** No rule to make target `/home/ohtsu/tmp/github/node/out/Release/obj.target/uv/deps/uv/src/unix/loop-watcher.o', needed by `/home/ohtsu/tmp/github/node/out/Release/obj.target/deps/uv/libuv.a'.  Stop.
make[1]: Leaving directory `/home/ohtsu/tmp/github/node/out'

@bnoordhuis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Shigeki, fixed in 578f69b.

Please sign in to comment.