src,test: fix idiosyncratic comment style
Back in the day I wrote comments in a really unusual way. Nowadays it makes my eyes bleed, and clang-format doesn't know how to deal with it. PR-URL: https://github.com/libuv/libuv/pull/1853 Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
parent
62a0f763a7
commit
9584df25dc
@ -86,8 +86,8 @@ typedef struct pollfd {
|
||||
#define SIGKILL 9
|
||||
#define SIGWINCH 28
|
||||
|
||||
/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */
|
||||
/* unix-like platforms. However MinGW doesn't define it, so we do. */
|
||||
/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like
|
||||
* platforms. However MinGW doesn't define it, so we do. */
|
||||
#ifndef SIGABRT_COMPAT
|
||||
# define SIGABRT_COMPAT 6
|
||||
#endif
|
||||
@ -478,8 +478,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
||||
struct { uv_pipe_connection_fields } conn; \
|
||||
} pipe;
|
||||
|
||||
/* TODO: put the parser states in an union - TTY handles are always */
|
||||
/* half-duplex so read-state can safely overlap write-state. */
|
||||
/* TODO: put the parser states in an union - TTY handles are always half-duplex
|
||||
* so read-state can safely overlap write-state. */
|
||||
#define UV_TTY_PRIVATE_FIELDS \
|
||||
HANDLE handle; \
|
||||
union { \
|
||||
|
||||
@ -174,8 +174,8 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
||||
|
||||
case UV_SIGNAL:
|
||||
uv__signal_close((uv_signal_t*) handle);
|
||||
/* Signal handles may not be closed immediately. The signal code will */
|
||||
/* itself close uv__make_close_pending whenever appropriate. */
|
||||
/* Signal handles may not be closed immediately. The signal code will
|
||||
* itself close uv__make_close_pending whenever appropriate. */
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
@ -261,8 +261,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
|
||||
w = loop->watchers[fd];
|
||||
|
||||
if (w == NULL) {
|
||||
/* File descriptor that we've stopped watching, disarm it. */
|
||||
/* TODO batch up */
|
||||
/* File descriptor that we've stopped watching, disarm it.
|
||||
* TODO: batch up. */
|
||||
struct kevent events[1];
|
||||
|
||||
EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0);
|
||||
|
||||
@ -71,8 +71,8 @@ int uv_async_send(uv_async_t* handle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The user should make sure never to call uv_async_send to a closing */
|
||||
/* or closed handle. */
|
||||
/* The user should make sure never to call uv_async_send to a closing or
|
||||
* closed handle. */
|
||||
assert(!(handle->flags & UV__HANDLE_CLOSING));
|
||||
|
||||
if (!uv__atomic_exchange_set(&handle->async_sent)) {
|
||||
|
||||
@ -29,10 +29,10 @@
|
||||
/* Atomic set operation on char */
|
||||
#ifdef _MSC_VER /* MSVC */
|
||||
|
||||
/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less */
|
||||
/* efficient than InterlockedExchange, but InterlockedExchange8 does not */
|
||||
/* exist, and interlocked operations on larger targets might require the */
|
||||
/* target to be aligned. */
|
||||
/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less
|
||||
* efficient than InterlockedExchange, but InterlockedExchange8 does not exist,
|
||||
* and interlocked operations on larger targets might require the target to be
|
||||
* aligned. */
|
||||
#pragma intrinsic(_InterlockedOr8)
|
||||
|
||||
static char INLINE uv__atomic_exchange_set(char volatile* target) {
|
||||
|
||||
@ -46,8 +46,8 @@ void uv_fatal_error(const int errorno, const char* syscall) {
|
||||
errmsg = "Unknown error";
|
||||
}
|
||||
|
||||
/* FormatMessage messages include a newline character already, */
|
||||
/* so don't add another. */
|
||||
/* FormatMessage messages include a newline character already, so don't add
|
||||
* another. */
|
||||
if (syscall) {
|
||||
fprintf(stderr, "%s: (%d) %s", syscall, errorno, errmsg);
|
||||
} else {
|
||||
|
||||
43
src/win/fs.c
43
src/win/fs.c
@ -326,12 +326,11 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
|
||||
reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength /
|
||||
sizeof(WCHAR);
|
||||
|
||||
/* Real symlinks can contain pretty much everything, but the only thing */
|
||||
/* we really care about is undoing the implicit conversion to an NT */
|
||||
/* namespaced path that CreateSymbolicLink will perform on absolute */
|
||||
/* paths. If the path is win32-namespaced then the user must have */
|
||||
/* explicitly made it so, and we better just return the unmodified */
|
||||
/* reparse data. */
|
||||
/* Real symlinks can contain pretty much everything, but the only thing we
|
||||
* really care about is undoing the implicit conversion to an NT namespaced
|
||||
* path that CreateSymbolicLink will perform on absolute paths. If the path
|
||||
* is win32-namespaced then the user must have explicitly made it so, and
|
||||
* we better just return the unmodified reparse data. */
|
||||
if (w_target_len >= 4 &&
|
||||
w_target[0] == L'\\' &&
|
||||
w_target[1] == L'?' &&
|
||||
@ -352,8 +351,8 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
|
||||
(w_target[5] == L'N' || w_target[5] == L'n') &&
|
||||
(w_target[6] == L'C' || w_target[6] == L'c') &&
|
||||
w_target[7] == L'\\') {
|
||||
/* \??\UNC\<server>\<share>\ - make sure the final path looks like */
|
||||
/* \\<server>\<share>\ */
|
||||
/* \??\UNC\<server>\<share>\ - make sure the final path looks like
|
||||
* \\<server>\<share>\ */
|
||||
w_target += 6;
|
||||
w_target[0] = L'\\';
|
||||
w_target_len -= 6;
|
||||
@ -368,11 +367,11 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
|
||||
w_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength /
|
||||
sizeof(WCHAR);
|
||||
|
||||
/* Only treat junctions that look like \??\<drive>:\ as symlink. */
|
||||
/* Junctions can also be used as mount points, like \??\Volume{<guid>}, */
|
||||
/* but that's confusing for programs since they wouldn't be able to */
|
||||
/* actually understand such a path when returned by uv_readlink(). */
|
||||
/* UNC paths are never valid for junctions so we don't care about them. */
|
||||
/* Only treat junctions that look like \??\<drive>:\ as symlink. Junctions
|
||||
* can also be used as mount points, like \??\Volume{<guid>}, but that's
|
||||
* confusing for programs since they wouldn't be able to actually
|
||||
* understand such a path when returned by uv_readlink(). UNC paths are
|
||||
* never valid for junctions so we don't care about them. */
|
||||
if (!(w_target_len >= 6 &&
|
||||
w_target[0] == L'\\' &&
|
||||
w_target[1] == L'?' &&
|
||||
@ -409,8 +408,8 @@ void fs__open(uv_fs_t* req) {
|
||||
int fd, current_umask;
|
||||
int flags = req->fs.info.file_flags;
|
||||
|
||||
/* Obtain the active umask. umask() never fails and returns the previous */
|
||||
/* umask. */
|
||||
/* Obtain the active umask. umask() never fails and returns the previous
|
||||
* umask. */
|
||||
current_umask = umask(0);
|
||||
umask(current_umask);
|
||||
|
||||
@ -530,8 +529,8 @@ void fs__open(uv_fs_t* req) {
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_FILE_EXISTS && (flags & UV_FS_O_CREAT) &&
|
||||
!(flags & UV_FS_O_EXCL)) {
|
||||
/* Special case: when ERROR_FILE_EXISTS happens and UV_FS_O_CREAT was */
|
||||
/* specified, it means the path referred to a directory. */
|
||||
/* Special case: when ERROR_FILE_EXISTS happens and UV_FS_O_CREAT was
|
||||
* specified, it means the path referred to a directory. */
|
||||
SET_REQ_UV_ERROR(req, UV_EISDIR, error);
|
||||
} else {
|
||||
SET_REQ_WIN32_ERROR(req, GetLastError());
|
||||
@ -756,9 +755,9 @@ void fs__unlink(uv_fs_t* req) {
|
||||
}
|
||||
|
||||
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
/* Do not allow deletion of directories, unless it is a symlink. When */
|
||||
/* the path refers to a non-symlink directory, report EPERM as mandated */
|
||||
/* by POSIX.1. */
|
||||
/* Do not allow deletion of directories, unless it is a symlink. When the
|
||||
* path refers to a non-symlink directory, report EPERM as mandated by
|
||||
* POSIX.1. */
|
||||
|
||||
/* Check if it is a reparse point. If it's not, it's a normal directory. */
|
||||
if (!(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
|
||||
@ -767,8 +766,8 @@ void fs__unlink(uv_fs_t* req) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Read the reparse point and check if it is a valid symlink. */
|
||||
/* If not, don't unlink. */
|
||||
/* Read the reparse point and check if it is a valid symlink. If not, don't
|
||||
* unlink. */
|
||||
if (fs__readlink_handle(handle, NULL, NULL) < 0) {
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_SYMLINK_NOT_SUPPORTED)
|
||||
|
||||
@ -71,8 +71,8 @@ int uv__getaddrinfo_translate_error(int sys_err) {
|
||||
#endif
|
||||
|
||||
|
||||
/* adjust size value to be multiple of 4. Use to keep pointer aligned */
|
||||
/* Do we need different versions of this for different architectures? */
|
||||
/* Adjust size value to be multiple of 4. Use to keep pointer aligned.
|
||||
* Do we need different versions of this for different architectures? */
|
||||
#define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2)
|
||||
|
||||
#ifndef NDIS_IF_MAX_STRING_SIZE
|
||||
@ -124,8 +124,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
|
||||
}
|
||||
|
||||
if (req->retcode == 0) {
|
||||
/* convert addrinfoW to addrinfo */
|
||||
/* first calculate required length */
|
||||
/* Convert addrinfoW to addrinfo. First calculate required length. */
|
||||
addrinfow_ptr = req->addrinfow;
|
||||
while (addrinfow_ptr != NULL) {
|
||||
addrinfo_len += addrinfo_struct_len +
|
||||
@ -313,8 +312,8 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
||||
/* save alloc_ptr now so we can free if error */
|
||||
req->alloc = (void*)alloc_ptr;
|
||||
|
||||
/* convert node string to UTF16 into allocated memory and save pointer in */
|
||||
/* the request. */
|
||||
/* Convert node string to UTF16 into allocated memory and save pointer in the
|
||||
* request. */
|
||||
if (node != NULL) {
|
||||
req->node = (WCHAR*)alloc_ptr;
|
||||
if (MultiByteToWideChar(CP_UTF8,
|
||||
@ -331,8 +330,8 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
||||
req->node = NULL;
|
||||
}
|
||||
|
||||
/* convert service string to UTF16 into allocated memory and save pointer */
|
||||
/* in the req. */
|
||||
/* Convert service string to UTF16 into allocated memory and save pointer in
|
||||
* the req. */
|
||||
if (service != NULL) {
|
||||
req->service = (WCHAR*)alloc_ptr;
|
||||
if (MultiByteToWideChar(CP_UTF8,
|
||||
|
||||
@ -164,10 +164,10 @@ INLINE static void uv_process_endgames(uv_loop_t* loop) {
|
||||
|
||||
INLINE static HANDLE uv__get_osfhandle(int fd)
|
||||
{
|
||||
/* _get_osfhandle() raises an assert in debug builds if the FD is invalid. */
|
||||
/* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE */
|
||||
/* for invalid FDs in release builds (or if you let the assert continue). */
|
||||
/* So this wrapper function disables asserts when calling _get_osfhandle. */
|
||||
/* _get_osfhandle() raises an assert in debug builds if the FD is invalid.
|
||||
* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE for
|
||||
* invalid FDs in release builds (or if you let the assert continue). So this
|
||||
* wrapper function disables asserts when calling _get_osfhandle. */
|
||||
|
||||
HANDLE handle;
|
||||
UV_BEGIN_DISABLE_CRT_ASSERT();
|
||||
|
||||
@ -52,8 +52,8 @@ static char uv_zero_[] = "";
|
||||
/* Null uv_buf_t */
|
||||
static const uv_buf_t uv_null_buf_ = { 0, NULL };
|
||||
|
||||
/* The timeout that the pipe will wait for the remote end to write data */
|
||||
/* when the local ends wants to shut it down. */
|
||||
/* The timeout that the pipe will wait for the remote end to write data when
|
||||
* the local ends wants to shut it down. */
|
||||
static const int64_t eof_timeout = 50; /* ms */
|
||||
|
||||
static const int default_pending_pipe_instances = 4;
|
||||
@ -595,8 +595,8 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
|
||||
loop = handle->loop;
|
||||
assert(loop);
|
||||
|
||||
/* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. */
|
||||
/* We wait for the pipe to become available with WaitNamedPipe. */
|
||||
/* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. We wait
|
||||
* for the pipe to become available with WaitNamedPipe. */
|
||||
while (WaitNamedPipeW(handle->name, 30000)) {
|
||||
/* The pipe is now available, try to connect. */
|
||||
pipeHandle = open_named_pipe(handle->name, &duplex_flags);
|
||||
@ -748,8 +748,8 @@ void uv__pipe_stop_read(uv_pipe_t* handle) {
|
||||
}
|
||||
|
||||
|
||||
/* Cleans up uv_pipe_t (server or connection) and all resources associated */
|
||||
/* with it. */
|
||||
/* Cleans up uv_pipe_t (server or connection) and all resources associated with
|
||||
* it. */
|
||||
void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle) {
|
||||
int i;
|
||||
HANDLE pipeHandle;
|
||||
@ -889,8 +889,8 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) {
|
||||
} else {
|
||||
pipe_client = (uv_pipe_t*)client;
|
||||
|
||||
/* Find a connection instance that has been connected, but not yet */
|
||||
/* accepted. */
|
||||
/* Find a connection instance that has been connected, but not yet
|
||||
* accepted. */
|
||||
req = server->pipe.serv.pending_accepts;
|
||||
|
||||
if (!req) {
|
||||
@ -1169,8 +1169,8 @@ int uv_pipe_read_start(uv_pipe_t* handle,
|
||||
handle->read_cb = read_cb;
|
||||
handle->alloc_cb = alloc_cb;
|
||||
|
||||
/* If reading was stopped and then started again, there could still be a */
|
||||
/* read request pending. */
|
||||
/* If reading was stopped and then started again, there could still be a read
|
||||
* request pending. */
|
||||
if (!(handle->flags & UV_HANDLE_READ_PENDING))
|
||||
uv_pipe_queue_read(loop, handle);
|
||||
|
||||
@ -1505,8 +1505,8 @@ int uv_pipe_write2(uv_loop_t* loop,
|
||||
|
||||
static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
|
||||
uv_buf_t buf) {
|
||||
/* If there is an eof timer running, we don't need it any more, */
|
||||
/* so discard it. */
|
||||
/* If there is an eof timer running, we don't need it any more, so discard
|
||||
* it. */
|
||||
eof_timer_destroy(handle);
|
||||
|
||||
handle->flags &= ~UV_HANDLE_READABLE;
|
||||
@ -1518,8 +1518,8 @@ static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
|
||||
|
||||
static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error,
|
||||
uv_buf_t buf) {
|
||||
/* If there is an eof timer running, we don't need it any more, */
|
||||
/* so discard it. */
|
||||
/* If there is an eof timer running, we don't need it any more, so discard
|
||||
* it. */
|
||||
eof_timer_destroy(handle);
|
||||
|
||||
uv_read_stop((uv_stream_t*) handle);
|
||||
@ -1806,19 +1806,19 @@ void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle,
|
||||
UNREGISTER_HANDLE_REQ(loop, handle, req);
|
||||
|
||||
if (handle->flags & UV_HANDLE_READABLE) {
|
||||
/* Initialize and optionally start the eof timer. Only do this if the */
|
||||
/* pipe is readable and we haven't seen EOF come in ourselves. */
|
||||
/* Initialize and optionally start the eof timer. Only do this if the pipe
|
||||
* is readable and we haven't seen EOF come in ourselves. */
|
||||
eof_timer_init(handle);
|
||||
|
||||
/* If reading start the timer right now. */
|
||||
/* Otherwise uv_pipe_queue_read will start it. */
|
||||
/* If reading start the timer right now. Otherwise uv_pipe_queue_read will
|
||||
* start it. */
|
||||
if (handle->flags & UV_HANDLE_READ_PENDING) {
|
||||
eof_timer_start(handle);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* This pipe is not readable. We can just close it to let the other end */
|
||||
/* know that we're done writing. */
|
||||
/* This pipe is not readable. We can just close it to let the other end
|
||||
* know that we're done writing. */
|
||||
close_pipe(handle);
|
||||
}
|
||||
|
||||
@ -1869,17 +1869,16 @@ static void eof_timer_cb(uv_timer_t* timer) {
|
||||
|
||||
assert(pipe->type == UV_NAMED_PIPE);
|
||||
|
||||
/* This should always be true, since we start the timer only */
|
||||
/* in uv_pipe_queue_read after successfully calling ReadFile, */
|
||||
/* or in uv_process_pipe_shutdown_req if a read is pending, */
|
||||
/* and we always immediately stop the timer in */
|
||||
/* uv_process_pipe_read_req. */
|
||||
/* This should always be true, since we start the timer only in
|
||||
* uv_pipe_queue_read after successfully calling ReadFile, or in
|
||||
* uv_process_pipe_shutdown_req if a read is pending, and we always
|
||||
* immediately stop the timer in uv_process_pipe_read_req. */
|
||||
assert(pipe->flags & UV_HANDLE_READ_PENDING);
|
||||
|
||||
/* If there are many packets coming off the iocp then the timer callback */
|
||||
/* may be called before the read request is coming off the queue. */
|
||||
/* Therefore we check here if the read request has completed but will */
|
||||
/* be processed later. */
|
||||
/* If there are many packets coming off the iocp then the timer callback may
|
||||
* be called before the read request is coming off the queue. Therefore we
|
||||
* check here if the read request has completed but will be processed later.
|
||||
*/
|
||||
if ((pipe->flags & UV_HANDLE_READ_PENDING) &&
|
||||
HasOverlappedIoCompleted(&pipe->read_req.u.io.overlapped)) {
|
||||
return;
|
||||
@ -1888,12 +1887,12 @@ static void eof_timer_cb(uv_timer_t* timer) {
|
||||
/* Force both ends off the pipe. */
|
||||
close_pipe(pipe);
|
||||
|
||||
/* Stop reading, so the pending read that is going to fail will */
|
||||
/* not be reported to the user. */
|
||||
/* Stop reading, so the pending read that is going to fail will not be
|
||||
* reported to the user. */
|
||||
uv_read_stop((uv_stream_t*) pipe);
|
||||
|
||||
/* Report the eof and update flags. This will get reported even if the */
|
||||
/* user stopped reading in the meantime. TODO: is that okay? */
|
||||
/* Report the eof and update flags. This will get reported even if the user
|
||||
* stopped reading in the meantime. TODO: is that okay? */
|
||||
uv_pipe_read_eof(loop, pipe, uv_null_buf_);
|
||||
}
|
||||
|
||||
|
||||
@ -91,16 +91,16 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
|
||||
handle->mask_events_1 = handle->events;
|
||||
handle->mask_events_2 = 0;
|
||||
} else {
|
||||
/* Just wait until there's an unsubmitted req. */
|
||||
/* This will happen almost immediately as one of the 2 outstanding */
|
||||
/* requests is about to return. When this happens, */
|
||||
/* uv__fast_poll_process_poll_req will be called, and the pending */
|
||||
/* events, if needed, will be processed in a subsequent request. */
|
||||
/* Just wait until there's an unsubmitted req. This will happen almost
|
||||
* immediately as one of the 2 outstanding requests is about to return.
|
||||
* When this happens, uv__fast_poll_process_poll_req will be called, and
|
||||
* the pending events, if needed, will be processed in a subsequent
|
||||
* request. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Setting Exclusive to TRUE makes the other poll request return if there */
|
||||
/* is any. */
|
||||
/* Setting Exclusive to TRUE makes the other poll request return if there is
|
||||
* any. */
|
||||
afd_poll_info->Exclusive = TRUE;
|
||||
afd_poll_info->NumberOfHandles = 1;
|
||||
afd_poll_info->Timeout.QuadPart = INT64_MAX;
|
||||
@ -257,8 +257,8 @@ static int uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
|
||||
uv_want_endgame(loop, (uv_handle_t*) handle);
|
||||
return 0;
|
||||
} else {
|
||||
/* Cancel outstanding poll requests by executing another, unique poll */
|
||||
/* request that forces the outstanding ones to return. */
|
||||
/* Cancel outstanding poll requests by executing another, unique poll
|
||||
* request that forces the outstanding ones to return. */
|
||||
return uv__fast_poll_cancel_poll_req(loop, handle);
|
||||
}
|
||||
}
|
||||
@ -316,9 +316,8 @@ static SOCKET uv__fast_poll_get_peer_socket(uv_loop_t* loop,
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
/* If we didn't (try) to create a peer socket yet, try to make one. Don't */
|
||||
/* try again if the peer socket creation failed earlier for the same */
|
||||
/* protocol. */
|
||||
/* If we didn't (try) to create a peer socket yet, try to make one. Don't try
|
||||
* again if the peer socket creation failed earlier for the same protocol. */
|
||||
peer_socket = loop->poll_peer_sockets[index];
|
||||
if (peer_socket == 0) {
|
||||
peer_socket = uv__fast_poll_create_peer_socket(loop->iocp, protocol_info);
|
||||
@ -357,8 +356,8 @@ static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) {
|
||||
efds.fd_count = 0;
|
||||
}
|
||||
|
||||
/* Make the select() time out after 3 minutes. If select() hangs because */
|
||||
/* the user closed the socket, we will at least not hang indefinitely. */
|
||||
/* Make the select() time out after 3 minutes. If select() hangs because the
|
||||
* user closed the socket, we will at least not hang indefinitely. */
|
||||
timeout.tv_sec = 3 * 60;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
@ -522,10 +521,10 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
|
||||
if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR)
|
||||
return uv_translate_sys_error(WSAGetLastError());
|
||||
|
||||
/* Try to obtain a base handle for the socket. This increases this chances */
|
||||
/* that we find an AFD handle and are able to use the fast poll mechanism. */
|
||||
/* This will always fail on windows XP/2k3, since they don't support the */
|
||||
/* SIO_BASE_HANDLE ioctl. */
|
||||
/* Try to obtain a base handle for the socket. This increases this chances that
|
||||
* we find an AFD handle and are able to use the fast poll mechanism. This will
|
||||
* always fail on windows XP/2k3, since they don't support the. SIO_BASE_HANDLE
|
||||
* ioctl. */
|
||||
#ifndef NDEBUG
|
||||
base_socket = INVALID_SOCKET;
|
||||
#endif
|
||||
@ -557,9 +556,9 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
|
||||
return uv_translate_sys_error(WSAGetLastError());
|
||||
}
|
||||
|
||||
/* Get the peer socket that is needed to enable fast poll. If the returned */
|
||||
/* value is NULL, the protocol is not implemented by MSAFD and we'll have */
|
||||
/* to use slow mode. */
|
||||
/* Get the peer socket that is needed to enable fast poll. If the returned
|
||||
* value is NULL, the protocol is not implemented by MSAFD and we'll have to
|
||||
* use slow mode. */
|
||||
peer_socket = uv__fast_poll_get_peer_socket(loop, &protocol_info);
|
||||
|
||||
if (peer_socket != INVALID_SOCKET) {
|
||||
|
||||
@ -105,10 +105,9 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
|
||||
int err;
|
||||
|
||||
if (flags & UV_READABLE_PIPE) {
|
||||
/* The server needs inbound access too, otherwise CreateNamedPipe() */
|
||||
/* won't give us the FILE_READ_ATTRIBUTES permission. We need that to */
|
||||
/* probe the state of the write buffer when we're trying to shutdown */
|
||||
/* the pipe. */
|
||||
/* The server needs inbound access too, otherwise CreateNamedPipe() won't
|
||||
* give us the FILE_READ_ATTRIBUTES permission. We need that to probe the
|
||||
* state of the write buffer when we're trying to shutdown the pipe. */
|
||||
server_access |= PIPE_ACCESS_OUTBOUND | PIPE_ACCESS_INBOUND;
|
||||
client_access |= GENERIC_READ | FILE_WRITE_ATTRIBUTES;
|
||||
}
|
||||
@ -160,8 +159,8 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do a blocking ConnectNamedPipe. This should not block because we have */
|
||||
/* both ends of the pipe created. */
|
||||
/* Do a blocking ConnectNamedPipe. This should not block because we have both
|
||||
* ends of the pipe created. */
|
||||
if (!ConnectNamedPipe(server_pipe->handle, NULL)) {
|
||||
if (GetLastError() != ERROR_PIPE_CONNECTED) {
|
||||
err = GetLastError();
|
||||
@ -195,11 +194,11 @@ static int uv__duplicate_handle(uv_loop_t* loop, HANDLE handle, HANDLE* dup) {
|
||||
HANDLE current_process;
|
||||
|
||||
|
||||
/* _get_osfhandle will sometimes return -2 in case of an error. This seems */
|
||||
/* to happen when fd <= 2 and the process' corresponding stdio handle is */
|
||||
/* set to NULL. Unfortunately DuplicateHandle will happily duplicate */
|
||||
/* (HANDLE) -2, so this situation goes unnoticed until someone tries to */
|
||||
/* use the duplicate. Therefore we filter out known-invalid handles here. */
|
||||
/* _get_osfhandle will sometimes return -2 in case of an error. This seems to
|
||||
* happen when fd <= 2 and the process' corresponding stdio handle is set to
|
||||
* NULL. Unfortunately DuplicateHandle will happily duplicate (HANDLE) -2, so
|
||||
* this situation goes unnoticed until someone tries to use the duplicate.
|
||||
* Therefore we filter out known-invalid handles here. */
|
||||
if (handle == INVALID_HANDLE_VALUE ||
|
||||
handle == NULL ||
|
||||
handle == (HANDLE) -2) {
|
||||
@ -285,8 +284,8 @@ int uv__stdio_create(uv_loop_t* loop,
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
/* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can */
|
||||
/* clean up on failure. */
|
||||
/* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can clean
|
||||
* up on failure. */
|
||||
CHILD_STDIO_COUNT(buffer) = count;
|
||||
for (i = 0; i < count; i++) {
|
||||
CHILD_STDIO_CRT_FLAGS(buffer, i) = 0;
|
||||
@ -304,12 +303,12 @@ int uv__stdio_create(uv_loop_t* loop,
|
||||
switch (fdopt.flags & (UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD |
|
||||
UV_INHERIT_STREAM)) {
|
||||
case UV_IGNORE:
|
||||
/* Starting a process with no stdin/stout/stderr can confuse it. */
|
||||
/* So no matter what the user specified, we make sure the first */
|
||||
/* three FDs are always open in their typical modes, e.g. stdin */
|
||||
/* be readable and stdout/err should be writable. For FDs > 2, don't */
|
||||
/* do anything - all handles in the stdio buffer are initialized with */
|
||||
/* INVALID_HANDLE_VALUE, which should be okay. */
|
||||
/* Starting a process with no stdin/stout/stderr can confuse it. So no
|
||||
* matter what the user specified, we make sure the first three FDs are
|
||||
* always open in their typical modes, e. g. stdin be readable and
|
||||
* stdout/err should be writable. For FDs > 2, don't do anything - all
|
||||
* handles in the stdio buffer are initialized with.
|
||||
* INVALID_HANDLE_VALUE, which should be okay. */
|
||||
if (i <= 2) {
|
||||
DWORD access = (i == 0) ? FILE_GENERIC_READ :
|
||||
FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES;
|
||||
@ -324,14 +323,14 @@ int uv__stdio_create(uv_loop_t* loop,
|
||||
break;
|
||||
|
||||
case UV_CREATE_PIPE: {
|
||||
/* Create a pair of two connected pipe ends; one end is turned into */
|
||||
/* an uv_pipe_t for use by the parent. The other one is given to */
|
||||
/* the child. */
|
||||
/* Create a pair of two connected pipe ends; one end is turned into an
|
||||
* uv_pipe_t for use by the parent. The other one is given to the
|
||||
* child. */
|
||||
uv_pipe_t* parent_pipe = (uv_pipe_t*) fdopt.data.stream;
|
||||
HANDLE child_pipe = INVALID_HANDLE_VALUE;
|
||||
|
||||
/* Create a new, connected pipe pair. stdio[i].stream should point */
|
||||
/* to an uninitialized, but not connected pipe handle. */
|
||||
/* Create a new, connected pipe pair. stdio[i]. stream should point to
|
||||
* an uninitialized, but not connected pipe handle. */
|
||||
assert(fdopt.data.stream->type == UV_NAMED_PIPE);
|
||||
assert(!(fdopt.data.stream->flags & UV_HANDLE_CONNECTION));
|
||||
assert(!(fdopt.data.stream->flags & UV_HANDLE_PIPESERVER));
|
||||
@ -355,8 +354,8 @@ int uv__stdio_create(uv_loop_t* loop,
|
||||
/* Make an inheritable duplicate of the handle. */
|
||||
err = uv__duplicate_fd(loop, fdopt.data.fd, &child_handle);
|
||||
if (err) {
|
||||
/* If fdopt.data.fd is not valid and fd <= 2, then ignore the */
|
||||
/* error. */
|
||||
/* If fdopt. data. fd is not valid and fd <= 2, then ignore the
|
||||
* error. */
|
||||
if (fdopt.data.fd <= 2 && err == ERROR_INVALID_HANDLE) {
|
||||
CHILD_STDIO_CRT_FLAGS(buffer, i) = 0;
|
||||
CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE;
|
||||
@ -419,8 +418,8 @@ int uv__stdio_create(uv_loop_t* loop,
|
||||
|
||||
if (stream_handle == NULL ||
|
||||
stream_handle == INVALID_HANDLE_VALUE) {
|
||||
/* The handle is already closed, or not yet created, or the */
|
||||
/* stream type is not supported. */
|
||||
/* The handle is already closed, or not yet created, or the stream
|
||||
* type is not supported. */
|
||||
err = ERROR_NOT_SUPPORTED;
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -360,8 +360,8 @@ static WCHAR* search_path(const WCHAR *file,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find the start of the filename so we can split the directory from the */
|
||||
/* name. */
|
||||
/* Find the start of the filename so we can split the directory from the
|
||||
* name. */
|
||||
for (file_name_start = (WCHAR*)file + file_len;
|
||||
file_name_start > file
|
||||
&& file_name_start[-1] != L'\\'
|
||||
@ -556,8 +556,8 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) {
|
||||
arg_count++;
|
||||
}
|
||||
|
||||
/* Adjust for potential quotes. Also assume the worst-case scenario */
|
||||
/* that every character needs escaping, so we need twice as much space. */
|
||||
/* Adjust for potential quotes. Also assume the worst-case scenario that
|
||||
* every character needs escaping, so we need twice as much space. */
|
||||
dst_len = dst_len * 2 + arg_count * 2;
|
||||
|
||||
/* Allocate buffer for the final command line. */
|
||||
@ -870,8 +870,8 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) {
|
||||
assert(handle->exit_cb_pending);
|
||||
handle->exit_cb_pending = 0;
|
||||
|
||||
/* If we're closing, don't call the exit callback. Just schedule a close */
|
||||
/* callback now. */
|
||||
/* If we're closing, don't call the exit callback. Just schedule a close
|
||||
* callback now. */
|
||||
if (handle->flags & UV__HANDLE_CLOSING) {
|
||||
uv_want_endgame(loop, (uv_handle_t*) handle);
|
||||
return;
|
||||
@ -883,8 +883,8 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) {
|
||||
handle->wait_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* Set the handle to inactive: no callbacks will be made after the exit */
|
||||
/* callback.*/
|
||||
/* Set the handle to inactive: no callbacks will be made after the exit
|
||||
* callback. */
|
||||
uv__handle_stop(handle);
|
||||
|
||||
if (GetExitCodeProcess(handle->process_handle, &status)) {
|
||||
@ -905,8 +905,8 @@ void uv_process_close(uv_loop_t* loop, uv_process_t* handle) {
|
||||
uv__handle_closing(handle);
|
||||
|
||||
if (handle->wait_handle != INVALID_HANDLE_VALUE) {
|
||||
/* This blocks until either the wait was cancelled, or the callback has */
|
||||
/* completed. */
|
||||
/* This blocks until either the wait was cancelled, or the callback has
|
||||
* completed. */
|
||||
BOOL r = UnregisterWaitEx(handle->wait_handle, INVALID_HANDLE_VALUE);
|
||||
if (!r) {
|
||||
/* This should never happen, and if it happens, we can't recover... */
|
||||
@ -1109,14 +1109,13 @@ int uv_spawn(uv_loop_t* loop,
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Spawn succeeded */
|
||||
/* Beyond this point, failure is reported asynchronously. */
|
||||
/* Spawn succeeded. Beyond this point, failure is reported asynchronously. */
|
||||
|
||||
process->process_handle = info.hProcess;
|
||||
process->pid = info.dwProcessId;
|
||||
|
||||
/* If the process isn't spawned as detached, assign to the global job */
|
||||
/* object so windows will kill it when the parent process dies. */
|
||||
/* If the process isn't spawned as detached, assign to the global job object
|
||||
* so windows will kill it when the parent process dies. */
|
||||
if (!(options->flags & UV_PROCESS_DETACHED)) {
|
||||
uv_once(&uv_global_job_handle_init_guard_, uv__init_global_job_handle);
|
||||
|
||||
@ -1159,8 +1158,8 @@ int uv_spawn(uv_loop_t* loop,
|
||||
|
||||
assert(!err);
|
||||
|
||||
/* Make the handle active. It will remain active until the exit callback */
|
||||
/* is made or the handle is closed, whichever happens first. */
|
||||
/* Make the handle active. It will remain active until the exit callback is
|
||||
* made or the handle is closed, whichever happens first. */
|
||||
uv__handle_start(process);
|
||||
|
||||
/* Cleanup, whether we succeeded or failed. */
|
||||
@ -1191,16 +1190,16 @@ static int uv__kill(HANDLE process_handle, int signum) {
|
||||
case SIGTERM:
|
||||
case SIGKILL:
|
||||
case SIGINT: {
|
||||
/* Unconditionally terminate the process. On Windows, killed processes */
|
||||
/* normally return 1. */
|
||||
/* Unconditionally terminate the process. On Windows, killed processes
|
||||
* normally return 1. */
|
||||
DWORD status;
|
||||
int err;
|
||||
|
||||
if (TerminateProcess(process_handle, 1))
|
||||
return 0;
|
||||
|
||||
/* If the process already exited before TerminateProcess was called, */
|
||||
/* TerminateProcess will fail with ERROR_ACCESS_DENIED. */
|
||||
/* If the process already exited before TerminateProcess was called,.
|
||||
* TerminateProcess will fail with ERROR_ACCESS_DENIED. */
|
||||
err = GetLastError();
|
||||
if (err == ERROR_ACCESS_DENIED &&
|
||||
GetExitCodeProcess(process_handle, &status) &&
|
||||
|
||||
@ -47,13 +47,13 @@ void uv_signals_init(void) {
|
||||
|
||||
|
||||
static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) {
|
||||
/* Compare signums first so all watchers with the same signnum end up */
|
||||
/* adjacent. */
|
||||
/* Compare signums first so all watchers with the same signnum end up
|
||||
* adjacent. */
|
||||
if (w1->signum < w2->signum) return -1;
|
||||
if (w1->signum > w2->signum) return 1;
|
||||
|
||||
/* Sort by loop pointer, so we can easily look up the first item after */
|
||||
/* { .signum = x, .loop = NULL } */
|
||||
/* Sort by loop pointer, so we can easily look up the first item after
|
||||
* { .signum = x, .loop = NULL }. */
|
||||
if ((uintptr_t) w1->loop < (uintptr_t) w2->loop) return -1;
|
||||
if ((uintptr_t) w1->loop > (uintptr_t) w2->loop) return 1;
|
||||
|
||||
@ -118,10 +118,10 @@ static BOOL WINAPI uv__signal_control_handler(DWORD type) {
|
||||
|
||||
case CTRL_CLOSE_EVENT:
|
||||
if (uv__signal_dispatch(SIGHUP)) {
|
||||
/* Windows will terminate the process after the control handler */
|
||||
/* returns. After that it will just terminate our process. Therefore */
|
||||
/* block the signal handler so the main loop has some time to pick */
|
||||
/* up the signal and do something for a few seconds. */
|
||||
/* Windows will terminate the process after the control handler
|
||||
* returns. After that it will just terminate our process. Therefore
|
||||
* block the signal handler so the main loop has some time to pick up
|
||||
* the signal and do something for a few seconds. */
|
||||
Sleep(INFINITE);
|
||||
return TRUE;
|
||||
}
|
||||
@ -129,8 +129,8 @@ static BOOL WINAPI uv__signal_control_handler(DWORD type) {
|
||||
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
/* These signals are only sent to services. Services have their own */
|
||||
/* notification mechanism, so there's no point in handling these. */
|
||||
/* These signals are only sent to services. Services have their own
|
||||
* notification mechanism, so there's no point in handling these. */
|
||||
|
||||
default:
|
||||
/* We don't handle these. */
|
||||
@ -193,10 +193,10 @@ int uv__signal_start(uv_signal_t* handle,
|
||||
if (signum != SIGWINCH && (signum <= 0 || signum >= NSIG))
|
||||
return UV_EINVAL;
|
||||
|
||||
/* Short circuit: if the signal watcher is already watching {signum} don't */
|
||||
/* go through the process of deregistering and registering the handler. */
|
||||
/* Additionally, this avoids pending signals getting lost in the (small) */
|
||||
/* time frame that handle->signum == 0. */
|
||||
/* Short circuit: if the signal watcher is already watching {signum} don't go
|
||||
* through the process of deregistering and registering the handler.
|
||||
* Additionally, this avoids pending signals getting lost in the (small) time
|
||||
* frame that handle->signum == 0. */
|
||||
if (signum == handle->signum) {
|
||||
handle->signal_cb = signal_cb;
|
||||
return 0;
|
||||
@ -237,9 +237,9 @@ void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle,
|
||||
(volatile LONG*) &handle->pending_signum, 0);
|
||||
assert(dispatched_signum != 0);
|
||||
|
||||
/* Check if the pending signal equals the signum that we are watching for. */
|
||||
/* These can get out of sync when the handler is stopped and restarted */
|
||||
/* while the signal_req is pending. */
|
||||
/* Check if the pending signal equals the signum that we are watching for.
|
||||
* These can get out of sync when the handler is stopped and restarted while
|
||||
* the signal_req is pending. */
|
||||
if (dispatched_signum == handle->signum)
|
||||
handle->signal_cb(handle, dispatched_signum);
|
||||
|
||||
|
||||
@ -99,8 +99,8 @@ static int uv_tcp_set_socket(uv_loop_t* loop,
|
||||
if (!SetHandleInformation((HANDLE) socket, HANDLE_FLAG_INHERIT, 0))
|
||||
return GetLastError();
|
||||
|
||||
/* Associate it with the I/O completion port. */
|
||||
/* Use uv_handle_t pointer as completion key. */
|
||||
/* Associate it with the I/O completion port. Use uv_handle_t pointer as
|
||||
* completion key. */
|
||||
if (CreateIoCompletionPort((HANDLE)socket,
|
||||
loop->iocp,
|
||||
(ULONG_PTR)socket,
|
||||
@ -326,9 +326,9 @@ static int uv_tcp_try_bind(uv_tcp_t* handle,
|
||||
|
||||
on = (flags & UV_TCP_IPV6ONLY) != 0;
|
||||
|
||||
/* TODO: how to handle errors? This may fail if there is no ipv4 stack */
|
||||
/* available, or when run on XP/2003 which have no support for dualstack */
|
||||
/* sockets. For now we're silently ignoring the error. */
|
||||
/* TODO: how to handle errors? This may fail if there is no ipv4 stack
|
||||
* available, or when run on XP/2003 which have no support for dualstack
|
||||
* sockets. For now we're silently ignoring the error. */
|
||||
setsockopt(handle->socket,
|
||||
IPPROTO_IPV6,
|
||||
IPV6_V6ONLY,
|
||||
@ -626,9 +626,9 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
|
||||
uv_tcp_queue_accept(handle, req);
|
||||
}
|
||||
|
||||
/* Initialize other unused requests too, because uv_tcp_endgame */
|
||||
/* doesn't know how many requests were initialized, so it will */
|
||||
/* try to clean up {uv_simultaneous_server_accepts} requests. */
|
||||
/* Initialize other unused requests too, because uv_tcp_endgame doesn't
|
||||
* know how many requests were initialized, so it will try to clean up
|
||||
* {uv_simultaneous_server_accepts} requests. */
|
||||
for (i = simultaneous_accepts; i < uv_simultaneous_server_accepts; i++) {
|
||||
req = &handle->tcp.serv.accept_reqs[i];
|
||||
UV_REQ_INIT(req, UV_ACCEPT);
|
||||
@ -721,8 +721,8 @@ int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
|
||||
handle->alloc_cb = alloc_cb;
|
||||
INCREASE_ACTIVE_COUNT(loop, handle);
|
||||
|
||||
/* If reading was stopped and then started again, there could still be a */
|
||||
/* read request pending. */
|
||||
/* If reading was stopped and then started again, there could still be a read
|
||||
* request pending. */
|
||||
if (!(handle->flags & UV_HANDLE_READ_PENDING)) {
|
||||
if (handle->flags & UV_HANDLE_EMULATE_IOCP &&
|
||||
!handle->read_req.event_handle) {
|
||||
@ -965,8 +965,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
err = GET_REQ_SOCK_ERROR(req);
|
||||
|
||||
if (err == WSAECONNABORTED) {
|
||||
/*
|
||||
* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix.
|
||||
/* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix.
|
||||
*/
|
||||
err = WSAECONNRESET;
|
||||
}
|
||||
@ -1046,8 +1045,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
DECREASE_ACTIVE_COUNT(loop, handle);
|
||||
|
||||
if (err == WSAECONNABORTED) {
|
||||
/* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with */
|
||||
/* Unix. */
|
||||
/* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with
|
||||
* Unix. */
|
||||
err = WSAECONNRESET;
|
||||
}
|
||||
|
||||
@ -1119,10 +1118,9 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
|
||||
assert(handle->type == UV_TCP);
|
||||
|
||||
/* If handle->accepted_socket is not a valid socket, then */
|
||||
/* uv_queue_accept must have failed. This is a serious error. We stop */
|
||||
/* accepting connections and report this error to the connection */
|
||||
/* callback. */
|
||||
/* If handle->accepted_socket is not a valid socket, then uv_queue_accept
|
||||
* must have failed. This is a serious error. We stop accepting connections
|
||||
* and report this error to the connection callback. */
|
||||
if (req->accept_socket == INVALID_SOCKET) {
|
||||
if (handle->flags & UV_HANDLE_LISTENING) {
|
||||
handle->flags &= ~UV_HANDLE_LISTENING;
|
||||
@ -1147,9 +1145,9 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
handle->stream.serv.connection_cb((uv_stream_t*)handle, 0);
|
||||
}
|
||||
} else {
|
||||
/* Error related to accepted socket is ignored because the server */
|
||||
/* socket may still be healthy. If the server socket is broken */
|
||||
/* uv_queue_accept will detect it. */
|
||||
/* Error related to accepted socket is ignored because the server socket
|
||||
* may still be healthy. If the server socket is broken uv_queue_accept
|
||||
* will detect it. */
|
||||
closesocket(req->accept_socket);
|
||||
req->accept_socket = INVALID_SOCKET;
|
||||
if (handle->flags & UV_HANDLE_LISTENING) {
|
||||
@ -1346,8 +1344,8 @@ static int uv_tcp_try_cancel_io(uv_tcp_t* tcp) {
|
||||
non_ifs_lsp = (tcp->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 :
|
||||
uv_tcp_non_ifs_lsp_ipv4;
|
||||
|
||||
/* If there are non-ifs LSPs then try to obtain a base handle for the */
|
||||
/* socket. This will always fail on Windows XP/3k. */
|
||||
/* If there are non-ifs LSPs then try to obtain a base handle for the socket.
|
||||
* This will always fail on Windows XP/3k. */
|
||||
if (non_ifs_lsp) {
|
||||
DWORD bytes;
|
||||
if (WSAIoctl(socket,
|
||||
@ -1379,38 +1377,37 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) {
|
||||
int close_socket = 1;
|
||||
|
||||
if (tcp->flags & UV_HANDLE_READ_PENDING) {
|
||||
/* In order for winsock to do a graceful close there must not be any */
|
||||
/* any pending reads, or the socket must be shut down for writing */
|
||||
/* In order for winsock to do a graceful close there must not be any any
|
||||
* pending reads, or the socket must be shut down for writing */
|
||||
if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) {
|
||||
/* Just do shutdown on non-shared sockets, which ensures graceful close. */
|
||||
shutdown(tcp->socket, SD_SEND);
|
||||
|
||||
} else if (uv_tcp_try_cancel_io(tcp) == 0) {
|
||||
/* In case of a shared socket, we try to cancel all outstanding I/O, */
|
||||
/* If that works, don't close the socket yet - wait for the read req to */
|
||||
/* return and close the socket in uv_tcp_endgame. */
|
||||
/* In case of a shared socket, we try to cancel all outstanding I/O,. If
|
||||
* that works, don't close the socket yet - wait for the read req to
|
||||
* return and close the socket in uv_tcp_endgame. */
|
||||
close_socket = 0;
|
||||
|
||||
} else {
|
||||
/* When cancelling isn't possible - which could happen when an LSP is */
|
||||
/* present on an old Windows version, we will have to close the socket */
|
||||
/* with a read pending. That is not nice because trailing sent bytes */
|
||||
/* may not make it to the other side. */
|
||||
/* When cancelling isn't possible - which could happen when an LSP is
|
||||
* present on an old Windows version, we will have to close the socket
|
||||
* with a read pending. That is not nice because trailing sent bytes may
|
||||
* not make it to the other side. */
|
||||
}
|
||||
|
||||
} else if ((tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET) &&
|
||||
tcp->tcp.serv.accept_reqs != NULL) {
|
||||
/* Under normal circumstances closesocket() will ensure that all pending */
|
||||
/* accept reqs are canceled. However, when the socket is shared the */
|
||||
/* presence of another reference to the socket in another process will */
|
||||
/* keep the accept reqs going, so we have to ensure that these are */
|
||||
/* canceled. */
|
||||
/* Under normal circumstances closesocket() will ensure that all pending
|
||||
* accept reqs are canceled. However, when the socket is shared the
|
||||
* presence of another reference to the socket in another process will keep
|
||||
* the accept reqs going, so we have to ensure that these are canceled. */
|
||||
if (uv_tcp_try_cancel_io(tcp) != 0) {
|
||||
/* When cancellation is not possible, there is another option: we can */
|
||||
/* close the incoming sockets, which will also cancel the accept */
|
||||
/* operations. However this is not cool because we might inadvertently */
|
||||
/* close a socket that just accepted a new connection, which will */
|
||||
/* cause the connection to be aborted. */
|
||||
/* When cancellation is not possible, there is another option: we can
|
||||
* close the incoming sockets, which will also cancel the accept
|
||||
* operations. However this is not cool because we might inadvertently
|
||||
* close a socket that just accepted a new connection, which will cause
|
||||
* the connection to be aborted. */
|
||||
unsigned int i;
|
||||
for (i = 0; i < uv_simultaneous_server_accepts; i++) {
|
||||
uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i];
|
||||
|
||||
@ -69,8 +69,8 @@ static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) {
|
||||
guard->ran = 1;
|
||||
|
||||
} else {
|
||||
/* We lost the race. Destroy the event we created and wait for the */
|
||||
/* existing one to become signaled. */
|
||||
/* We lost the race. Destroy the event we created and wait for the existing
|
||||
* one to become signaled. */
|
||||
CloseHandle(created_event);
|
||||
result = WaitForSingleObject(existing_event, INFINITE);
|
||||
assert(result == WAIT_OBJECT_0);
|
||||
@ -526,13 +526,13 @@ static int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex,
|
||||
cond->fallback.waiters_count++;
|
||||
LeaveCriticalSection(&cond->fallback.waiters_count_lock);
|
||||
|
||||
/* It's ok to release the <mutex> here since Win32 manual-reset events */
|
||||
/* maintain state when used with <SetEvent>. This avoids the "lost wakeup" */
|
||||
/* bug. */
|
||||
/* It's ok to release the <mutex> here since Win32 manual-reset events
|
||||
* maintain state when used with <SetEvent>. This avoids the "lost wakeup"
|
||||
* bug. */
|
||||
uv_mutex_unlock(mutex);
|
||||
|
||||
/* Wait for either event to become signaled due to <uv_cond_signal> being */
|
||||
/* called or <uv_cond_broadcast> being called. */
|
||||
/* Wait for either event to become signaled due to <uv_cond_signal> being
|
||||
* called or <uv_cond_broadcast> being called. */
|
||||
result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds);
|
||||
|
||||
EnterCriticalSection(&cond->fallback.waiters_count_lock);
|
||||
@ -543,8 +543,8 @@ static int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex,
|
||||
|
||||
/* Some thread called <pthread_cond_broadcast>. */
|
||||
if (last_waiter) {
|
||||
/* We're the last waiter to be notified or to stop waiting, so reset the */
|
||||
/* the manual-reset event. */
|
||||
/* We're the last waiter to be notified or to stop waiting, so reset the
|
||||
* the manual-reset event. */
|
||||
ResetEvent(cond->fallback.broadcast_event);
|
||||
}
|
||||
|
||||
|
||||
127
src/win/tty.c
127
src/win/tty.c
@ -205,8 +205,8 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) {
|
||||
return uv_translate_sys_error(GetLastError());
|
||||
}
|
||||
|
||||
/* Obtain the tty_output_lock because the virtual window state is */
|
||||
/* shared between all uv_tty_t handles. */
|
||||
/* Obtain the tty_output_lock because the virtual window state is shared
|
||||
* between all uv_tty_t handles. */
|
||||
uv_sem_wait(&uv_tty_output_lock);
|
||||
|
||||
if (uv__vterm_state == UV_UNCHECKED)
|
||||
@ -484,8 +484,8 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) {
|
||||
bytes = MAX_INPUT_BUFFER_LENGTH;
|
||||
}
|
||||
|
||||
/* At last, unicode! */
|
||||
/* One utf-16 codeunit never takes more than 3 utf-8 codeunits to encode */
|
||||
/* At last, unicode! One utf-16 codeunit never takes more than 3 utf-8
|
||||
* codeunits to encode. */
|
||||
chars = bytes / 3;
|
||||
|
||||
status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS);
|
||||
@ -620,10 +620,10 @@ static const char* get_vt100_fn_key(DWORD code, char shift, char ctrl,
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
/* These mappings are the same as Cygwin's. Unmodified and alt-modified */
|
||||
/* keypad keys comply with linux console, modifiers comply with xterm */
|
||||
/* modifier usage. F1..f12 and shift-f1..f10 comply with linux console, */
|
||||
/* f6..f12 with and without modifiers comply with rxvt. */
|
||||
/* These mappings are the same as Cygwin's. Unmodified and alt-modified
|
||||
* keypad keys comply with linux console, modifiers comply with xterm
|
||||
* modifier usage. F1. f12 and shift-f1. f10 comply with linux console, f6.
|
||||
* f12 with and without modifiers comply with rxvt. */
|
||||
VK_CASE(VK_INSERT, "[2~", "[2;2~", "[2;5~", "[2;6~")
|
||||
VK_CASE(VK_END, "[4~", "[4;2~", "[4;5~", "[4;6~")
|
||||
VK_CASE(VK_DOWN, "[B", "[1;2B", "[1;5B", "[1;6B")
|
||||
@ -706,8 +706,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Windows sends a lot of events that we're not interested in, so buf */
|
||||
/* will be allocated on demand, when there's actually something to emit. */
|
||||
/* Windows sends a lot of events that we're not interested in, so buf will be
|
||||
* allocated on demand, when there's actually something to emit. */
|
||||
buf = uv_null_buf_;
|
||||
buf_used = 0;
|
||||
|
||||
@ -733,16 +733,16 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ignore keyup events, unless the left alt key was held and a valid */
|
||||
/* unicode character was emitted. */
|
||||
/* Ignore keyup events, unless the left alt key was held and a valid
|
||||
* unicode character was emitted. */
|
||||
if (!KEV.bKeyDown && !(((KEV.dwControlKeyState & LEFT_ALT_PRESSED) ||
|
||||
KEV.wVirtualKeyCode==VK_MENU) && KEV.uChar.UnicodeChar != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ignore keypresses to numpad number keys if the left alt is held */
|
||||
/* because the user is composing a character, or windows simulating */
|
||||
/* this. */
|
||||
/* Ignore keypresses to numpad number keys if the left alt is held
|
||||
* because the user is composing a character, or windows simulating this.
|
||||
*/
|
||||
if ((KEV.dwControlKeyState & LEFT_ALT_PRESSED) &&
|
||||
!(KEV.dwControlKeyState & ENHANCED_KEY) &&
|
||||
(KEV.wVirtualKeyCode == VK_INSERT ||
|
||||
@ -779,8 +779,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Prefix with \u033 if alt was held, but alt was not used as part */
|
||||
/* a compose sequence. */
|
||||
/* Prefix with \u033 if alt was held, but alt was not used as part a
|
||||
* compose sequence. */
|
||||
if ((KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
|
||||
&& !(KEV.dwControlKeyState & (LEFT_CTRL_PRESSED |
|
||||
RIGHT_CTRL_PRESSED)) && KEV.bKeyDown) {
|
||||
@ -818,8 +818,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
/* Whatever happened, the last character wasn't a high surrogate. */
|
||||
handle->tty.rd.last_utf16_high_surrogate = 0;
|
||||
|
||||
/* If the utf16 character(s) couldn't be converted something must */
|
||||
/* be wrong. */
|
||||
/* If the utf16 character(s) couldn't be converted something must be
|
||||
* wrong. */
|
||||
if (!char_len) {
|
||||
handle->flags &= ~UV_HANDLE_READING;
|
||||
DECREASE_ACTIVE_COUNT(loop, handle);
|
||||
@ -950,8 +950,7 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
|
||||
} else {
|
||||
if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) {
|
||||
/* Read successful */
|
||||
/* TODO: read unicode, convert to utf-8 */
|
||||
/* Read successful. TODO: read unicode, convert to utf-8 */
|
||||
DWORD bytes = req->u.io.overlapped.InternalHigh;
|
||||
handle->read_cb((uv_stream_t*) handle, bytes, &buf);
|
||||
} else {
|
||||
@ -975,9 +974,9 @@ void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
assert(handle->type == UV_TTY);
|
||||
assert(handle->flags & UV_HANDLE_TTY_READABLE);
|
||||
|
||||
/* If the read_line_buffer member is zero, it must have been an raw read. */
|
||||
/* Otherwise it was a line-buffered read. */
|
||||
/* FIXME: This is quite obscure. Use a flag or something. */
|
||||
/* If the read_line_buffer member is zero, it must have been an raw read.
|
||||
* Otherwise it was a line-buffered read. FIXME: This is quite obscure. Use a
|
||||
* flag or something. */
|
||||
if (handle->tty.rd.read_line_buffer.len == 0) {
|
||||
uv_process_tty_read_raw_req(loop, handle, req);
|
||||
} else {
|
||||
@ -999,14 +998,14 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
|
||||
handle->read_cb = read_cb;
|
||||
handle->alloc_cb = alloc_cb;
|
||||
|
||||
/* If reading was stopped and then started again, there could still be a */
|
||||
/* read request pending. */
|
||||
/* If reading was stopped and then started again, there could still be a read
|
||||
* request pending. */
|
||||
if (handle->flags & UV_HANDLE_READ_PENDING) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Maybe the user stopped reading half-way while processing key events. */
|
||||
/* Short-circuit if this could be the case. */
|
||||
/* Maybe the user stopped reading half-way while processing key events.
|
||||
* Short-circuit if this could be the case. */
|
||||
if (handle->tty.rd.last_key_len > 0) {
|
||||
SET_REQ_SUCCESS(&handle->read_req);
|
||||
uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req);
|
||||
@ -1033,8 +1032,8 @@ int uv_tty_read_stop(uv_tty_t* handle) {
|
||||
return 0;
|
||||
|
||||
if (handle->flags & UV_HANDLE_TTY_RAW) {
|
||||
/* Cancel raw read */
|
||||
/* Write some bullshit event to force the console wait to return. */
|
||||
/* Cancel raw read. Write some bullshit event to force the console wait to
|
||||
* return. */
|
||||
memset(&record, 0, sizeof record);
|
||||
if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) {
|
||||
return GetLastError();
|
||||
@ -1116,8 +1115,8 @@ static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) {
|
||||
uv_tty_virtual_offset = info->dwCursorPosition.Y;
|
||||
} else if (uv_tty_virtual_offset < info->dwCursorPosition.Y -
|
||||
uv_tty_virtual_height + 1) {
|
||||
/* If suddenly find the cursor outside of the virtual window, it must */
|
||||
/* have somehow scrolled. Update the virtual window offset. */
|
||||
/* If suddenly find the cursor outside of the virtual window, it must have
|
||||
* somehow scrolled. Update the virtual window offset. */
|
||||
uv_tty_virtual_offset = info->dwCursorPosition.Y -
|
||||
uv_tty_virtual_height + 1;
|
||||
}
|
||||
@ -1304,8 +1303,8 @@ static int uv_tty_clear(uv_tty_t* handle, int dir, char entire_screen,
|
||||
x2 = 0;
|
||||
x2r = 1;
|
||||
} else {
|
||||
/* Clear to end of row. We pretend the console is 65536 characters wide, */
|
||||
/* uv_tty_make_real_coord will clip it to the actual console width. */
|
||||
/* Clear to end of row. We pretend the console is 65536 characters wide,
|
||||
* uv_tty_make_real_coord will clip it to the actual console width. */
|
||||
x2 = 0xffff;
|
||||
x2r = 0;
|
||||
}
|
||||
@ -1613,8 +1612,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
const uv_buf_t bufs[],
|
||||
unsigned int nbufs,
|
||||
DWORD* error) {
|
||||
/* We can only write 8k characters at a time. Windows can't handle */
|
||||
/* much more characters in a single console write anyway. */
|
||||
/* We can only write 8k characters at a time. Windows can't handle much more
|
||||
* characters in a single console write anyway. */
|
||||
WCHAR utf16_buf[MAX_CONSOLE_CHAR];
|
||||
WCHAR* utf16_buffer;
|
||||
DWORD utf16_buf_used = 0;
|
||||
@ -1650,9 +1649,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
unsigned char previous_eol = handle->tty.wr.previous_eol;
|
||||
unsigned char ansi_parser_state = handle->tty.wr.ansi_parser_state;
|
||||
|
||||
/* Store the error here. If we encounter an error, stop trying to do i/o */
|
||||
/* but keep parsing the buffer so we leave the parser in a consistent */
|
||||
/* state. */
|
||||
/* Store the error here. If we encounter an error, stop trying to do i/o but
|
||||
* keep parsing the buffer so we leave the parser in a consistent state. */
|
||||
*error = ERROR_SUCCESS;
|
||||
|
||||
utf16_buffer = utf16_buf;
|
||||
@ -1700,9 +1698,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
for (j = 0; j < buf.len; j++) {
|
||||
unsigned char c = buf.base[j];
|
||||
|
||||
/* Run the character through the utf8 decoder We happily accept non */
|
||||
/* shortest form encodings and invalid code points - there's no real */
|
||||
/* harm that can be done. */
|
||||
/* Run the character through the utf8 decoder We happily accept non
|
||||
* shortest form encodings and invalid code points - there's no real harm
|
||||
* that can be done. */
|
||||
if (utf8_bytes_left == 0) {
|
||||
/* Read utf-8 start byte */
|
||||
DWORD first_zero_bit;
|
||||
@ -1742,8 +1740,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
/* Start byte where continuation was expected. */
|
||||
utf8_bytes_left = 0;
|
||||
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
|
||||
/* Patch buf offset so this character will be parsed again as a */
|
||||
/* start byte. */
|
||||
/* Patch buf offset so this character will be parsed again as a start
|
||||
* byte. */
|
||||
j--;
|
||||
}
|
||||
|
||||
@ -1776,8 +1774,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
case '_':
|
||||
case 'P':
|
||||
case ']':
|
||||
/* Not supported, but we'll have to parse until we see a stop */
|
||||
/* code, e.g. ESC \ or BEL. */
|
||||
/* Not supported, but we'll have to parse until we see a stop code,
|
||||
* e. g. ESC \ or BEL. */
|
||||
ansi_parser_state = ANSI_ST_CONTROL;
|
||||
continue;
|
||||
|
||||
@ -1859,8 +1857,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
continue;
|
||||
|
||||
} else {
|
||||
/* If ANSI_IN_ARG is not set, add another argument and */
|
||||
/* default it to 0. */
|
||||
/* If ANSI_IN_ARG is not set, add another argument and default it
|
||||
* to 0. */
|
||||
|
||||
/* Check for too many arguments */
|
||||
if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) {
|
||||
ansi_parser_state |= ANSI_IGNORE;
|
||||
@ -1874,9 +1873,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
|
||||
} else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) &&
|
||||
handle->tty.wr.ansi_csi_argc == 0) {
|
||||
/* Ignores '?' if it is the first character after CSI[ */
|
||||
/* This is an extension character from the VT100 codeset */
|
||||
/* that is supported and used by most ANSI terminals today. */
|
||||
/* Ignores '?' if it is the first character after CSI[. This is an
|
||||
* extension character from the VT100 codeset that is supported and
|
||||
* used by most ANSI terminals today. */
|
||||
continue;
|
||||
|
||||
} else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' &&
|
||||
@ -2006,8 +2005,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
continue;
|
||||
|
||||
} else {
|
||||
/* We don't support commands that use private mode characters or */
|
||||
/* intermediaries. Ignore the rest of the sequence. */
|
||||
/* We don't support commands that use private mode characters or
|
||||
* intermediaries. Ignore the rest of the sequence. */
|
||||
ansi_parser_state |= ANSI_IGNORE;
|
||||
continue;
|
||||
}
|
||||
@ -2020,8 +2019,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
}
|
||||
|
||||
} else if (ansi_parser_state & ANSI_ST_CONTROL) {
|
||||
/* Unsupported control code */
|
||||
/* Ignore everything until we see BEL or ESC \ */
|
||||
/* Unsupported control code.
|
||||
* Ignore everything until we see `BEL` or `ESC \`. */
|
||||
if (ansi_parser_state & ANSI_IN_STRING) {
|
||||
if (!(ansi_parser_state & ANSI_BACKSLASH_SEEN)) {
|
||||
if (utf8_codepoint == '"') {
|
||||
@ -2055,9 +2054,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
abort();
|
||||
}
|
||||
|
||||
/* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the */
|
||||
/* windows console doesn't really support UTF-16, so just emit the */
|
||||
/* replacement character. */
|
||||
/* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows
|
||||
* console doesn't really support UTF-16, so just emit the replacement
|
||||
* character. */
|
||||
if (utf8_codepoint > 0xffff) {
|
||||
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
|
||||
}
|
||||
@ -2071,10 +2070,10 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
utf16_buf[utf16_buf_used++] = L'\r';
|
||||
utf16_buf[utf16_buf_used++] = L'\n';
|
||||
} else if (utf8_codepoint == 0x0d && previous_eol == 0x0a) {
|
||||
/* \n was followed by \r; do not print the \r, since */
|
||||
/* the source was either \r\n\r (so the second \r is */
|
||||
/* redundant) or was \n\r (so the \n was processed */
|
||||
/* by the last case and an \r automatically inserted). */
|
||||
/* \n was followed by \r; do not print the \r, since the source was
|
||||
* either \r\n\r (so the second \r is redundant) or was \n\r (so the
|
||||
* \n was processed by the last case and an \r automatically
|
||||
* inserted). */
|
||||
} else {
|
||||
/* \r without \n; print \r as-is. */
|
||||
ENSURE_BUFFER_SPACE(1);
|
||||
@ -2224,8 +2223,8 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) {
|
||||
|
||||
if (handle->flags & UV__HANDLE_CLOSING &&
|
||||
handle->reqs_pending == 0) {
|
||||
/* The wait handle used for raw reading should be unregistered when the */
|
||||
/* wait callback runs. */
|
||||
/* The wait handle used for raw reading should be unregistered when the
|
||||
* wait callback runs. */
|
||||
assert(!(handle->flags & UV_HANDLE_TTY_READABLE) ||
|
||||
handle->tty.rd.read_raw_wait == NULL);
|
||||
|
||||
|
||||
@ -74,8 +74,8 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket,
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
/* Associate it with the I/O completion port. */
|
||||
/* Use uv_handle_t pointer as completion key. */
|
||||
/* Associate it with the I/O completion port. Use uv_handle_t pointer as
|
||||
* completion key. */
|
||||
if (CreateIoCompletionPort((HANDLE)socket,
|
||||
loop->iocp,
|
||||
(ULONG_PTR)socket,
|
||||
@ -84,11 +84,11 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket,
|
||||
}
|
||||
|
||||
if (pSetFileCompletionNotificationModes) {
|
||||
/* All known Windows that support SetFileCompletionNotificationModes */
|
||||
/* have a bug that makes it impossible to use this function in */
|
||||
/* conjunction with datagram sockets. We can work around that but only */
|
||||
/* if the user is using the default UDP driver (AFD) and has no other */
|
||||
/* LSPs stacked on top. Here we check whether that is the case. */
|
||||
/* All known Windows that support SetFileCompletionNotificationModes have a
|
||||
* bug that makes it impossible to use this function in conjunction with
|
||||
* datagram sockets. We can work around that but only if the user is using
|
||||
* the default UDP driver (AFD) and has no other. LSPs stacked on top. Here
|
||||
* we check whether that is the case. */
|
||||
opt_len = (int) sizeof info;
|
||||
if (getsockopt(socket,
|
||||
SOL_SOCKET,
|
||||
@ -245,12 +245,12 @@ static int uv_udp_maybe_bind(uv_udp_t* handle,
|
||||
handle->flags |= UV_HANDLE_IPV6;
|
||||
|
||||
if (addr->sa_family == AF_INET6 && !(flags & UV_UDP_IPV6ONLY)) {
|
||||
/* On windows IPV6ONLY is on by default. */
|
||||
/* If the user doesn't specify it libuv turns it off. */
|
||||
/* On windows IPV6ONLY is on by default. If the user doesn't specify it
|
||||
* libuv turns it off. */
|
||||
|
||||
/* TODO: how to handle errors? This may fail if there is no ipv4 stack */
|
||||
/* available, or when run on XP/2003 which have no support for dualstack */
|
||||
/* sockets. For now we're silently ignoring the error. */
|
||||
/* TODO: how to handle errors? This may fail if there is no ipv4 stack
|
||||
* available, or when run on XP/2003 which have no support for dualstack
|
||||
* sockets. For now we're silently ignoring the error. */
|
||||
setsockopt(handle->socket,
|
||||
IPPROTO_IPV6,
|
||||
IPV6_V6ONLY,
|
||||
@ -386,8 +386,8 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
|
||||
handle->recv_cb = recv_cb;
|
||||
handle->alloc_cb = alloc_cb;
|
||||
|
||||
/* If reading was stopped and then started again, there could still be a */
|
||||
/* recv request pending. */
|
||||
/* If reading was stopped and then started again, there could still be a recv
|
||||
* request pending. */
|
||||
if (!(handle->flags & UV_HANDLE_READ_PENDING))
|
||||
uv_udp_queue_recv(loop, handle);
|
||||
|
||||
@ -467,19 +467,19 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
|
||||
if (!REQ_SUCCESS(req)) {
|
||||
DWORD err = GET_REQ_SOCK_ERROR(req);
|
||||
if (err == WSAEMSGSIZE) {
|
||||
/* Not a real error, it just indicates that the received packet */
|
||||
/* was bigger than the receive buffer. */
|
||||
/* Not a real error, it just indicates that the received packet was
|
||||
* bigger than the receive buffer. */
|
||||
} else if (err == WSAECONNRESET || err == WSAENETRESET) {
|
||||
/* A previous sendto operation failed; ignore this error. If */
|
||||
/* zero-reading we need to call WSARecv/WSARecvFrom _without_ the */
|
||||
/* MSG_PEEK flag to clear out the error queue. For nonzero reads, */
|
||||
/* immediately queue a new receive. */
|
||||
/* A previous sendto operation failed; ignore this error. If zero-reading
|
||||
* we need to call WSARecv/WSARecvFrom _without_ the. MSG_PEEK flag to
|
||||
* clear out the error queue. For nonzero reads, immediately queue a new
|
||||
* receive. */
|
||||
if (!(handle->flags & UV_HANDLE_ZERO_READ)) {
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
/* A real error occurred. Report the error to the user only if we're */
|
||||
/* currently reading. */
|
||||
/* A real error occurred. Report the error to the user only if we're
|
||||
* currently reading. */
|
||||
if (handle->flags & UV_HANDLE_READING) {
|
||||
uv_udp_recv_stop(handle);
|
||||
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
|
||||
@ -503,8 +503,8 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
|
||||
struct sockaddr_storage from;
|
||||
int from_len;
|
||||
|
||||
/* Do a nonblocking receive */
|
||||
/* TODO: try to read multiple datagrams at once. FIONREAD maybe? */
|
||||
/* Do a nonblocking receive.
|
||||
* TODO: try to read multiple datagrams at once. FIONREAD maybe? */
|
||||
buf = uv_buf_init(NULL, 0);
|
||||
handle->alloc_cb((uv_handle_t*) handle, 65536, &buf);
|
||||
if (buf.base == NULL || buf.len == 0) {
|
||||
|
||||
@ -149,8 +149,8 @@ int uv_exepath(char* buffer, size_t* size_ptr) {
|
||||
|
||||
uv__free(utf16_buffer);
|
||||
|
||||
/* utf8_len *does* include the terminating null at this point, but the */
|
||||
/* returned size shouldn't. */
|
||||
/* utf8_len *does* include the terminating null at this point, but the
|
||||
* returned size shouldn't. */
|
||||
*size_ptr = utf8_len - 1;
|
||||
return 0;
|
||||
|
||||
@ -173,16 +173,16 @@ int uv_cwd(char* buffer, size_t* size) {
|
||||
if (utf16_len == 0) {
|
||||
return uv_translate_sys_error(GetLastError());
|
||||
} else if (utf16_len > MAX_PATH) {
|
||||
/* This should be impossible; however the CRT has a code path to deal */
|
||||
/* with this scenario, so I added a check anyway. */
|
||||
/* This should be impossible; however the CRT has a code path to deal with
|
||||
* this scenario, so I added a check anyway. */
|
||||
return UV_EIO;
|
||||
}
|
||||
|
||||
/* utf16_len contains the length, *not* including the terminating null. */
|
||||
utf16_buffer[utf16_len] = L'\0';
|
||||
|
||||
/* The returned directory should not have a trailing slash, unless it */
|
||||
/* points at a drive root, like c:\. Remove it if needed.*/
|
||||
/* The returned directory should not have a trailing slash, unless it points
|
||||
* at a drive root, like c:\. Remove it if needed. */
|
||||
if (utf16_buffer[utf16_len - 1] == L'\\' &&
|
||||
!(utf16_len == 3 && utf16_buffer[1] == L':')) {
|
||||
utf16_len--;
|
||||
@ -239,9 +239,9 @@ int uv_chdir(const char* dir) {
|
||||
utf16_buffer,
|
||||
MAX_PATH) == 0) {
|
||||
DWORD error = GetLastError();
|
||||
/* The maximum length of the current working directory is 260 chars, */
|
||||
/* including terminating null. If it doesn't fit, the path name must be */
|
||||
/* too long. */
|
||||
/* The maximum length of the current working directory is 260 chars,
|
||||
* including terminating null. If it doesn't fit, the path name must be too
|
||||
* long. */
|
||||
if (error == ERROR_INSUFFICIENT_BUFFER) {
|
||||
return UV_ENAMETOOLONG;
|
||||
} else {
|
||||
@ -253,9 +253,9 @@ int uv_chdir(const char* dir) {
|
||||
return uv_translate_sys_error(GetLastError());
|
||||
}
|
||||
|
||||
/* Windows stores the drive-local path in an "hidden" environment variable, */
|
||||
/* which has the form "=C:=C:\Windows". SetCurrentDirectory does not */
|
||||
/* update this, so we'll have to do it. */
|
||||
/* Windows stores the drive-local path in an "hidden" environment variable,
|
||||
* which has the form "=C:=C:\Windows". SetCurrentDirectory does not update
|
||||
* this, so we'll have to do it. */
|
||||
utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer);
|
||||
if (utf16_len == 0) {
|
||||
return uv_translate_sys_error(GetLastError());
|
||||
@ -263,8 +263,8 @@ int uv_chdir(const char* dir) {
|
||||
return UV_EIO;
|
||||
}
|
||||
|
||||
/* The returned directory should not have a trailing slash, unless it */
|
||||
/* points at a drive root, like c:\. Remove it if needed. */
|
||||
/* The returned directory should not have a trailing slash, unless it points
|
||||
* at a drive root, like c:\. Remove it if needed. */
|
||||
if (utf16_buffer[utf16_len - 1] == L'\\' &&
|
||||
!(utf16_len == 3 && utf16_buffer[1] == L':')) {
|
||||
utf16_len--;
|
||||
@ -272,8 +272,8 @@ int uv_chdir(const char* dir) {
|
||||
}
|
||||
|
||||
if (utf16_len < 2 || utf16_buffer[1] != L':') {
|
||||
/* Doesn't look like a drive letter could be there - probably an UNC */
|
||||
/* path. TODO: Need to handle win32 namespaces like \\?\C:\ ? */
|
||||
/* Doesn't look like a drive letter could be there - probably an UNC path.
|
||||
* TODO: Need to handle win32 namespaces like \\?\C:\ ? */
|
||||
drive_letter = 0;
|
||||
} else if (utf16_buffer[0] >= L'A' && utf16_buffer[0] <= L'Z') {
|
||||
drive_letter = utf16_buffer[0];
|
||||
@ -842,17 +842,17 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the size of the adapters reported by windows, and then get the */
|
||||
/* list itself. */
|
||||
/* Fetch the size of the adapters reported by windows, and then get the list
|
||||
* itself. */
|
||||
win_address_buf_size = 0;
|
||||
win_address_buf = NULL;
|
||||
|
||||
for (;;) {
|
||||
ULONG r;
|
||||
|
||||
/* If win_address_buf is 0, then GetAdaptersAddresses will fail with */
|
||||
/* ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in */
|
||||
/* win_address_buf_size. */
|
||||
/* If win_address_buf is 0, then GetAdaptersAddresses will fail with.
|
||||
* ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in
|
||||
* win_address_buf_size. */
|
||||
r = GetAdaptersAddresses(AF_UNSPEC,
|
||||
flags,
|
||||
NULL,
|
||||
@ -866,8 +866,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
|
||||
switch (r) {
|
||||
case ERROR_BUFFER_OVERFLOW:
|
||||
/* This happens when win_address_buf is NULL or too small to hold */
|
||||
/* all adapters. */
|
||||
/* This happens when win_address_buf is NULL or too small to hold all
|
||||
* adapters. */
|
||||
win_address_buf = uv__malloc(win_address_buf_size);
|
||||
if (win_address_buf == NULL)
|
||||
return UV_ENOMEM;
|
||||
@ -901,15 +901,15 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
return UV_ENOBUFS;
|
||||
|
||||
default:
|
||||
/* Other (unspecified) errors can happen, but we don't have any */
|
||||
/* special meaning for them. */
|
||||
/* Other (unspecified) errors can happen, but we don't have any special
|
||||
* meaning for them. */
|
||||
assert(r != ERROR_SUCCESS);
|
||||
return uv_translate_sys_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
/* Count the number of enabled interfaces and compute how much space is */
|
||||
/* needed to store their info. */
|
||||
/* Count the number of enabled interfaces and compute how much space is
|
||||
* needed to store their info. */
|
||||
count = 0;
|
||||
uv_address_buf_size = 0;
|
||||
|
||||
@ -919,9 +919,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
IP_ADAPTER_UNICAST_ADDRESS* unicast_address;
|
||||
int name_size;
|
||||
|
||||
/* Interfaces that are not 'up' should not be reported. Also skip */
|
||||
/* interfaces that have no associated unicast address, as to avoid */
|
||||
/* allocating space for the name for this interface. */
|
||||
/* Interfaces that are not 'up' should not be reported. Also skip
|
||||
* interfaces that have no associated unicast address, as to avoid
|
||||
* allocating space for the name for this interface. */
|
||||
if (adapter->OperStatus != IfOperStatusUp ||
|
||||
adapter->FirstUnicastAddress == NULL)
|
||||
continue;
|
||||
@ -941,8 +941,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
}
|
||||
uv_address_buf_size += name_size;
|
||||
|
||||
/* Count the number of addresses associated with this interface, and */
|
||||
/* compute the size. */
|
||||
/* Count the number of addresses associated with this interface, and
|
||||
* compute the size. */
|
||||
for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*)
|
||||
adapter->FirstUnicastAddress;
|
||||
unicast_address != NULL;
|
||||
@ -959,8 +959,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
|
||||
return UV_ENOMEM;
|
||||
}
|
||||
|
||||
/* Compute the start of the uv_interface_address_t array, and the place in */
|
||||
/* the buffer where the interface names will be stored. */
|
||||
/* Compute the start of the uv_interface_address_t array, and the place in
|
||||
* the buffer where the interface names will be stored. */
|
||||
uv_address = uv_address_buf;
|
||||
name_buf = (char*) (uv_address_buf + count);
|
||||
|
||||
@ -1199,8 +1199,8 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
|
||||
return UV_EIO;
|
||||
}
|
||||
|
||||
/* The returned directory should not have a trailing slash, unless it */
|
||||
/* points at a drive root, like c:\. Remove it if needed.*/
|
||||
/* The returned directory should not have a trailing slash, unless it points
|
||||
* at a drive root, like c:\. Remove it if needed. */
|
||||
if (path[len - 1] == L'\\' &&
|
||||
!(len == 3 && path[1] == L':')) {
|
||||
len--;
|
||||
|
||||
@ -4076,8 +4076,8 @@
|
||||
# define STATUS_HASH_NOT_PRESENT ((NTSTATUS) 0xC000A101L)
|
||||
#endif
|
||||
|
||||
/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the */
|
||||
/* DDK got it wrong! */
|
||||
/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the DDK
|
||||
* got it wrong! */
|
||||
#ifdef NTSTATUS_FROM_WIN32
|
||||
# undef NTSTATUS_FROM_WIN32
|
||||
#endif
|
||||
|
||||
@ -256,8 +256,8 @@ int uv_ntstatus_to_winsock_error(NTSTATUS status) {
|
||||
default:
|
||||
if ((status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) &&
|
||||
(status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) {
|
||||
/* It's a windows error that has been previously mapped to an */
|
||||
/* ntstatus code. */
|
||||
/* It's a windows error that has been previously mapped to an ntstatus
|
||||
* code. */
|
||||
return (DWORD) (status & 0xffff);
|
||||
} else {
|
||||
/* The default fallback for unmappable ntstatus codes. */
|
||||
@ -519,8 +519,8 @@ int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in,
|
||||
sizeof *info_out);
|
||||
|
||||
if (overlapped == NULL) {
|
||||
/* If this is a blocking operation, wait for the event to become */
|
||||
/* signaled, and then grab the real status from the io status block. */
|
||||
/* If this is a blocking operation, wait for the event to become signaled,
|
||||
* and then grab the real status from the io status block. */
|
||||
if (status == STATUS_PENDING) {
|
||||
DWORD r = WaitForSingleObject(event, INFINITE);
|
||||
|
||||
|
||||
@ -57,8 +57,8 @@ int platform_init(int argc, char **argv) {
|
||||
}
|
||||
|
||||
|
||||
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */
|
||||
/* Make sure that all stdio output of the processes is buffered up. */
|
||||
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure
|
||||
* that all stdio output of the processes is buffered up. */
|
||||
int process_start(char* name, char* part, process_info_t* p, int is_helper) {
|
||||
FILE* stdout_file;
|
||||
int stdout_fd;
|
||||
@ -161,9 +161,9 @@ static void* dowait(void* data) {
|
||||
}
|
||||
|
||||
|
||||
/* Wait for all `n` processes in `vec` to terminate. */
|
||||
/* Time out after `timeout` msec, or never if timeout == -1 */
|
||||
/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */
|
||||
/* Wait for all `n` processes in `vec` to terminate. Time out after `timeout`
|
||||
* msec, or never if timeout == -1. Return 0 if all processes are terminated,
|
||||
* -1 on error, -2 on timeout. */
|
||||
int process_wait(process_info_t* vec, int n, int timeout) {
|
||||
int i;
|
||||
int r;
|
||||
@ -358,8 +358,7 @@ int process_terminate(process_info_t *p) {
|
||||
}
|
||||
|
||||
|
||||
/* Return the exit code of process p. */
|
||||
/* On error, return -1. */
|
||||
/* Return the exit code of process p. On error, return -1. */
|
||||
int process_reap(process_info_t *p) {
|
||||
if (WIFEXITED(p->status)) {
|
||||
return WEXITSTATUS(p->status);
|
||||
|
||||
@ -165,8 +165,8 @@ error:
|
||||
}
|
||||
|
||||
|
||||
/* Timeout is in msecs. Set timeout < 0 to never time out. */
|
||||
/* Returns 0 when all processes are terminated, -2 on timeout. */
|
||||
/* Timeout is in msecs. Set timeout < 0 to never time out. Returns 0 when all
|
||||
* processes are terminated, -2 on timeout. */
|
||||
int process_wait(process_info_t *vec, int n, int timeout) {
|
||||
int i;
|
||||
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
|
||||
|
||||
@ -138,13 +138,13 @@ void print_lines(const char* buffer, size_t size, FILE* stream);
|
||||
/* Do platform-specific initialization. */
|
||||
int platform_init(int argc, char** argv);
|
||||
|
||||
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */
|
||||
/* Make sure that all stdio output of the processes is buffered up. */
|
||||
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure
|
||||
* that all stdio output of the processes is buffered up. */
|
||||
int process_start(char *name, char* part, process_info_t *p, int is_helper);
|
||||
|
||||
/* Wait for all `n` processes in `vec` to terminate. */
|
||||
/* Time out after `timeout` msec, or never if timeout == -1 */
|
||||
/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */
|
||||
/* Wait for all `n` processes in `vec` to terminate. Time out after `timeout`
|
||||
* msec, or never if timeout == -1. Return 0 if all processes are terminated,
|
||||
* -1 on error, -2 on timeout. */
|
||||
int process_wait(process_info_t *vec, int n, int timeout);
|
||||
|
||||
/* Returns the number of bytes in the stdio output buffer for process `p`. */
|
||||
@ -164,8 +164,7 @@ char* process_get_name(process_info_t *p);
|
||||
/* Terminate process `p`. */
|
||||
int process_terminate(process_info_t *p);
|
||||
|
||||
/* Return the exit code of process p. */
|
||||
/* On error, return -1. */
|
||||
/* Return the exit code of process p. On error, return -1. */
|
||||
int process_reap(process_info_t *p);
|
||||
|
||||
/* Clean up after terminating process `p` (e.g. free the output buffer etc.). */
|
||||
|
||||
@ -88,10 +88,9 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
|
||||
|
||||
bytes_received += nread;
|
||||
|
||||
/* We call shutdown here because when bytes_received == sizeof MESSAGE */
|
||||
/* there will be no more data sent nor received, so here it would be */
|
||||
/* possible for a backend to call shutdown_cb immediately and *not* */
|
||||
/* from a fresh stack. */
|
||||
/* We call shutdown here because when bytes_received == sizeof MESSAGE there
|
||||
* will be no more data sent nor received, so here it would be possible for a
|
||||
* backend to call shutdown_cb immediately and *not* from a fresh stack. */
|
||||
if (bytes_received == sizeof MESSAGE) {
|
||||
nested++;
|
||||
|
||||
@ -131,10 +130,10 @@ static void write_cb(uv_write_t* req, int status) {
|
||||
|
||||
puts("Data written. 500ms timeout...");
|
||||
|
||||
/* After the data has been sent, we're going to wait for a while, then */
|
||||
/* start reading. This makes us certain that the message has been echoed */
|
||||
/* back to our receive buffer when we start reading. This maximizes the */
|
||||
/* temptation for the backend to use dirty stack for calling read_cb. */
|
||||
/* After the data has been sent, we're going to wait for a while, then start
|
||||
* reading. This makes us certain that the message has been echoed back to
|
||||
* our receive buffer when we start reading. This maximizes the temptation
|
||||
* for the backend to use dirty stack for calling read_cb. */
|
||||
nested++;
|
||||
r = uv_timer_init(uv_default_loop(), &timer);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -98,8 +98,8 @@ static void connection_fail(uv_connect_cb connect_cb) {
|
||||
r = uv_tcp_init(uv_default_loop(), &tcp);
|
||||
ASSERT(!r);
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
/* so these handles can be pre-initialized. */
|
||||
/* We are never doing multiple reads/connects at a time anyway. so these
|
||||
* handles can be pre-initialized. */
|
||||
ASSERT(0 == uv_tcp_bind(&tcp, (const struct sockaddr*) &client_addr, 0));
|
||||
|
||||
r = uv_tcp_connect(&req,
|
||||
|
||||
@ -138,8 +138,8 @@ static void connect_cb(uv_connect_t* req, int status) {
|
||||
ASSERT(req != NULL);
|
||||
ASSERT(status == 0);
|
||||
|
||||
/* Not that the server will send anything, but otherwise we'll never know */
|
||||
/* when the server closes the connection. */
|
||||
/* Not that the server will send anything, but otherwise we'll never know
|
||||
* when the server closes the connection. */
|
||||
r = uv_read_start((uv_stream_t*)(req->handle), alloc_cb, read_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
|
||||
@ -317,8 +317,7 @@ TEST_IMPL(fork_signal_to_child_closed) {
|
||||
printf("Waiting for child in parent\n");
|
||||
assert_wait_child(child_pid);
|
||||
} else {
|
||||
/* child */
|
||||
/* Our signal handler should still be installed. */
|
||||
/* Child. Our signal handler should still be installed. */
|
||||
ASSERT(0 == uv_loop_fork(uv_default_loop()));
|
||||
printf("Checking loop in child\n");
|
||||
ASSERT(0 != uv_loop_alive(uv_default_loop()));
|
||||
@ -652,13 +651,11 @@ TEST_IMPL(fork_threadpool_queue_work_simple) {
|
||||
ASSERT(child_pid != -1);
|
||||
|
||||
if (child_pid != 0) {
|
||||
/* parent */
|
||||
/* We can still run work. */
|
||||
/* Parent. We can still run work. */
|
||||
assert_run_work(uv_default_loop());
|
||||
assert_wait_child(child_pid);
|
||||
} else {
|
||||
/* child */
|
||||
/* We can work in a new loop. */
|
||||
/* Child. We can work in a new loop. */
|
||||
printf("Running child in %d\n", getpid());
|
||||
uv_loop_init(&loop);
|
||||
printf("Child first watch\n");
|
||||
|
||||
@ -43,9 +43,9 @@ TEST_IMPL(hrtime) {
|
||||
|
||||
/* printf("i= %d diff = %llu\n", i, (unsigned long long int) diff); */
|
||||
|
||||
/* The windows Sleep() function has only a resolution of 10-20 ms. */
|
||||
/* Check that the difference between the two hrtime values is somewhat in */
|
||||
/* the range we expect it to be. */
|
||||
/* The windows Sleep() function has only a resolution of 10-20 ms. Check
|
||||
* that the difference between the two hrtime values is somewhat in the
|
||||
* range we expect it to be. */
|
||||
ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC);
|
||||
ASSERT(diff < (uint64_t) 80 * NANOSEC / MILLISEC);
|
||||
--i;
|
||||
|
||||
@ -228,8 +228,8 @@ static void check_cb(uv_check_t* handle) {
|
||||
uv_close((uv_handle_t*)&idle_1_handles[i], idle_1_close_cb);
|
||||
}
|
||||
|
||||
/* This handle is closed/recreated every time, close it only if it is */
|
||||
/* active.*/
|
||||
/* This handle is closed/recreated every time, close it only if it is
|
||||
* active. */
|
||||
if (idle_2_is_active) {
|
||||
uv_close((uv_handle_t*)&idle_2_handle, idle_2_close_cb);
|
||||
}
|
||||
@ -246,10 +246,10 @@ static void prepare_2_cb(uv_prepare_t* handle) {
|
||||
fflush(stderr);
|
||||
ASSERT(handle == &prepare_2_handle);
|
||||
|
||||
/* prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), */
|
||||
/* and it stops itself immediately. A started watcher is not queued */
|
||||
/* until the next round, so when this callback is made */
|
||||
/* (loop_iteration % 2 == 0) cannot be true. */
|
||||
/* Prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), and it
|
||||
* stops itself immediately. A started watcher is not queued until the next
|
||||
* round, so when this callback is made (loop_iteration % 2 == 0) cannot be
|
||||
* true. */
|
||||
ASSERT(loop_iteration % 2 != 0);
|
||||
|
||||
r = uv_prepare_stop((uv_prepare_t*)handle);
|
||||
@ -304,8 +304,8 @@ TEST_IMPL(loop_handles) {
|
||||
|
||||
/* don't init or start idle_2, both is done by idle_1_cb */
|
||||
|
||||
/* the timer callback is there to keep the event loop polling */
|
||||
/* unref it as it is not supposed to keep the loop alive */
|
||||
/* The timer callback is there to keep the event loop polling unref it as it
|
||||
* is not supposed to keep the loop alive */
|
||||
r = uv_timer_init(uv_default_loop(), &timer_handle);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT);
|
||||
|
||||
@ -171,8 +171,8 @@ static void tcp_pinger_v6_new(void) {
|
||||
pinger->stream.tcp.data = pinger;
|
||||
ASSERT(!r);
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
/* so these handles can be pre-initialized. */
|
||||
/* We are never doing multiple reads/connects at a time anyway, so these
|
||||
* handles can be pre-initialized. */
|
||||
r = uv_tcp_connect(&pinger->connect_req,
|
||||
&pinger->stream.tcp,
|
||||
(const struct sockaddr*) &server_addr,
|
||||
@ -200,8 +200,8 @@ static void tcp_pinger_new(void) {
|
||||
pinger->stream.tcp.data = pinger;
|
||||
ASSERT(!r);
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
/* so these handles can be pre-initialized. */
|
||||
/* We are never doing multiple reads/connects at a time anyway, so these
|
||||
* handles can be pre-initialized. */
|
||||
r = uv_tcp_connect(&pinger->connect_req,
|
||||
&pinger->stream.tcp,
|
||||
(const struct sockaddr*) &server_addr,
|
||||
@ -227,9 +227,8 @@ static void pipe_pinger_new(void) {
|
||||
pinger->stream.pipe.data = pinger;
|
||||
ASSERT(!r);
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
/* so these handles can be pre-initialized. */
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway, so these
|
||||
* handles can be pre-initialized. */
|
||||
uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME,
|
||||
pinger_on_connect);
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ TEST_IMPL(pipe_set_chmod) {
|
||||
r = uv_pipe_bind(&pipe_handle, TEST_PIPENAME);
|
||||
ASSERT(r == 0);
|
||||
|
||||
/* No easy way to test if this works, we will only make sure that */
|
||||
/* the call is successful. */
|
||||
/* No easy way to test if this works, we will only make sure that the call is
|
||||
* successful. */
|
||||
r = uv_pipe_chmod(&pipe_handle, UV_READABLE);
|
||||
if (r == UV_EPERM) {
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
|
||||
@ -1637,8 +1637,8 @@ TEST_IMPL(spawn_reads_child_path) {
|
||||
static const char dyld_path_var[] = "LD_LIBRARY_PATH";
|
||||
#endif
|
||||
|
||||
/* Set up the process, but make sure that the file to run is relative and */
|
||||
/* requires a lookup into PATH */
|
||||
/* Set up the process, but make sure that the file to run is relative and
|
||||
* requires a lookup into PATH. */
|
||||
init_process_options("spawn_helper1", exit_cb);
|
||||
|
||||
/* Set up the PATH env variable */
|
||||
@ -1805,8 +1805,8 @@ TEST_IMPL(spawn_quoted_path) {
|
||||
options.args = args;
|
||||
options.exit_cb = exit_cb;
|
||||
options.flags = 0;
|
||||
/* We test if search_path works correctly with semicolons in quoted path. */
|
||||
/* We will use invalid drive, so we are sure no executable is spawned */
|
||||
/* We test if search_path works correctly with semicolons in quoted path. We
|
||||
* will use an invalid drive, so we are sure no executable is spawned. */
|
||||
quoted_path_env[0] = "PATH=\"xyz:\\test;\";xyz:\\other";
|
||||
quoted_path_env[1] = NULL;
|
||||
options.env = quoted_path_env;
|
||||
|
||||
@ -58,8 +58,8 @@ static void repeat_1_cb(uv_timer_t* handle) {
|
||||
|
||||
if (repeat_1_cb_called == 10) {
|
||||
uv_close((uv_handle_t*)handle, close_cb);
|
||||
/* We're not calling uv_timer_again on repeat_2 any more, so after this */
|
||||
/* timer_2_cb is expected. */
|
||||
/* We're not calling uv_timer_again on repeat_2 any more, so after this
|
||||
* timer_2_cb is expected. */
|
||||
repeat_2_cb_allowed = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -120,8 +120,7 @@ static void sv_recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards sv_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards sv_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -81,8 +81,7 @@ static void cl_recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards cl_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards cl_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -82,8 +82,7 @@ static void cl_recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards cl_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards cl_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,8 +106,7 @@ static void recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards sv_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards sv_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -72,8 +72,7 @@ static void cl_recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards cl_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards cl_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
@ -128,8 +127,7 @@ static void sv_recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards sv_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards sv_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -74,8 +74,7 @@ static void sv_recv_cb(uv_udp_t* handle,
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
/* Returning unused buffer */
|
||||
/* Don't count towards sv_recv_cb_called */
|
||||
/* Returning unused buffer. Don't count towards sv_recv_cb_called */
|
||||
ASSERT(addr == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user