Changes since version 1.44.2: * win: remove stdint-msvc2008.h (Ben Noordhuis) * android: remove pthread-fixes.c (Ben Noordhuis) * build: enable MSVC_RUNTIME_LIBRARY setting (自发对称破缺) * unix: switch to c11 atomics (Ben Noordhuis) * unix: don't accept() connections in a loop (Ben Noordhuis) * win: fix off-by-1 buffer overrun in uv_exepath() (Ben Noordhuis) * build: switch ci from macos-10.15 to macos-11 (Ben Noordhuis) * win: fix thread race in uv_cwd() and uv_chdir() (Ben Noordhuis) * unix,win: remove UV_HANDLE_SHUTTING flag (Santiago Gimeno) * win: support Windows 11 in uv_os_uname() (Luan Devecchi) * unix: fix uv_getrusage() ru_maxrss reporting (Ben Noordhuis) * doc: add note about offset -1 in uv_fs_read/write (Steven Schveighoffer) * test: fix musl libc.a dlerror() test expectation (Ben Noordhuis) * kqueue: DRY file descriptor deletion logic (Ben Noordhuis) * linux: teach uv_get_constrained_memory() cgroupsv2 (Ben Noordhuis) * build: upgrade qemu-user-static package (Ben Noordhuis) * linux: move epoll.c back into linux-core.c (Ben Noordhuis) * unix: remove pre-macos 10.8 compatibility hack (Ben Noordhuis) * unix,win: fix memory leak in uv_fs_scandir() (Ben Noordhuis) * build: restore qemu download logic (Ben Noordhuis) * win: fix uv__pipe_accept memory leak (number201724) * doc: update LINKS.md (Daniel) * unix: simplify atomic op in uv_tty_reset_mode() (Ben Noordhuis) * build: add LIBUV_BUILD_SHARED cmake option (Christian Clason) * linux: remove unused or obsolete syscall wrappers (Ben Noordhuis) * linux: merge files back into single file (Ben Noordhuis) * stream: process more than one write req per loop tick (ywave620) * unix,win: give thread pool threads an 8 MB stack (Ben Noordhuis) * build: add MemorySanitizer (MSAN) support (Ben Noordhuis) * doc: add uv_poll_cb status==UV_EBADF note (jensbjorgensen) * build: support AddressSanitizer on MSVC (Jameson Nash) * win,pipe: improve method of obtaining pid for ipc (number201724) * thread: add support for affinity (daomingq) * include: map ENODATA error code (Ben Noordhuis) * build: remove bashism from autogen.sh (Santiago Gimeno) * win,tcp,udp: remove "active streams" optimization (Saúl Ibarra Corretgé) * win: drop code checking for Windows XP / Server 2k3 (Saúl Ibarra Corretgé) * unix,win: fix 'sprintf' is deprecated warning (twosee) * doc: mention close_cb can be NULL (Qix) * win: optimize udp receive performance (ywave620) * win: fix an incompatible types warning (twosee) * doc: document 0 return value for free/total memory (Ben Noordhuis) * darwin: use hw.cpufrequency again for frequency info (Jameson Nash) * win,test: change format of TEST_PIPENAME's (Santiago Gimeno) * win,pipe: fixes in uv_pipe_connect() (Santiago Gimeno) * misc: fix return value of memory functions (theanarkh) * src: add new metrics APIs (Trevor Norris) * thread: add uv_thread_getcpu() (daomingq) * build: don't use ifaddrs.h on solaris 10 (Edward Humes) * unix,win: add uv_get_available_memory() (Tim Besard) * test: fix -Wunused-but-set-variable warnings (Ben Noordhuis) * doc: bump min supported linux and freebsd versions (Ben Noordhuis) * Add Socket Runtime to the LINKS.md (Sergey Rubanov) * unix: drop kfreebsd support (Ben Noordhuis) * win: fix fstat for pipes and character files (Stefan Stojanovic) * win: fix -Wunused-variable warning (Ben Noordhuis) * win: fix -Wunused-function warning (Ben Noordhuis) * build: drop qemu-alpha from ci matrix (Ben Noordhuis) * win: move child_stdio_buffer out of uv_process_t (Santiago Gimeno) * test: fix some unreachable code warnings (Santiago Gimeno) * linux: simplify uv_uptime() (Ben Noordhuis) * test: unflake fs_event_watch_dir test (Ben Noordhuis) * darwin: remove unused fsevents symbol lookups (Ben Noordhuis) * build: add define guard around UV_EXTERN (Zvicii) * build: add UndefinedBehaviorSanitizer support (Ben Noordhuis) * build: enable platform_output test on qemu (Ben Noordhuis) * linux: handle cpu hotplugging in uv_cpu_info() (Ben Noordhuis) * build: remove unnecessary policy setting (dundargoc) * docs: add vcpkg instruction step (Jack·Boos·Yu) * win,fs: fix readlink errno for a non-symlink file (Darshan Sen) * misc: extend getpw to take uid as an argument (Jameson Nash) * unix,win: use static_assert when available (Ben Noordhuis) * docs: delete code Makefile (Jameson Nash) * docs: add CI for docs PRs (Jameson Nash) * docs: update Sphinx version on RTD (Jameson Nash) * doc: clean up license file (Ben Noordhuis) * test: fix some warnings when compiling tests (panran) * build,win: add mingw-w64 CI configuration (Jameson Nash) * build: add CI for distcheck (Jameson Nash) * unix: remove busy loop from uv_async_send (Jameson Nash) * doc: document uv_fs_cb type (Tamás Bálint Misius) * build: Improve build by cmake for Cygwin (erw7) * build: add libuv:: namespace to libuvConfig.cmake (AJ Heller) * test: fix ThreadSanitizer thread leak warning (Ben Noordhuis) * test: fix ThreadSanitizer data race warning (Ben Noordhuis) * test: fix ThreadSanitizer data race warning (Ben Noordhuis) * test: fix ThreadSanitizer data race warning (Ben Noordhuis) * test: cond-skip fork_threadpool_queue_work_simple (Ben Noordhuis) * test: cond-skip signal_multiple_loops (Ben Noordhuis) * test: cond-skip tcp_writealot (Ben Noordhuis) * build: promote tsan ci to must-pass (Ben Noordhuis) * build: add CI for OpenBSD and FreeBSD (James McCoy) * build,test: fix distcheck errors (Jameson Nash) * test: remove bad tty window size assumption (Ben Noordhuis) * darwin,process: feed kevent the signal to reap children (Jameson Nash) * unix: abort on clock_gettime() error (Ben Noordhuis) * test: remove timing-sensitive check (Ben Noordhuis) * unix: DRY and fix tcp bind error path (Jameson Nash) * macos: fix fsevents thread race conditions (Ben Noordhuis) * win: fix leak in uv_chdir (Trevor Norris) * test: make valgrind happy (Trevor Norris) * barrier: wait for prior out before next in (Jameson Nash) * test: fix visual studio 2015 build error (Ben Noordhuis) * linux: fix ceph copy error truncating readonly files (Bruno Passeri) * test: silence more valgrind warnings (Trevor Norris) * doc: add entries to LINKS.md (Trevor Norris) * win,unix: change execution order of timers (Trevor Norris) * doc: add trevnorris to maintainers (Trevor Norris) * linux: remove epoll_pwait() emulation code path (Ben Noordhuis) * linux: replace unsafe macro with inline function (Ben Noordhuis) * linux: remove arm oabi support (Ben Noordhuis) * unix,sunos: SO_REUSEPORT not valid on all sockets (Stacey Marshall) * doc: consistent single backquote in misc.rst (Jason Zhang) * src: switch to use C11 atomics where available (Trevor Norris) * test: don't use static buffer for formatting (Ben Noordhuis) * linux: introduce io_uring support (Ben Noordhuis) * linux: fix academic valgrind warning (Ben Noordhuis) * test: disable signal test under ASan and MSan (Ben Noordhuis) * linux: add IORING_OP_OPENAT support (Ben Noordhuis) * linux: add IORING_OP_CLOSE support (Ben Noordhuis) * linux: remove bug workaround for obsolete kernels (Ben Noordhuis) * doc: update active maintainers list (Ben Noordhuis) * test: add ASSERT_OK (Trevor Norris) * src: fix events/events_waiting metrics counter (Trevor Norris) * unix,win: add uv_clock_gettime() (Ben Noordhuis) * build: remove freebsd and openbsd buildbots (Ben Noordhuis) * win: fix race condition in uv__init_console() (sivadeilra) * linux: fix logic bug in sqe ring space check (Ben Noordhuis) * linux: use io_uring to batch epoll_ctl calls (Ben Noordhuis) * macos: update minimum supported version (Santiago Gimeno) * docs: fix some typos (cui fliter) * unix: use memcpy() instead of type punning (Ben Noordhuis) * test: add additional assert (Mohammed Keyvanzadeh) * build: export compile_commands.json (Lewis Russell) * win,process: write minidumps when sending SIGQUIT (Elliot Saba) * unix: constrained_memory should return UINT64_MAX (Tim Besard) * unix: handle CQ overflow in iou ring (Santiago Gimeno) * unix: remove clang compiler warning pragmas (Ben Noordhuis) * win: fix mingw build (gengjiawen) * test: fix -Wbool-compare compiler warning (Ben Noordhuis) * win: define MiniDumpWithAvxXStateContext always (Santiago Gimeno) * freebsd: hard-code UV_ENODATA definition (Santiago Gimeno) * linux: work around EOWNERDEAD io_uring kernel bug (Ben Noordhuis) * linux: fix WRITEV with lots of bufs using io_uring (Santiago Gimeno) -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEYS8OrZQBYiN530QC8ow8jaM8A74FAmRnW50ACgkQ8ow8jaM8 A76noBAAiavsCBvAC554x4Naic+B3fEYjKnLe8OLTbdN4XQsS2uSkCEuP0TuwLE7 Q93CHgDFcL//XmNAXwIKMIvZ7G25zga93qxrZdd7Hsuthg5oJwsrZb8faHG7CeKy Fq+SLCUdLcwOR9m9RDp1u3h/pIhoqQvLUlPcBvDKVaJOVhIngawKU/vC125z6ZJs CYaKMlPbU2WjIkkoQjNRYL8oolmWTs5T/8AhIVWntTCyc/+/n7uxmWwlfL2iR8Kj u5IT7Vhh6a7VC+dGh26k/FN0RGdAgJCZ1Jnrt+llHxRVuw0xEBnrTAyS3hOkA7Me s+8VUaCsreVi9p66hqE5b4IL5e9yUEB18A5dQBY+TFNeXaQETVg9BxPMXbhoh+XB 2643LZn/kN1iilZBMSMl9kqB66qeUihv8cvjMnrTzq+nSxJvuc13XPfbH+zhMkVh CQaFMq3v5vc4Kyk2YrjcsfGCIkRxRGlhSmk5riz1Xf+erf4GuOl+o2fA6YvVDAnE rzlzpGoRSHgHYC23KirkBHo7qQVbWy+NeLWFRFSHfSN4+czttdusiFSjxERavfSh ezRKH6dNHI8C9fqT3oAitXOgFt6AsMiYMt7JpJwPm0SdAFjIEkgjAfhkSQADUHz7 qezLtJoCL+bcUXE8tgRRuz+J6x4FhKBZVu5uA6fV1UuyWI74DBU= =YAOh -----END PGP SIGNATURE----- Merge tag 'v1.45.0' into merge_1.45.0
564 lines
27 KiB
C
564 lines
27 KiB
C
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to
|
|
* deal in the Software without restriction, including without limitation the
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*/
|
|
|
|
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
|
|
typedef intptr_t ssize_t;
|
|
# define SSIZE_MAX INTPTR_MAX
|
|
# define _SSIZE_T_
|
|
# define _SSIZE_T_DEFINED
|
|
#endif
|
|
|
|
#include <winsock2.h>
|
|
|
|
#ifndef LOCALE_INVARIANT
|
|
# define LOCALE_INVARIANT 0x007f
|
|
#endif
|
|
|
|
#include <mswsock.h>
|
|
// Disable the typedef in mstcpip.h of MinGW.
|
|
#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID
|
|
#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID
|
|
#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID
|
|
#include <ws2tcpip.h>
|
|
#undef _TCP_INITIAL_RTO_PARAMETERS
|
|
#undef TCP_INITIAL_RTO_PARAMETERS
|
|
#undef PTCP_INITIAL_RTO_PARAMETERS
|
|
#include <windows.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "uv/tree.h"
|
|
#include "uv/threadpool.h"
|
|
|
|
#define MAX_PIPENAME_LEN 256
|
|
|
|
#ifndef S_IFLNK
|
|
# define S_IFLNK 0xA000
|
|
#endif
|
|
|
|
// Define missing in Windows Kit Include\{VERSION}\ucrt\sys\stat.h
|
|
#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES && !defined(S_IFIFO)
|
|
# define S_IFIFO _S_IFIFO
|
|
#endif
|
|
|
|
/* Signals supported by uv_signal and or uv_kill */
|
|
#define SIGHUP 1
|
|
#define SIGINT 2
|
|
#define SIGQUIT 3
|
|
#define SIGILL 4
|
|
#define SIGABRT_COMPAT 6
|
|
#define SIGFPE 8
|
|
#define SIGKILL 9
|
|
#define SIGSEGV 11
|
|
#define SIGTERM 15
|
|
#define SIGBREAK 21
|
|
#define SIGABRT 22
|
|
#define SIGWINCH 28
|
|
|
|
/* Redefine NSIG to take SIGWINCH into consideration */
|
|
#if defined(NSIG) && NSIG <= SIGWINCH
|
|
# undef NSIG
|
|
#endif
|
|
#ifndef NSIG
|
|
# define NSIG SIGWINCH + 1
|
|
#endif
|
|
|
|
typedef int (WSAAPI* LPFN_WSARECV)
|
|
(SOCKET socket,
|
|
LPWSABUF buffers,
|
|
DWORD buffer_count,
|
|
LPDWORD bytes,
|
|
LPDWORD flags,
|
|
LPWSAOVERLAPPED overlapped,
|
|
LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
|
|
|
|
typedef int (WSAAPI* LPFN_WSARECVFROM)
|
|
(SOCKET socket,
|
|
LPWSABUF buffers,
|
|
DWORD buffer_count,
|
|
LPDWORD bytes,
|
|
LPDWORD flags,
|
|
struct sockaddr* addr,
|
|
LPINT addr_len,
|
|
LPWSAOVERLAPPED overlapped,
|
|
LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
|
|
|
|
#ifndef _NTDEF_
|
|
typedef LONG NTSTATUS;
|
|
typedef NTSTATUS *PNTSTATUS;
|
|
#endif
|
|
|
|
#ifndef RTL_CONDITION_VARIABLE_INIT
|
|
typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
|
|
#endif
|
|
|
|
typedef struct _AFD_POLL_HANDLE_INFO {
|
|
HANDLE Handle;
|
|
ULONG Events;
|
|
NTSTATUS Status;
|
|
} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
|
|
|
|
typedef struct _AFD_POLL_INFO {
|
|
LARGE_INTEGER Timeout;
|
|
ULONG NumberOfHandles;
|
|
ULONG Exclusive;
|
|
AFD_POLL_HANDLE_INFO Handles[1];
|
|
} AFD_POLL_INFO, *PAFD_POLL_INFO;
|
|
|
|
#define UV_MSAFD_PROVIDER_COUNT 4
|
|
|
|
|
|
/**
|
|
* It should be possible to cast uv_buf_t[] to WSABUF[]
|
|
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
|
|
*/
|
|
typedef struct uv_buf_t {
|
|
ULONG len;
|
|
char* base;
|
|
} uv_buf_t;
|
|
|
|
typedef SOCKET uv_os_sock_t;
|
|
typedef HANDLE uv_os_fd_t;
|
|
typedef int uv_pid_t;
|
|
|
|
typedef HANDLE uv_thread_t;
|
|
|
|
typedef HANDLE uv_sem_t;
|
|
|
|
typedef CRITICAL_SECTION uv_mutex_t;
|
|
|
|
typedef CONDITION_VARIABLE uv_cond_t;
|
|
|
|
typedef SRWLOCK uv_rwlock_t;
|
|
|
|
typedef struct {
|
|
unsigned threshold;
|
|
unsigned in;
|
|
uv_mutex_t mutex;
|
|
/* TODO: in v2 make this a uv_cond_t, without unused_ */
|
|
CONDITION_VARIABLE cond;
|
|
unsigned out;
|
|
} uv_barrier_t;
|
|
|
|
typedef struct {
|
|
DWORD tls_index;
|
|
} uv_key_t;
|
|
|
|
#define UV_ONCE_INIT { 0, NULL }
|
|
|
|
typedef struct uv_once_s {
|
|
unsigned char ran;
|
|
HANDLE event;
|
|
} uv_once_t;
|
|
|
|
/* Platform-specific definitions for uv_spawn support. */
|
|
typedef unsigned char uv_uid_t;
|
|
typedef unsigned char uv_gid_t;
|
|
|
|
typedef struct uv__dirent_s {
|
|
int d_type;
|
|
char d_name[1];
|
|
} uv__dirent_t;
|
|
|
|
#define UV_DIR_PRIVATE_FIELDS \
|
|
HANDLE dir_handle; \
|
|
WIN32_FIND_DATAW find_data; \
|
|
BOOL need_find_call;
|
|
|
|
#define HAVE_DIRENT_TYPES
|
|
#define UV__DT_DIR UV_DIRENT_DIR
|
|
#define UV__DT_FILE UV_DIRENT_FILE
|
|
#define UV__DT_LINK UV_DIRENT_LINK
|
|
#define UV__DT_FIFO UV_DIRENT_FIFO
|
|
#define UV__DT_SOCKET UV_DIRENT_SOCKET
|
|
#define UV__DT_CHAR UV_DIRENT_CHAR
|
|
#define UV__DT_BLOCK UV_DIRENT_BLOCK
|
|
|
|
/* Platform-specific definitions for uv_dlopen support. */
|
|
#define UV_DYNAMIC FAR WINAPI
|
|
typedef struct {
|
|
HMODULE handle;
|
|
char* errmsg;
|
|
} uv_lib_t;
|
|
|
|
#define UV_LOOP_PRIVATE_FIELDS \
|
|
/* The loop's I/O completion port */ \
|
|
HANDLE iocp; \
|
|
/* The current time according to the event loop. in msecs. */ \
|
|
uint64_t time; \
|
|
/* Tail of a single-linked circular queue of pending reqs. If the queue */ \
|
|
/* is empty, tail_ is NULL. If there is only one item, */ \
|
|
/* tail_->next_req == tail_ */ \
|
|
uv_req_t* pending_reqs_tail; \
|
|
/* Head of a single-linked list of closed handles */ \
|
|
uv_handle_t* endgame_handles; \
|
|
/* Timers */ \
|
|
struct { \
|
|
void* min; \
|
|
unsigned int nelts; \
|
|
} timer_heap; \
|
|
uint64_t timer_counter; \
|
|
/* Lists of active loop (prepare / check / idle) watchers */ \
|
|
void* prepare_handles[2]; \
|
|
void* check_handles[2]; \
|
|
void* idle_handles[2]; \
|
|
/* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
|
|
SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
|
|
/* Threadpool */ \
|
|
void* wq[2]; \
|
|
uv_mutex_t wq_mutex; \
|
|
uv_async_t wq_async; \
|
|
/* Async handle */ \
|
|
struct uv_req_s async_req; \
|
|
void* async_handles[2]; \
|
|
/* Global queue of loops */ \
|
|
void* loops_queue[2];
|
|
|
|
#define UV_REQ_TYPE_PRIVATE \
|
|
/* TODO: remove the req suffix */ \
|
|
UV_ACCEPT, \
|
|
UV_FS_EVENT_REQ, \
|
|
UV_POLL_REQ, \
|
|
UV_PROCESS_EXIT, \
|
|
UV_READ, \
|
|
UV_UDP_RECV, \
|
|
UV_WAKEUP, \
|
|
UV_SIGNAL_REQ,
|
|
|
|
#define UV_REQ_PRIVATE_FIELDS \
|
|
union { \
|
|
/* Used by I/O operations */ \
|
|
struct { \
|
|
OVERLAPPED overlapped; \
|
|
size_t queued_bytes; \
|
|
} io; \
|
|
/* in v2, we can move these to the UV_CONNECT_PRIVATE_FIELDS */ \
|
|
struct { \
|
|
ULONG_PTR result; /* overlapped.Internal is reused to hold the result */\
|
|
HANDLE pipeHandle; \
|
|
DWORD duplex_flags; \
|
|
WCHAR* name; \
|
|
} connect; \
|
|
} u; \
|
|
struct uv_req_s* next_req;
|
|
|
|
#define UV_WRITE_PRIVATE_FIELDS \
|
|
int coalesced; \
|
|
uv_buf_t write_buffer; \
|
|
HANDLE event_handle; \
|
|
HANDLE wait_handle;
|
|
|
|
#define UV_CONNECT_PRIVATE_FIELDS \
|
|
/* empty */
|
|
|
|
#define UV_SHUTDOWN_PRIVATE_FIELDS \
|
|
/* empty */
|
|
|
|
#define UV_UDP_SEND_PRIVATE_FIELDS \
|
|
/* empty */
|
|
|
|
#define UV_PRIVATE_REQ_TYPES \
|
|
typedef struct uv_pipe_accept_s { \
|
|
UV_REQ_FIELDS \
|
|
HANDLE pipeHandle; \
|
|
struct uv_pipe_accept_s* next_pending; \
|
|
} uv_pipe_accept_t; \
|
|
\
|
|
typedef struct uv_tcp_accept_s { \
|
|
UV_REQ_FIELDS \
|
|
SOCKET accept_socket; \
|
|
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
|
|
HANDLE event_handle; \
|
|
HANDLE wait_handle; \
|
|
struct uv_tcp_accept_s* next_pending; \
|
|
} uv_tcp_accept_t; \
|
|
\
|
|
typedef struct uv_read_s { \
|
|
UV_REQ_FIELDS \
|
|
HANDLE event_handle; \
|
|
HANDLE wait_handle; \
|
|
} uv_read_t;
|
|
|
|
#define uv_stream_connection_fields \
|
|
unsigned int write_reqs_pending; \
|
|
uv_shutdown_t* shutdown_req;
|
|
|
|
#define uv_stream_server_fields \
|
|
uv_connection_cb connection_cb;
|
|
|
|
#define UV_STREAM_PRIVATE_FIELDS \
|
|
unsigned int reqs_pending; \
|
|
int activecnt; \
|
|
uv_read_t read_req; \
|
|
union { \
|
|
struct { uv_stream_connection_fields } conn; \
|
|
struct { uv_stream_server_fields } serv; \
|
|
} stream;
|
|
|
|
#define uv_tcp_server_fields \
|
|
uv_tcp_accept_t* accept_reqs; \
|
|
unsigned int processed_accepts; \
|
|
uv_tcp_accept_t* pending_accepts; \
|
|
LPFN_ACCEPTEX func_acceptex;
|
|
|
|
#define uv_tcp_connection_fields \
|
|
uv_tcp_accept_t* dummy1; /* Mirror of union field, keep as NULL */ \
|
|
unsigned int dummy2; /* Mirror of union field, keep as 0 */ \
|
|
LPFN_CONNECTEX func_connectex;
|
|
|
|
#define UV_TCP_PRIVATE_FIELDS \
|
|
SOCKET socket; \
|
|
int delayed_error; \
|
|
union { \
|
|
struct { uv_tcp_server_fields } serv; \
|
|
struct { uv_tcp_connection_fields } conn; \
|
|
} tcp;
|
|
|
|
#define UV_UDP_PRIVATE_FIELDS \
|
|
SOCKET socket; \
|
|
unsigned int reqs_pending; \
|
|
int activecnt; \
|
|
uv_req_t recv_req; \
|
|
struct sockaddr_storage recv_from; \
|
|
int recv_from_len; \
|
|
uv_udp_recv_cb recv_cb; \
|
|
uv_alloc_cb alloc_cb; \
|
|
LPFN_WSARECV func_wsarecv; \
|
|
LPFN_WSARECVFROM func_wsarecvfrom;
|
|
|
|
#define uv_pipe_server_fields \
|
|
int pending_instances; \
|
|
uv_pipe_accept_t* accept_reqs; \
|
|
uv_pipe_accept_t* pending_accepts;
|
|
|
|
#define uv_pipe_connection_fields \
|
|
uv_timer_t* eof_timer; \
|
|
DWORD ipc_remote_pid; \
|
|
struct { \
|
|
uint32_t payload_remaining; \
|
|
} ipc_data_frame; \
|
|
void* ipc_xfer_queue[2]; \
|
|
int ipc_xfer_queue_length; \
|
|
uv_write_t* non_overlapped_writes_tail; \
|
|
CRITICAL_SECTION readfile_thread_lock; \
|
|
volatile HANDLE readfile_thread_handle;
|
|
|
|
#define UV_PIPE_PRIVATE_FIELDS \
|
|
HANDLE handle; \
|
|
WCHAR* name; \
|
|
union { \
|
|
struct { uv_pipe_server_fields } serv; \
|
|
struct { uv_pipe_connection_fields } conn; \
|
|
} pipe;
|
|
|
|
/* TODO: put the parser states in a union - TTY handles are always half-duplex
|
|
* so read-state can safely overlap write-state. */
|
|
#define UV_TTY_PRIVATE_FIELDS \
|
|
HANDLE handle; \
|
|
union { \
|
|
struct { \
|
|
/* Used for readable TTY handles */ \
|
|
uv_buf_t read_line_buffer; \
|
|
HANDLE read_raw_wait; \
|
|
/* Fields used for translating win keystrokes into vt100 characters */ \
|
|
char last_key[8]; \
|
|
unsigned char last_key_offset; \
|
|
unsigned char last_key_len; \
|
|
WCHAR last_utf16_high_surrogate; \
|
|
INPUT_RECORD last_input_record; \
|
|
} rd; \
|
|
struct { \
|
|
/* Used for writable TTY handles */ \
|
|
/* utf8-to-utf16 conversion state */ \
|
|
unsigned int utf8_codepoint; \
|
|
unsigned char utf8_bytes_left; \
|
|
/* eol conversion state */ \
|
|
unsigned char previous_eol; \
|
|
/* ansi parser state */ \
|
|
unsigned short ansi_parser_state; \
|
|
unsigned char ansi_csi_argc; \
|
|
unsigned short ansi_csi_argv[4]; \
|
|
COORD saved_position; \
|
|
WORD saved_attributes; \
|
|
} wr; \
|
|
} tty;
|
|
|
|
#define UV_POLL_PRIVATE_FIELDS \
|
|
SOCKET socket; \
|
|
/* Used in fast mode */ \
|
|
SOCKET peer_socket; \
|
|
AFD_POLL_INFO afd_poll_info_1; \
|
|
AFD_POLL_INFO afd_poll_info_2; \
|
|
/* Used in fast and slow mode. */ \
|
|
uv_req_t poll_req_1; \
|
|
uv_req_t poll_req_2; \
|
|
unsigned char submitted_events_1; \
|
|
unsigned char submitted_events_2; \
|
|
unsigned char mask_events_1; \
|
|
unsigned char mask_events_2; \
|
|
unsigned char events;
|
|
|
|
#define UV_TIMER_PRIVATE_FIELDS \
|
|
uv_timer_cb timer_cb; \
|
|
void* heap_node[3]; \
|
|
uint64_t timeout; \
|
|
uint64_t repeat; \
|
|
uint64_t start_id;
|
|
|
|
#define UV_ASYNC_PRIVATE_FIELDS \
|
|
void* queue[2]; \
|
|
uv_async_cb async_cb; \
|
|
LONG volatile async_sent;
|
|
|
|
#define UV_PREPARE_PRIVATE_FIELDS \
|
|
void* queue[2]; \
|
|
uv_prepare_cb prepare_cb;
|
|
|
|
#define UV_CHECK_PRIVATE_FIELDS \
|
|
void* queue[2]; \
|
|
uv_check_cb check_cb;
|
|
|
|
#define UV_IDLE_PRIVATE_FIELDS \
|
|
void* queue[2]; \
|
|
uv_idle_cb idle_cb;
|
|
|
|
#define UV_HANDLE_PRIVATE_FIELDS \
|
|
uv_handle_t* endgame_next; \
|
|
unsigned int flags;
|
|
|
|
#define UV_GETADDRINFO_PRIVATE_FIELDS \
|
|
struct uv__work work_req; \
|
|
uv_getaddrinfo_cb getaddrinfo_cb; \
|
|
void* alloc; \
|
|
WCHAR* node; \
|
|
WCHAR* service; \
|
|
/* The addrinfoW field is used to store a pointer to the hints, and */ \
|
|
/* later on to store the result of GetAddrInfoW. The final result will */ \
|
|
/* be converted to struct addrinfo* and stored in the addrinfo field. */ \
|
|
struct addrinfoW* addrinfow; \
|
|
struct addrinfo* addrinfo; \
|
|
int retcode;
|
|
|
|
#define UV_GETNAMEINFO_PRIVATE_FIELDS \
|
|
struct uv__work work_req; \
|
|
uv_getnameinfo_cb getnameinfo_cb; \
|
|
struct sockaddr_storage storage; \
|
|
int flags; \
|
|
char host[NI_MAXHOST]; \
|
|
char service[NI_MAXSERV]; \
|
|
int retcode;
|
|
|
|
#define UV_PROCESS_PRIVATE_FIELDS \
|
|
struct uv_process_exit_s { \
|
|
UV_REQ_FIELDS \
|
|
} exit_req; \
|
|
void* unused; /* TODO: retained for ABI compat; remove this in v2.x. */ \
|
|
int exit_signal; \
|
|
HANDLE wait_handle; \
|
|
HANDLE process_handle; \
|
|
volatile char exit_cb_pending;
|
|
|
|
#define UV_FS_PRIVATE_FIELDS \
|
|
struct uv__work work_req; \
|
|
int flags; \
|
|
DWORD sys_errno_; \
|
|
union { \
|
|
/* TODO: remove me in 0.9. */ \
|
|
WCHAR* pathw; \
|
|
HANDLE hFile; \
|
|
} file; \
|
|
union { \
|
|
struct { \
|
|
int mode; \
|
|
WCHAR* new_pathw; \
|
|
int file_flags; \
|
|
HANDLE hFile_out; \
|
|
unsigned int nbufs; \
|
|
uv_buf_t* bufs; \
|
|
int64_t offset; \
|
|
uv_buf_t bufsml[4]; \
|
|
} info; \
|
|
struct { \
|
|
double btime; \
|
|
double atime; \
|
|
double mtime; \
|
|
} time; \
|
|
} fs;
|
|
|
|
#define UV_WORK_PRIVATE_FIELDS \
|
|
struct uv__work work_req;
|
|
|
|
#define UV_FS_EVENT_PRIVATE_FIELDS \
|
|
struct uv_fs_event_req_s { \
|
|
UV_REQ_FIELDS \
|
|
} req; \
|
|
HANDLE dir_handle; \
|
|
int req_pending; \
|
|
uv_fs_event_cb cb; \
|
|
WCHAR* filew; \
|
|
WCHAR* short_filew; \
|
|
WCHAR* dirw; \
|
|
char* buffer;
|
|
|
|
#define UV_SIGNAL_PRIVATE_FIELDS \
|
|
RB_ENTRY(uv_signal_s) tree_entry; \
|
|
struct uv_req_s signal_req; \
|
|
unsigned long pending_signum;
|
|
|
|
#ifndef F_OK
|
|
#define F_OK 0
|
|
#endif
|
|
#ifndef R_OK
|
|
#define R_OK 4
|
|
#endif
|
|
#ifndef W_OK
|
|
#define W_OK 2
|
|
#endif
|
|
#ifndef X_OK
|
|
#define X_OK 1
|
|
#endif
|
|
|
|
/* fs open() flags supported on this platform: */
|
|
#define UV_FS_O_APPEND 0x0008
|
|
#define UV_FS_O_CREAT 0x0100
|
|
#define UV_FS_O_EXCL 0x0400
|
|
#define UV_FS_O_FILEMAP 0x20000000
|
|
#define UV_FS_O_RANDOM 0x0010
|
|
#define UV_FS_O_RDONLY 0x0000
|
|
#define UV_FS_O_RDWR 0x0002
|
|
#define UV_FS_O_SEQUENTIAL 0x0020
|
|
#define UV_FS_O_SHORT_LIVED 0x1000
|
|
#define UV_FS_O_TEMPORARY 0x0040
|
|
#define UV_FS_O_TRUNC 0x0200
|
|
#define UV_FS_O_WRONLY 0x0001
|
|
|
|
/* fs open() flags supported on other platforms (or mapped on this platform): */
|
|
#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */
|
|
#define UV_FS_O_DIRECTORY 0
|
|
#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */
|
|
#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */
|
|
#define UV_FS_O_NOATIME 0
|
|
#define UV_FS_O_NOCTTY 0
|
|
#define UV_FS_O_NOFOLLOW 0
|
|
#define UV_FS_O_NONBLOCK 0
|
|
#define UV_FS_O_SYMLINK 0
|
|
#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */
|