LIBS: updated libuv
parent
e10a72f8e6
commit
4b255acdd9
2
Makefile
2
Makefile
|
@ -37,11 +37,13 @@ update-restclient-cpp:
|
|||
|
||||
update-libuv:
|
||||
$(call UPDATE_GIT,libuv,https://github.com/libuv/libuv.git)
|
||||
rm -rf contrib/libs/libuv/include/uv/*.[ch]
|
||||
rm -rf contrib/libs/libuv/include/*.[ch]
|
||||
rm -rf contrib/libs/libuv/src/unix/*.[ch]
|
||||
rm -rf contrib/libs/libuv/src/win32/*.[ch]
|
||||
rm -rf contrib/libs/libuv/src/*.[ch]
|
||||
cp $(UPDATEDIR)/libuv.sync/include/*.h contrib/libs/libuv/include
|
||||
cp $(UPDATEDIR)/libuv.sync/include/uv/*.h contrib/libs/libuv/include/uv
|
||||
cp $(UPDATEDIR)/libuv.sync/src/unix/*.[ch] contrib/libs/libuv/src/unix
|
||||
cp $(UPDATEDIR)/libuv.sync/src/win/*.[ch] contrib/libs/libuv/src/win
|
||||
cp $(UPDATEDIR)/libuv.sync/src/*.[ch] contrib/libs/libuv/src
|
||||
|
|
|
@ -3,14 +3,15 @@ set(LIB libuv)
|
|||
include_directories(include src)
|
||||
set(SOURCES
|
||||
include/uv.h
|
||||
include/tree.h
|
||||
include/uv-errno.h
|
||||
include/uv-threadpool.h
|
||||
include/uv-version.h
|
||||
include/uv/tree.h
|
||||
include/uv/errno.h
|
||||
include/uv/threadpool.h
|
||||
include/uv/version.h
|
||||
src/fs-poll.c
|
||||
src/heap-inl.h
|
||||
src/inet.c
|
||||
src/queue.h
|
||||
src/timer.c
|
||||
src/threadpool.c
|
||||
src/uv-common.c
|
||||
src/uv-common.h
|
||||
|
@ -21,7 +22,7 @@ set(SOURCES
|
|||
if(WIN32)
|
||||
add_definitions(-D_WIN32_WINNT=0x0600 -D_GNU_SOURCE -D_CRT_SECURE_NO_WARNINGS)
|
||||
set (SOURCES ${SOURCES}
|
||||
include/uv-win.h
|
||||
include/uv/win.h
|
||||
src/win/async.c
|
||||
src/win/atomicops-inl.h
|
||||
src/win/core.c
|
||||
|
@ -66,12 +67,12 @@ else()
|
|||
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
|
||||
include_directories(src/unix)
|
||||
set(SOURCES ${SOURCES}
|
||||
include/uv-unix.h
|
||||
include/uv-linux.h
|
||||
include/uv-sunos.h
|
||||
include/uv-darwin.h
|
||||
include/uv-bsd.h
|
||||
include/uv-aix.h
|
||||
include/uv/unix.h
|
||||
include/uv/linux.h
|
||||
include/uv/sunos.h
|
||||
include/uv/darwin.h
|
||||
include/uv/bsd.h
|
||||
include/uv/aix.h
|
||||
src/unix/async.c
|
||||
src/unix/atomic-ops.h
|
||||
src/unix/core.c
|
||||
|
@ -90,7 +91,6 @@ else()
|
|||
src/unix/stream.c
|
||||
src/unix/tcp.c
|
||||
src/unix/thread.c
|
||||
src/unix/timer.c
|
||||
src/unix/tty.c
|
||||
src/unix/udp.c
|
||||
)
|
||||
|
@ -166,7 +166,7 @@ else()
|
|||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||
set (SOURCES ${SOURCES}
|
||||
include/android-ifaddrs.h
|
||||
include/uv/android-ifaddrs.h
|
||||
src/unix/android-ifaddrs.c
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -45,21 +45,21 @@ extern "C" {
|
|||
# define UV_EXTERN /* nothing */
|
||||
#endif
|
||||
|
||||
#include "uv-errno.h"
|
||||
#include "uv-version.h"
|
||||
#include "uv/errno.h"
|
||||
#include "uv/version.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
# include "stdint-msvc2008.h"
|
||||
# include "uv/stdint-msvc2008.h"
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include "uv-win.h"
|
||||
# include "uv/win.h"
|
||||
#else
|
||||
# include "uv-unix.h"
|
||||
# include "uv/unix.h"
|
||||
#endif
|
||||
|
||||
/* Expand this list if necessary. */
|
||||
|
@ -1004,16 +1004,18 @@ UV_EXTERN int uv_queue_work(uv_loop_t* loop,
|
|||
UV_EXTERN int uv_cancel(uv_req_t* req);
|
||||
|
||||
|
||||
struct uv_cpu_times_s {
|
||||
uint64_t user;
|
||||
uint64_t nice;
|
||||
uint64_t sys;
|
||||
uint64_t idle;
|
||||
uint64_t irq;
|
||||
};
|
||||
|
||||
struct uv_cpu_info_s {
|
||||
char* model;
|
||||
int speed;
|
||||
struct uv_cpu_times_s {
|
||||
uint64_t user;
|
||||
uint64_t nice;
|
||||
uint64_t sys;
|
||||
uint64_t idle;
|
||||
uint64_t irq;
|
||||
} cpu_times;
|
||||
struct uv_cpu_times_s cpu_times;
|
||||
};
|
||||
|
||||
struct uv_interface_address_s {
|
||||
|
@ -1139,6 +1141,7 @@ typedef enum {
|
|||
UV_FS_READLINK,
|
||||
UV_FS_CHOWN,
|
||||
UV_FS_FCHOWN,
|
||||
UV_FS_LCHOWN,
|
||||
UV_FS_REALPATH,
|
||||
UV_FS_COPYFILE
|
||||
} uv_fs_type;
|
||||
|
@ -1343,6 +1346,12 @@ UV_EXTERN int uv_fs_fchown(uv_loop_t* loop,
|
|||
uv_uid_t uid,
|
||||
uv_gid_t gid,
|
||||
uv_fs_cb cb);
|
||||
UV_EXTERN int uv_fs_lchown(uv_loop_t* loop,
|
||||
uv_fs_t* req,
|
||||
const char* path,
|
||||
uv_uid_t uid,
|
||||
uv_gid_t gid,
|
||||
uv_fs_cb cb);
|
||||
|
||||
|
||||
enum uv_fs_event {
|
||||
|
|
|
@ -42,32 +42,32 @@
|
|||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "uv-threadpool.h"
|
||||
#include "uv/threadpool.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
# include "uv-linux.h"
|
||||
# include "uv/linux.h"
|
||||
#elif defined (__MVS__)
|
||||
# include "uv-os390.h"
|
||||
# include "uv/os390.h"
|
||||
#elif defined(__PASE__)
|
||||
# include "uv-posix.h"
|
||||
# include "uv/posix.h"
|
||||
#elif defined(_AIX)
|
||||
# include "uv-aix.h"
|
||||
# include "uv/aix.h"
|
||||
#elif defined(__sun)
|
||||
# include "uv-sunos.h"
|
||||
# include "uv/sunos.h"
|
||||
#elif defined(__APPLE__)
|
||||
# include "uv-darwin.h"
|
||||
# include "uv/darwin.h"
|
||||
#elif defined(__DragonFly__) || \
|
||||
defined(__FreeBSD__) || \
|
||||
defined(__FreeBSD_kernel__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__)
|
||||
# include "uv-bsd.h"
|
||||
# include "uv/bsd.h"
|
||||
#elif defined(__CYGWIN__) || defined(__MSYS__)
|
||||
# include "uv-posix.h"
|
||||
# include "uv/posix.h"
|
||||
#endif
|
||||
|
||||
#ifndef PTHREAD_BARRIER_SERIAL_THREAD
|
||||
# include "pthread-barrier.h"
|
||||
# include "uv/pthread-barrier.h"
|
||||
#endif
|
||||
|
||||
#ifndef NI_MAXHOST
|
|
@ -31,8 +31,8 @@
|
|||
*/
|
||||
|
||||
#define UV_VERSION_MAJOR 1
|
||||
#define UV_VERSION_MINOR 20
|
||||
#define UV_VERSION_PATCH 4
|
||||
#define UV_VERSION_MINOR 21
|
||||
#define UV_VERSION_PATCH 1
|
||||
#define UV_VERSION_IS_RELEASE 0
|
||||
#define UV_VERSION_SUFFIX "dev"
|
||||
|
|
@ -53,13 +53,13 @@ typedef struct pollfd {
|
|||
#include <sys/stat.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
# include "stdint-msvc2008.h"
|
||||
# include "uv/stdint-msvc2008.h"
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "tree.h"
|
||||
#include "uv-threadpool.h"
|
||||
#include "uv/tree.h"
|
||||
#include "uv/threadpool.h"
|
||||
|
||||
#define MAX_PIPENAME_LEN 256
|
||||
|
||||
|
@ -308,8 +308,6 @@ typedef struct {
|
|||
char* errmsg;
|
||||
} uv_lib_t;
|
||||
|
||||
RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
||||
|
||||
#define UV_LOOP_PRIVATE_FIELDS \
|
||||
/* The loop's I/O completion port */ \
|
||||
HANDLE iocp; \
|
||||
|
@ -321,8 +319,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|||
uv_req_t* pending_reqs_tail; \
|
||||
/* Head of a single-linked list of closed handles */ \
|
||||
uv_handle_t* endgame_handles; \
|
||||
/* The head of the timers tree */ \
|
||||
struct uv_timer_tree_s timers; \
|
||||
/* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \
|
||||
void* timer_heap; \
|
||||
/* Lists of active loop (prepare / check / idle) watchers */ \
|
||||
uv_prepare_t* prepare_handles; \
|
||||
uv_check_t* check_handles; \
|
||||
|
@ -529,8 +527,9 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|||
unsigned char events;
|
||||
|
||||
#define UV_TIMER_PRIVATE_FIELDS \
|
||||
RB_ENTRY(uv_timer_s) tree_entry; \
|
||||
uint64_t due; \
|
||||
void* heap_node[3]; \
|
||||
int unused; \
|
||||
uint64_t timeout; \
|
||||
uint64_t repeat; \
|
||||
uint64_t start_id; \
|
||||
uv_timer_cb timer_cb;
|
|
@ -19,7 +19,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
# include "stdint-msvc2008.h"
|
||||
# include "uv/stdint-msvc2008.h"
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
|
|
@ -19,13 +19,22 @@
|
|||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
#include "uv-common.h"
|
||||
#include "heap-inl.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
static struct heap *timer_heap(const uv_loop_t* loop) {
|
||||
#ifdef _WIN32
|
||||
return (struct heap*) loop->timer_heap;
|
||||
#else
|
||||
return (struct heap*) &loop->timer_heap;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static int timer_less_than(const struct heap_node* ha,
|
||||
const struct heap_node* hb) {
|
||||
const uv_timer_t* a;
|
||||
|
@ -81,7 +90,7 @@ int uv_timer_start(uv_timer_t* handle,
|
|||
/* start_id is the second index to be compared in uv__timer_cmp() */
|
||||
handle->start_id = handle->loop->timer_counter++;
|
||||
|
||||
heap_insert((struct heap*) &handle->loop->timer_heap,
|
||||
heap_insert(timer_heap(handle->loop),
|
||||
(struct heap_node*) &handle->heap_node,
|
||||
timer_less_than);
|
||||
uv__handle_start(handle);
|
||||
|
@ -94,7 +103,7 @@ int uv_timer_stop(uv_timer_t* handle) {
|
|||
if (!uv__is_active(handle))
|
||||
return 0;
|
||||
|
||||
heap_remove((struct heap*) &handle->loop->timer_heap,
|
||||
heap_remove(timer_heap(handle->loop),
|
||||
(struct heap_node*) &handle->heap_node,
|
||||
timer_less_than);
|
||||
uv__handle_stop(handle);
|
||||
|
@ -131,7 +140,7 @@ int uv__next_timeout(const uv_loop_t* loop) {
|
|||
const uv_timer_t* handle;
|
||||
uint64_t diff;
|
||||
|
||||
heap_node = heap_min((const struct heap*) &loop->timer_heap);
|
||||
heap_node = heap_min(timer_heap(loop));
|
||||
if (heap_node == NULL)
|
||||
return -1; /* block indefinitely */
|
||||
|
||||
|
@ -152,7 +161,7 @@ void uv__run_timers(uv_loop_t* loop) {
|
|||
uv_timer_t* handle;
|
||||
|
||||
for (;;) {
|
||||
heap_node = heap_min((struct heap*) &loop->timer_heap);
|
||||
heap_node = heap_min(timer_heap(loop));
|
||||
if (heap_node == NULL)
|
||||
break;
|
||||
|
|
@ -23,7 +23,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "android-ifaddrs.h"
|
||||
#include "uv/android-ifaddrs.h"
|
||||
#include "uv-common.h"
|
||||
|
||||
#include <string.h>
|
||||
|
|
|
@ -929,7 +929,11 @@ out:
|
|||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
if (result == 0)
|
||||
return 0;
|
||||
|
||||
errno = UV__ERR(result);
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1116,6 +1120,7 @@ static void uv__fs_work(struct uv__work* w) {
|
|||
X(COPYFILE, uv__fs_copyfile(req));
|
||||
X(FCHMOD, fchmod(req->file, req->mode));
|
||||
X(FCHOWN, fchown(req->file, req->uid, req->gid));
|
||||
X(LCHOWN, lchown(req->path, req->uid, req->gid));
|
||||
X(FDATASYNC, uv__fs_fdatasync(req));
|
||||
X(FSTAT, uv__fs_fstat(req->file, &req->statbuf));
|
||||
X(FSYNC, uv__fs_fsync(req));
|
||||
|
@ -1242,6 +1247,20 @@ int uv_fs_fchown(uv_loop_t* loop,
|
|||
}
|
||||
|
||||
|
||||
int uv_fs_lchown(uv_loop_t* loop,
|
||||
uv_fs_t* req,
|
||||
const char* path,
|
||||
uv_uid_t uid,
|
||||
uv_gid_t gid,
|
||||
uv_fs_cb cb) {
|
||||
INIT(LCHOWN);
|
||||
PATH;
|
||||
req->uid = uid;
|
||||
req->gid = gid;
|
||||
POST;
|
||||
}
|
||||
|
||||
|
||||
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
||||
INIT(FDATASYNC);
|
||||
req->file = file;
|
||||
|
|
|
@ -252,10 +252,6 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay);
|
|||
/* pipe */
|
||||
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
|
||||
|
||||
/* timer */
|
||||
void uv__run_timers(uv_loop_t* loop);
|
||||
int uv__next_timeout(const uv_loop_t* loop);
|
||||
|
||||
/* signal */
|
||||
void uv__signal_close(uv_signal_t* handle);
|
||||
void uv__signal_global_once_init(void);
|
||||
|
@ -280,7 +276,6 @@ void uv__prepare_close(uv_prepare_t* handle);
|
|||
void uv__process_close(uv_process_t* handle);
|
||||
void uv__stream_close(uv_stream_t* handle);
|
||||
void uv__tcp_close(uv_tcp_t* handle);
|
||||
void uv__timer_close(uv_timer_t* handle);
|
||||
void uv__udp_close(uv_udp_t* handle);
|
||||
void uv__udp_finish_close(uv_udp_t* handle);
|
||||
uv_handle_type uv__handle_type(int fd);
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
#ifdef HAVE_IFADDRS_H
|
||||
# if defined(__ANDROID__)
|
||||
# include "android-ifaddrs.h"
|
||||
# include "uv/android-ifaddrs.h"
|
||||
# else
|
||||
# include <ifaddrs.h>
|
||||
# endif
|
||||
|
@ -388,7 +388,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
|||
* free when we switch over to edge-triggered I/O.
|
||||
*/
|
||||
if (pe->events == POLLERR || pe->events == POLLHUP)
|
||||
pe->events |= w->pevents & (POLLIN | POLLOUT | UV__POLLPRI);
|
||||
pe->events |=
|
||||
w->pevents & (POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
|
||||
|
||||
if (pe->events != 0) {
|
||||
/* Run signal watchers last. This also affects child process watchers
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "tree.h"
|
||||
#include "uv/tree.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "tree.h"
|
||||
#include "uv/tree.h"
|
||||
#include "internal.h"
|
||||
#include "heap-inl.h"
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -141,7 +141,7 @@ static void init_message_queue(uv__os390_epoll* lst) {
|
|||
} msg;
|
||||
|
||||
/* initialize message queue */
|
||||
lst->msg_queue = msgget(IPC_PRIVATE, 0622 | IPC_CREAT);
|
||||
lst->msg_queue = msgget(IPC_PRIVATE, 0600 | IPC_CREAT);
|
||||
if (lst->msg_queue == -1)
|
||||
abort();
|
||||
|
||||
|
@ -255,12 +255,13 @@ int epoll_ctl(uv__os390_epoll* lst,
|
|||
lst->items[fd].events = event->events;
|
||||
lst->items[fd].revents = 0;
|
||||
} else if (op == EPOLL_CTL_MOD) {
|
||||
if (fd >= lst->size || lst->items[fd].fd == -1) {
|
||||
if (fd >= lst->size - 1 || lst->items[fd].fd == -1) {
|
||||
uv_mutex_unlock(&global_epoll_lock);
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
lst->items[fd].events = event->events;
|
||||
lst->items[fd].revents = 0;
|
||||
} else
|
||||
abort();
|
||||
|
||||
|
@ -275,8 +276,9 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events,
|
|||
struct pollfd* pfds;
|
||||
int pollret;
|
||||
int reventcount;
|
||||
int nevents;
|
||||
|
||||
size = _SET_FDS_MSGS(size, 1, lst->size - 1);
|
||||
_SET_FDS_MSGS(size, 1, lst->size - 1);
|
||||
pfds = lst->items;
|
||||
pollret = poll(pfds, size, timeout);
|
||||
if (pollret <= 0)
|
||||
|
@ -285,19 +287,28 @@ int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events,
|
|||
pollret = _NFDS(pollret) + _NMSGS(pollret);
|
||||
|
||||
reventcount = 0;
|
||||
nevents = 0;
|
||||
for (int i = 0;
|
||||
i < lst->size && i < maxevents && reventcount < pollret; ++i) {
|
||||
struct epoll_event ev;
|
||||
struct pollfd* pfd;
|
||||
|
||||
if (pfds[i].fd == -1 || pfds[i].revents == 0)
|
||||
pfd = &pfds[i];
|
||||
if (pfd->fd == -1 || pfd->revents == 0)
|
||||
continue;
|
||||
|
||||
ev.fd = pfds[i].fd;
|
||||
ev.events = pfds[i].revents;
|
||||
events[reventcount++] = ev;
|
||||
ev.fd = pfd->fd;
|
||||
ev.events = pfd->revents;
|
||||
if (pfd->revents & POLLIN && pfd->revents & POLLOUT)
|
||||
reventcount += 2;
|
||||
else if (pfd->revents & (POLLIN | POLLOUT))
|
||||
++reventcount;
|
||||
|
||||
pfd->revents = 0;
|
||||
events[nevents++] = ev;
|
||||
}
|
||||
|
||||
return reventcount;
|
||||
return nevents;
|
||||
}
|
||||
|
||||
|
||||
|
@ -493,7 +504,7 @@ ssize_t os390_readlink(const char* path, char* buf, size_t len) {
|
|||
|
||||
|
||||
size_t strnlen(const char* str, size_t maxlen) {
|
||||
void* p = memchr(str, 0, maxlen);
|
||||
char* p = memchr(str, 0, maxlen);
|
||||
if (p == NULL)
|
||||
return maxlen;
|
||||
else
|
||||
|
|
|
@ -1121,6 +1121,7 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) {
|
|||
#ifdef __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wgnu-folding-constant"
|
||||
# pragma clang diagnostic ignored "-Wvla-extension"
|
||||
#endif
|
||||
|
||||
static void uv__read(uv_stream_t* stream) {
|
||||
|
|
|
@ -32,13 +32,13 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
# include "stdint-msvc2008.h"
|
||||
# include "uv/stdint-msvc2008.h"
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "uv.h"
|
||||
#include "tree.h"
|
||||
#include "uv/tree.h"
|
||||
#include "queue.h"
|
||||
|
||||
#if EDOM > 0
|
||||
|
@ -132,6 +132,10 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value);
|
|||
|
||||
void uv__fs_scandir_cleanup(uv_fs_t* req);
|
||||
|
||||
int uv__next_timeout(const uv_loop_t* loop);
|
||||
void uv__run_timers(uv_loop_t* loop);
|
||||
void uv__timer_close(uv_timer_t* handle);
|
||||
|
||||
#define uv__has_active_reqs(loop) \
|
||||
((loop)->active_reqs.count > 0)
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "internal.h"
|
||||
#include "queue.h"
|
||||
#include "handle-inl.h"
|
||||
#include "heap-inl.h"
|
||||
#include "req-inl.h"
|
||||
|
||||
/* uv_once initialization guards */
|
||||
|
@ -221,6 +222,7 @@ static void uv_init(void) {
|
|||
|
||||
|
||||
int uv_loop_init(uv_loop_t* loop) {
|
||||
struct heap* timer_heap;
|
||||
int err;
|
||||
|
||||
/* Initialize libuv itself first */
|
||||
|
@ -246,7 +248,11 @@ int uv_loop_init(uv_loop_t* loop) {
|
|||
|
||||
loop->endgame_handles = NULL;
|
||||
|
||||
RB_INIT(&loop->timers);
|
||||
loop->timer_heap = timer_heap = uv__malloc(sizeof(*timer_heap));
|
||||
if (timer_heap == NULL)
|
||||
goto fail_timers_alloc;
|
||||
|
||||
heap_init(timer_heap);
|
||||
|
||||
loop->check_handles = NULL;
|
||||
loop->prepare_handles = NULL;
|
||||
|
@ -285,6 +291,10 @@ fail_async_init:
|
|||
uv_mutex_destroy(&loop->wq_mutex);
|
||||
|
||||
fail_mutex_init:
|
||||
uv__free(timer_heap);
|
||||
loop->timer_heap = NULL;
|
||||
|
||||
fail_timers_alloc:
|
||||
CloseHandle(loop->iocp);
|
||||
loop->iocp = INVALID_HANDLE_VALUE;
|
||||
|
||||
|
@ -292,6 +302,13 @@ fail_mutex_init:
|
|||
}
|
||||
|
||||
|
||||
void uv_update_time(uv_loop_t* loop) {
|
||||
uint64_t new_time = uv__hrtime(1000);
|
||||
assert(new_time >= loop->time);
|
||||
loop->time = new_time;
|
||||
}
|
||||
|
||||
|
||||
void uv__once_init(void) {
|
||||
uv_once(&uv_init_guard_, uv_init);
|
||||
}
|
||||
|
@ -320,6 +337,9 @@ void uv__loop_close(uv_loop_t* loop) {
|
|||
uv_mutex_unlock(&loop->wq_mutex);
|
||||
uv_mutex_destroy(&loop->wq_mutex);
|
||||
|
||||
uv__free(loop->timer_heap);
|
||||
loop->timer_heap = NULL;
|
||||
|
||||
CloseHandle(loop->iocp);
|
||||
}
|
||||
|
||||
|
@ -441,7 +461,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
|
|||
|
||||
while (r != 0 && loop->stop_flag == 0) {
|
||||
uv_update_time(loop);
|
||||
uv_process_timers(loop);
|
||||
uv__run_timers(loop);
|
||||
|
||||
ran_pending = uv_process_reqs(loop);
|
||||
uv_idle_invoke(loop);
|
||||
|
@ -465,7 +485,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
|
|||
* UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
|
||||
* the check.
|
||||
*/
|
||||
uv_process_timers(loop);
|
||||
uv__run_timers(loop);
|
||||
}
|
||||
|
||||
r = uv__loop_alive(loop);
|
||||
|
|
|
@ -1971,6 +1971,10 @@ static void fs__fchown(uv_fs_t* req) {
|
|||
}
|
||||
|
||||
|
||||
static void fs__lchown(uv_fs_t* req) {
|
||||
req->result = 0;
|
||||
}
|
||||
|
||||
static void uv__fs_work(struct uv__work* w) {
|
||||
uv_fs_t* req;
|
||||
|
||||
|
@ -2008,6 +2012,7 @@ static void uv__fs_work(struct uv__work* w) {
|
|||
XX(REALPATH, realpath)
|
||||
XX(CHOWN, chown)
|
||||
XX(FCHOWN, fchown);
|
||||
XX(LCHOWN, lchown);
|
||||
default:
|
||||
assert(!"bad uv_fs_type");
|
||||
}
|
||||
|
@ -2293,6 +2298,19 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid,
|
|||
}
|
||||
|
||||
|
||||
int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
|
||||
uv_gid_t gid, uv_fs_cb cb) {
|
||||
int err;
|
||||
|
||||
INIT(UV_FS_LCHOWN);
|
||||
err = fs__capture_path(req, path, NULL, cb != NULL);
|
||||
if (err) {
|
||||
return uv_translate_sys_error(err);
|
||||
}
|
||||
POST;
|
||||
}
|
||||
|
||||
|
||||
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
||||
int err;
|
||||
|
||||
|
|
|
@ -126,7 +126,8 @@ INLINE static void uv_process_endgames(uv_loop_t* loop) {
|
|||
break;
|
||||
|
||||
case UV_TIMER:
|
||||
uv_timer_endgame(loop, (uv_timer_t*) handle);
|
||||
uv__timer_close((uv_timer_t*) handle);
|
||||
uv__handle_close(handle);
|
||||
break;
|
||||
|
||||
case UV_PREPARE:
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "uv.h"
|
||||
#include "../uv-common.h"
|
||||
|
||||
#include "tree.h"
|
||||
#include "uv/tree.h"
|
||||
#include "winapi.h"
|
||||
#include "winsock.h"
|
||||
|
||||
|
@ -246,15 +246,6 @@ int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle);
|
|||
void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle);
|
||||
|
||||
|
||||
/*
|
||||
* Timers
|
||||
*/
|
||||
void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle);
|
||||
|
||||
DWORD uv__next_timeout(const uv_loop_t* loop);
|
||||
void uv_process_timers(uv_loop_t* loop);
|
||||
|
||||
|
||||
/*
|
||||
* Loop watchers
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <io.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -1294,7 +1293,7 @@ static int uv__pipe_write_data(uv_loop_t* loop,
|
|||
size_t nbufs,
|
||||
uv_stream_t* send_handle,
|
||||
uv_write_cb cb,
|
||||
bool copy_always) {
|
||||
int copy_always) {
|
||||
int err;
|
||||
int result;
|
||||
uv_buf_t write_buf;
|
||||
|
@ -1536,7 +1535,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop,
|
|||
/* Write buffers. We set the `always_copy` flag, so it is not a problem that
|
||||
* some of the written data lives on the stack. */
|
||||
err = uv__pipe_write_data(
|
||||
loop, req, handle, bufs, buf_count, send_handle, cb, true);
|
||||
loop, req, handle, bufs, buf_count, send_handle, cb, 1);
|
||||
|
||||
/* If we had to heap-allocate the bufs array, free it now. */
|
||||
if (bufs != stack_bufs) {
|
||||
|
@ -1561,7 +1560,7 @@ int uv__pipe_write(uv_loop_t* loop,
|
|||
/* Non-IPC pipe write: put data on the wire directly. */
|
||||
assert(send_handle == NULL);
|
||||
return uv__pipe_write_data(
|
||||
loop, req, handle, bufs, nbufs, NULL, cb, false);
|
||||
loop, req, handle, bufs, nbufs, NULL, cb, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1658,7 +1657,8 @@ static DWORD uv__pipe_read_data(uv_loop_t* loop,
|
|||
* (a) the length of the user-allocated buffer.
|
||||
* (b) the maximum data length as specified by the `max_bytes` argument.
|
||||
*/
|
||||
max_bytes = min(buf.len, max_bytes);
|
||||
if (max_bytes > buf.len)
|
||||
max_bytes = buf.len;
|
||||
|
||||
/* Read into the user buffer. */
|
||||
if (!ReadFile(handle->handle, buf.base, max_bytes, &bytes_read, NULL)) {
|
||||
|
@ -1674,7 +1674,7 @@ static DWORD uv__pipe_read_data(uv_loop_t* loop,
|
|||
|
||||
|
||||
static DWORD uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) {
|
||||
DWORD* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining;
|
||||
uint32_t* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining;
|
||||
int err;
|
||||
|
||||
if (*data_remaining > 0) {
|
||||
|
|
|
@ -103,6 +103,7 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
|
|||
DWORD client_access = 0;
|
||||
HANDLE child_pipe = INVALID_HANDLE_VALUE;
|
||||
int err;
|
||||
int overlap;
|
||||
|
||||
if (flags & UV_READABLE_PIPE) {
|
||||
/* The server needs inbound access too, otherwise CreateNamedPipe() won't
|
||||
|
@ -130,7 +131,7 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
|
|||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
BOOL overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE);
|
||||
overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE);
|
||||
child_pipe = CreateFileA(pipe_name,
|
||||
client_access,
|
||||
0,
|
||||
|
|
|
@ -26,15 +26,6 @@
|
|||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
|
||||
static int uv_cond_condvar_init(uv_cond_t* cond);
|
||||
static void uv_cond_condvar_destroy(uv_cond_t* cond);
|
||||
static void uv_cond_condvar_signal(uv_cond_t* cond);
|
||||
static void uv_cond_condvar_broadcast(uv_cond_t* cond);
|
||||
static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex);
|
||||
static int uv_cond_condvar_timedwait(uv_cond_t* cond,
|
||||
uv_mutex_t* mutex, uint64_t timeout);
|
||||
|
||||
|
||||
static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) {
|
||||
DWORD result;
|
||||
HANDLE existing_event, created_event;
|
||||
|
@ -374,7 +365,7 @@ int uv_cond_init(uv_cond_t* cond) {
|
|||
|
||||
void uv_cond_destroy(uv_cond_t* cond) {
|
||||
/* nothing to do */
|
||||
UV__UNUSED(cond);
|
||||
(void) &cond;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
# include "stdint-msvc2008.h"
|
||||
# include "uv/stdint-msvc2008.h"
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue