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 libuv to ab8c3b85c1
  • Loading branch information
Igor Zinkovsky committed Mar 30, 2012
1 parent 1752443 commit 6aa7f6f
Show file tree
Hide file tree
Showing 44 changed files with 902 additions and 442 deletions.
6 changes: 4 additions & 2 deletions deps/uv/config-unix.mk
Expand Up @@ -152,14 +152,16 @@ src/unix/uv-eio.o: src/unix/uv-eio.c

clean-platform:
-rm -f src/ares/*.o
-rm -f src/unix/*.o
-rm -f src/unix/ev/*.o
-rm -f src/unix/eio/*.o
-rm -f src/unix/*.o
-rm -f src/unix/linux/*.o
-rm -rf test/run-tests.dSYM run-benchmarks.dSYM

distclean-platform:
-rm -f src/ares/*.o
-rm -f src/unix/ev/*.o
-rm -f src/unix/*.o
-rm -f src/unix/ev/*.o
-rm -f src/unix/eio/*.o
-rm -f src/unix/linux/*.o
-rm -rf test/run-tests.dSYM run-benchmarks.dSYM
6 changes: 3 additions & 3 deletions deps/uv/include/uv-private/ngx-queue.h
Expand Up @@ -4,8 +4,8 @@
*/


#ifndef _NGX_QUEUE_H_INCLUDED_
#define _NGX_QUEUE_H_INCLUDED_
#ifndef NGX_QUEUE_H_INCLUDED_
#define NGX_QUEUE_H_INCLUDED_


typedef struct ngx_queue_s ngx_queue_t;
Expand Down Expand Up @@ -103,4 +103,4 @@ struct ngx_queue_s {
for ((q) = ngx_queue_head(h); (q) != (h); (q) = ngx_queue_next(q))


#endif /* _NGX_QUEUE_H_INCLUDED_ */
#endif /* NGX_QUEUE_H_INCLUDED_ */
12 changes: 8 additions & 4 deletions deps/uv/include/uv-private/tree.h
Expand Up @@ -23,10 +23,14 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _UV_TREE_H_
#define _UV_TREE_H_
#ifndef UV_TREE_H_
#define UV_TREE_H_

#define __unused
#if __GNUC__
# define __unused __attribute__((unused))
#else
# define __unused
#endif

/*
* This file defines data structures for different types of trees:
Expand Down Expand Up @@ -759,4 +763,4 @@ name##_RB_MINMAX(struct name *head, int val) \
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
(x) = (y))

#endif /* _UV_TREE_H_ */
#endif /* UV_TREE_H_ */
4 changes: 4 additions & 0 deletions deps/uv/include/uv-private/uv-unix.h
Expand Up @@ -78,6 +78,10 @@ typedef void* uv_lib_t;
/* Poll result queue */ \
eio_channel uv_eio_channel; \
struct ev_loop* ev; \
/* Various thing for libeio. */ \
uv_async_t uv_eio_want_poll_notifier; \
uv_async_t uv_eio_done_poll_notifier; \
uv_idle_t uv_eio_poller; \
UV_LOOP_PRIVATE_PLATFORM_FIELDS

#define UV_REQ_BUFSML_SIZE (4)
Expand Down
5 changes: 4 additions & 1 deletion deps/uv/include/uv-private/uv-win.h
Expand Up @@ -318,7 +318,10 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
uv_write_t ipc_header_write_req; \
int ipc_pid; \
uint64_t remaining_ipc_rawdata_bytes; \
WSAPROTOCOL_INFOW* pending_socket_info; \
struct { \
WSAPROTOCOL_INFOW* socket_info; \
int tcp_connection; \
} pending_ipc_info; \
uv_write_t* non_overlapped_writes_tail;

#define UV_PIPE_PRIVATE_FIELDS \
Expand Down
23 changes: 13 additions & 10 deletions deps/uv/include/uv.h
Expand Up @@ -121,7 +121,8 @@ typedef intptr_t ssize_t;
XX( 50, EPERM, "operation not permitted") \
XX( 51, ELOOP, "too many symbolic links encountered") \
XX( 52, EXDEV, "cross-device link not permitted") \
XX( 53, ENOTEMPTY, "directory not empty")
XX( 53, ENOTEMPTY, "directory not empty") \
XX( 54, ENOSPC, "no space left on device")


#define UV_ERRNO_GEN(val, name, s) UV_##name = val,
Expand Down Expand Up @@ -494,6 +495,13 @@ UV_EXTERN int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb,
UV_EXTERN int uv_write(uv_write_t* req, uv_stream_t* handle,
uv_buf_t bufs[], int bufcnt, uv_write_cb cb);

/*
* Extended write function for sending handles over a pipe. The pipe must be
* initialized with ipc == 1.
* send_handle must be a TCP socket or pipe, which is a server or a connection
* (listening or connected state). Bound sockets or pipes will be assumed to
* be servers.
*/
UV_EXTERN int uv_write2(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[],
int bufcnt, uv_stream_t* send_handle, uv_write_cb cb);

Expand All @@ -509,10 +517,9 @@ struct uv_write_s {

/*
* Used to determine whether a stream is readable or writable.
* TODO: export in v0.8.
*/
/* UV_EXTERN */ int uv_is_readable(uv_stream_t* handle);
/* UV_EXTERN */ int uv_is_writable(uv_stream_t* handle);
UV_EXTERN int uv_is_readable(uv_stream_t* handle);
UV_EXTERN int uv_is_writable(uv_stream_t* handle);


/*
Expand Down Expand Up @@ -1482,12 +1489,8 @@ struct uv_counters_s {

struct uv_loop_s {
UV_LOOP_PRIVATE_FIELDS
/* list used for ares task handles */
uv_ares_task_t* uv_ares_handles_;
/* Various thing for libeio. */
uv_async_t uv_eio_want_poll_notifier;
uv_async_t uv_eio_done_poll_notifier;
uv_idle_t uv_eio_poller;
/* RB_HEAD(uv__ares_tasks, uv_ares_task_t) */
struct uv__ares_tasks { uv_ares_task_t* rbh_root; } uv_ares_handles_;
/* Diagnostic counters */
uv_counters_t counters;
/* The last error */
Expand Down
5 changes: 3 additions & 2 deletions deps/uv/src/unix/cares.c
Expand Up @@ -62,14 +62,15 @@ static void uv__ares_io(struct ev_loop* ev, struct ev_io* watcher,


/* Allocates and returns a new uv_ares_task_t */
static uv_ares_task_t* uv__ares_task_create(int fd) {
static uv_ares_task_t* uv__ares_task_create(uv_loop_t* loop, int fd) {
uv_ares_task_t* h = malloc(sizeof(uv_ares_task_t));

if (h == NULL) {
uv_fatal_error(ENOMEM, "malloc");
return NULL;
}

h->loop = loop;
h->sock = fd;

ev_io_init(&h->read_watcher, uv__ares_io, fd, EV_READ);
Expand Down Expand Up @@ -102,7 +103,7 @@ static void uv__ares_sockstate_cb(void* data, ares_socket_t sock,
ev_timer_again(loop->ev, &loop->timer);
}

h = uv__ares_task_create(sock);
h = uv__ares_task_create(loop, sock);
uv_add_ares_handle(loop, h);
}

Expand Down
11 changes: 6 additions & 5 deletions deps/uv/src/unix/core.c
Expand Up @@ -82,11 +82,11 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
uv_read_stop(stream);
ev_io_stop(stream->loop->ev, &stream->write_watcher);

uv__close(stream->fd);
close(stream->fd);
stream->fd = -1;

if (stream->accepted_fd >= 0) {
uv__close(stream->accepted_fd);
close(stream->accepted_fd);
stream->accepted_fd = -1;
}

Expand Down Expand Up @@ -145,6 +145,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
static int uv__loop_init(uv_loop_t* loop,
struct ev_loop *(ev_loop_new)(unsigned int flags)) {
memset(loop, 0, sizeof(*loop));
RB_INIT(&loop->uv_ares_handles_);
#if HAVE_KQUEUE
loop->ev = ev_loop_new(EVBACKEND_KQUEUE);
#else
Expand Down Expand Up @@ -751,7 +752,7 @@ int uv__socket(int domain, int type, int protocol) {
goto out;

if (uv__nonblock(sockfd, 1) || uv__cloexec(sockfd, 1)) {
uv__close(sockfd);
close(sockfd);
sockfd = -1;
}

Expand Down Expand Up @@ -787,7 +788,7 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
}

if (uv__cloexec(peerfd, 1) || uv__nonblock(peerfd, 1)) {
uv__close(peerfd);
close(peerfd);
peerfd = -1;
}

Expand Down Expand Up @@ -861,7 +862,7 @@ int uv__dup(int fd) {
return -1;

if (uv__cloexec(fd, 1)) {
SAVE_ERRNO(uv__close(fd));
SAVE_ERRNO(close(fd));
return -1;
}

Expand Down
2 changes: 2 additions & 0 deletions deps/uv/src/unix/error.c
Expand Up @@ -74,6 +74,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EMSGSIZE: return UV_EMSGSIZE;
case ENAMETOOLONG: return UV_ENAMETOOLONG;
case EINVAL: return UV_EINVAL;
case ENETUNREACH: return UV_ENETUNREACH;
case ECONNABORTED: return UV_ECONNABORTED;
case ELOOP: return UV_ELOOP;
case ECONNREFUSED: return UV_ECONNREFUSED;
Expand All @@ -90,6 +91,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EXDEV: return UV_EXDEV;
case EBUSY: return UV_EBUSY;
case ENOTEMPTY: return UV_ENOTEMPTY;
case ENOSPC: return UV_ENOSPC;
default: return UV_UNKNOWN;
}
UNREACHABLE();
Expand Down
7 changes: 0 additions & 7 deletions deps/uv/src/unix/internal.h
Expand Up @@ -172,13 +172,6 @@ int uv__cloexec(int fd, int set) __attribute__((unused));
int uv__socket(int domain, int type, int protocol);
int uv__dup(int fd);

/* We used to handle EINTR in uv__close() but linux 2.6 will have closed the
* file descriptor anyway, even on EINTR. Retrying in that case isn't merely
* useless, it's actively harmful - the file descriptor may have been acquired
* by another thread.
*/
#define uv__close(fd) close(fd)

/* error */
uv_err_code uv_translate_sys_error(int sys_errno);
void uv_fatal_error(const int errorno, const char* syscall);
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/src/unix/kqueue.c
Expand Up @@ -124,7 +124,7 @@ int uv_fs_event_init(uv_loop_t* loop,
void uv__fs_event_destroy(uv_fs_event_t* handle) {
uv__fs_event_stop(handle);
free(handle->filename);
uv__close(handle->fd);
close(handle->fd);
handle->fd = -1;
}

Expand Down
38 changes: 26 additions & 12 deletions deps/uv/src/unix/linux/core.c
Expand Up @@ -48,6 +48,14 @@
#undef NANOSEC
#define NANOSEC 1000000000

/* This is rather annoying: CLOCK_BOOTTIME lives in <linux/time.h> but we can't
* include that file because it conflicts with <time.h>. We'll just have to
* define it ourselves.
*/
#ifndef CLOCK_BOOTTIME
# define CLOCK_BOOTTIME 7
#endif

static char buf[MAXPATHLEN + 1];

static struct {
Expand Down Expand Up @@ -267,22 +275,28 @@ uv_err_t uv_resident_set_memory(size_t* rss) {


uv_err_t uv_uptime(double* uptime) {
#ifdef CLOCK_MONOTONIC
static volatile int no_clock_boottime;
struct timespec now;
if (0 == clock_gettime(CLOCK_MONOTONIC, &now)) {
*uptime = now.tv_sec;
*uptime += (double)now.tv_nsec / 1000000000.0;
return uv_ok_;
int r;

/* Try CLOCK_BOOTTIME first, fall back to CLOCK_MONOTONIC if not available
* (pre-2.6.39 kernels). CLOCK_MONOTONIC doesn't increase when the system
* is suspended.
*/
if (no_clock_boottime) {
retry: r = clock_gettime(CLOCK_MONOTONIC, &now);
}
return uv__new_sys_error(errno);
#else
struct sysinfo info;
if (sysinfo(&info) < 0) {
return uv__new_sys_error(errno);
else if ((r = clock_gettime(CLOCK_BOOTTIME, &now)) && errno == EINVAL) {
no_clock_boottime = 1;
goto retry;
}
*uptime = (double)info.uptime;

if (r)
return uv__new_sys_error(errno);

*uptime = now.tv_sec;
*uptime += (double)now.tv_nsec / 1000000000.0;
return uv_ok_;
#endif
}


Expand Down
5 changes: 2 additions & 3 deletions deps/uv/src/unix/linux/inotify.c
Expand Up @@ -132,8 +132,7 @@ static int compare_watchers(const uv_fs_event_t* a, const uv_fs_event_t* b) {
}


RB_GENERATE_INTERNAL(uv__inotify_watchers, uv_fs_event_s, node, compare_watchers,
inline static __attribute__((unused)))
RB_GENERATE_STATIC(uv__inotify_watchers, uv_fs_event_s, node, compare_watchers)


void uv__inotify_loop_init(uv_loop_t* loop) {
Expand Down Expand Up @@ -170,7 +169,7 @@ static int new_inotify_fd(void) {
return -1;

if (uv__cloexec(fd, 1) || uv__nonblock(fd, 1)) {
SAVE_ERRNO(uv__close(fd));
SAVE_ERRNO(close(fd));
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion deps/uv/src/unix/openbsd.c
Expand Up @@ -216,6 +216,7 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
int numcpus = 1;
static int which[] = {CTL_HW,HW_MODEL,0};
size_t size;
int i;
uv_cpu_info_t* cpu_info;

size = sizeof(model);
Expand Down Expand Up @@ -245,7 +246,7 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = sizeof(info);
which[0] = CTL_KERN;
which[1] = KERN_CPTIME2;
for (int i = 0; i < numcpus; i++) {
for (i = 0; i < numcpus; i++) {
which[2] = i;
size = sizeof(info);
if (sysctl(which, 3, &info, &size, NULL, 0) < 0) {
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/src/unix/pipe.c
Expand Up @@ -109,7 +109,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
assert(pipe_fname != NULL);
unlink(pipe_fname);
}
uv__close(sockfd);
close(sockfd);

free((void*)pipe_fname);
}
Expand Down Expand Up @@ -210,7 +210,7 @@ void uv_pipe_connect(uv_connect_t* req,

if (r == -1) {
status = errno;
uv__close(sockfd);
close(sockfd);
goto out;
}

Expand Down

0 comments on commit 6aa7f6f

Please sign in to comment.