|
@ -38,6 +38,7 @@ int uv_pipe_init(uv_pipe_t* handle) { |
|
|
handle->reqs_pending = 0; |
|
|
handle->reqs_pending = 0; |
|
|
handle->pending_accepts = NULL; |
|
|
handle->pending_accepts = NULL; |
|
|
handle->name = NULL; |
|
|
handle->name = NULL; |
|
|
|
|
|
handle->handle = INVALID_HANDLE_VALUE; |
|
|
|
|
|
|
|
|
uv_counters()->pipe_init++; |
|
|
uv_counters()->pipe_init++; |
|
|
|
|
|
|
|
@ -96,20 +97,18 @@ void uv_pipe_endgame(uv_pipe_t* handle) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Creates a pipe server. */ |
|
|
/* Creates a pipe server. */ |
|
|
/* TODO: make this work with UTF8 name */ |
|
|
|
|
|
int uv_pipe_bind(uv_pipe_t* handle, const char* name) { |
|
|
int uv_pipe_bind(uv_pipe_t* handle, const char* name) { |
|
|
int i; |
|
|
int i, errno, nameSize; |
|
|
uv_pipe_accept_t* req; |
|
|
uv_pipe_accept_t* req; |
|
|
|
|
|
|
|
|
if (!name) { |
|
|
if (handle->flags & UV_HANDLE_BOUND) { |
|
|
uv_set_sys_error(WSAEINVAL); |
|
|
uv_set_sys_error(WSAEINVAL); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* Make our own copy of the pipe name */ |
|
|
if (!name) { |
|
|
handle->name = _strdup(name); |
|
|
uv_set_sys_error(WSAEINVAL); |
|
|
if (!handle->name) { |
|
|
return -1; |
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) { |
|
|
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) { |
|
@ -121,8 +120,67 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) { |
|
|
req->next_pending = NULL; |
|
|
req->next_pending = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Convert name to UTF16. */ |
|
|
|
|
|
nameSize = uv_utf8_to_utf16(name, NULL, 0) * sizeof(wchar_t); |
|
|
|
|
|
handle->name = (wchar_t*)malloc(nameSize); |
|
|
|
|
|
if (!handle->name) { |
|
|
|
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!uv_utf8_to_utf16(name, handle->name, nameSize / sizeof(wchar_t))) { |
|
|
|
|
|
uv_set_sys_error(GetLastError()); |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Attempt to create the first pipe with FILE_FLAG_FIRST_PIPE_INSTANCE. |
|
|
|
|
|
* If this fails then there's already a pipe server for the given pipe name. |
|
|
|
|
|
*/ |
|
|
|
|
|
handle->accept_reqs[0].pipeHandle = CreateNamedPipeW(handle->name, |
|
|
|
|
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE, |
|
|
|
|
|
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, |
|
|
|
|
|
PIPE_UNLIMITED_INSTANCES, |
|
|
|
|
|
65536, |
|
|
|
|
|
65536, |
|
|
|
|
|
0, |
|
|
|
|
|
NULL); |
|
|
|
|
|
|
|
|
|
|
|
if (handle->accept_reqs[0].pipeHandle == INVALID_HANDLE_VALUE) { |
|
|
|
|
|
errno = GetLastError(); |
|
|
|
|
|
if (errno == ERROR_ACCESS_DENIED) { |
|
|
|
|
|
uv_set_error(UV_EADDRINUSE, errno); |
|
|
|
|
|
handle->error = LOOP->last_error; |
|
|
|
|
|
handle->flags |= UV_HANDLE_BIND_ERROR; |
|
|
|
|
|
} else if (errno == ERROR_PATH_NOT_FOUND || errno == ERROR_INVALID_NAME) { |
|
|
|
|
|
uv_set_error(UV_EADDRNOTAVAIL, errno); |
|
|
|
|
|
} else { |
|
|
|
|
|
uv_set_sys_error(errno); |
|
|
|
|
|
} |
|
|
|
|
|
goto error; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (uv_set_pipe_handle(handle, handle->accept_reqs[0].pipeHandle)) { |
|
|
|
|
|
uv_set_sys_error(GetLastError()); |
|
|
|
|
|
goto error; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
handle->flags |= UV_HANDLE_PIPESERVER; |
|
|
handle->flags |= UV_HANDLE_PIPESERVER; |
|
|
|
|
|
handle->flags |= UV_HANDLE_BOUND; |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
error: |
|
|
|
|
|
if (handle->name) { |
|
|
|
|
|
free(handle->name); |
|
|
|
|
|
handle->name = NULL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (handle->accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE) { |
|
|
|
|
|
CloseHandle(handle->accept_reqs[0].pipeHandle); |
|
|
|
|
|
handle->accept_reqs[0].pipeHandle = INVALID_HANDLE_VALUE; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -138,9 +196,9 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) { |
|
|
assert(handle); |
|
|
assert(handle); |
|
|
|
|
|
|
|
|
/* 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 (WaitNamedPipe(handle->name, 30000)) { |
|
|
while (WaitNamedPipeW(handle->name, 30000)) { |
|
|
/* The pipe is now available, try to connect. */ |
|
|
/* The pipe is now available, try to connect. */ |
|
|
pipeHandle = CreateFile(handle->name, |
|
|
pipeHandle = CreateFileW(handle->name, |
|
|
GENERIC_READ | GENERIC_WRITE, |
|
|
GENERIC_READ | GENERIC_WRITE, |
|
|
0, |
|
|
0, |
|
|
NULL, |
|
|
NULL, |
|
@ -174,10 +232,9 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: make this work with UTF8 name */ |
|
|
|
|
|
int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, |
|
|
int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, |
|
|
const char* name, uv_connect_cb cb) { |
|
|
const char* name, uv_connect_cb cb) { |
|
|
int errno; |
|
|
int errno, nameSize; |
|
|
HANDLE pipeHandle; |
|
|
HANDLE pipeHandle; |
|
|
|
|
|
|
|
|
handle->handle = INVALID_HANDLE_VALUE; |
|
|
handle->handle = INVALID_HANDLE_VALUE; |
|
@ -187,7 +244,19 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, |
|
|
req->handle = (uv_stream_t*) handle; |
|
|
req->handle = (uv_stream_t*) handle; |
|
|
req->cb = cb; |
|
|
req->cb = cb; |
|
|
|
|
|
|
|
|
pipeHandle = CreateFile(name, |
|
|
/* Convert name to UTF16. */ |
|
|
|
|
|
nameSize = uv_utf8_to_utf16(name, NULL, 0) * sizeof(wchar_t); |
|
|
|
|
|
handle->name = (wchar_t*)malloc(nameSize); |
|
|
|
|
|
if (!handle->name) { |
|
|
|
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!uv_utf8_to_utf16(name, handle->name, nameSize / sizeof(wchar_t))) { |
|
|
|
|
|
errno = GetLastError(); |
|
|
|
|
|
goto error; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pipeHandle = CreateFileW(handle->name, |
|
|
GENERIC_READ | GENERIC_WRITE, |
|
|
GENERIC_READ | GENERIC_WRITE, |
|
|
0, |
|
|
0, |
|
|
NULL, |
|
|
NULL, |
|
@ -198,11 +267,6 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, |
|
|
if (pipeHandle == INVALID_HANDLE_VALUE) { |
|
|
if (pipeHandle == INVALID_HANDLE_VALUE) { |
|
|
if (GetLastError() == ERROR_PIPE_BUSY) { |
|
|
if (GetLastError() == ERROR_PIPE_BUSY) { |
|
|
/* Wait for the server to make a pipe instance available. */ |
|
|
/* Wait for the server to make a pipe instance available. */ |
|
|
handle->name = _strdup(name); |
|
|
|
|
|
if (!handle->name) { |
|
|
|
|
|
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!QueueUserWorkItem(&pipe_connect_thread_proc, req, WT_EXECUTELONGFUNCTION)) { |
|
|
if (!QueueUserWorkItem(&pipe_connect_thread_proc, req, WT_EXECUTELONGFUNCTION)) { |
|
|
errno = GetLastError(); |
|
|
errno = GetLastError(); |
|
|
goto error; |
|
|
goto error; |
|
@ -228,6 +292,11 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, |
|
|
return 0; |
|
|
return 0; |
|
|
|
|
|
|
|
|
error: |
|
|
error: |
|
|
|
|
|
if (handle->name) { |
|
|
|
|
|
free(handle->name); |
|
|
|
|
|
handle->name = NULL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (pipeHandle != INVALID_HANDLE_VALUE) { |
|
|
if (pipeHandle != INVALID_HANDLE_VALUE) { |
|
|
CloseHandle(pipeHandle); |
|
|
CloseHandle(pipeHandle); |
|
|
} |
|
|
} |
|
@ -243,7 +312,7 @@ void close_pipe(uv_pipe_t* handle, int* status, uv_err_t* err) { |
|
|
|
|
|
|
|
|
if (handle->name) { |
|
|
if (handle->name) { |
|
|
free(handle->name); |
|
|
free(handle->name); |
|
|
handle->name; |
|
|
handle->name = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (handle->flags & UV_HANDLE_PIPESERVER) { |
|
|
if (handle->flags & UV_HANDLE_PIPESERVER) { |
|
@ -251,24 +320,26 @@ void close_pipe(uv_pipe_t* handle, int* status, uv_err_t* err) { |
|
|
pipeHandle = handle->accept_reqs[i].pipeHandle; |
|
|
pipeHandle = handle->accept_reqs[i].pipeHandle; |
|
|
if (pipeHandle != INVALID_HANDLE_VALUE) { |
|
|
if (pipeHandle != INVALID_HANDLE_VALUE) { |
|
|
CloseHandle(pipeHandle); |
|
|
CloseHandle(pipeHandle); |
|
|
|
|
|
handle->accept_reqs[i].pipeHandle = INVALID_HANDLE_VALUE; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else if (handle->handle != INVALID_HANDLE_VALUE) { |
|
|
} else if (handle->handle != INVALID_HANDLE_VALUE) { |
|
|
CloseHandle(handle->handle); |
|
|
CloseHandle(handle->handle); |
|
|
|
|
|
handle->handle = INVALID_HANDLE_VALUE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handle->flags |= UV_HANDLE_SHUT; |
|
|
handle->flags |= UV_HANDLE_SHUT; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void uv_pipe_queue_accept(uv_pipe_t* handle, uv_pipe_accept_t* req) { |
|
|
static void uv_pipe_queue_accept(uv_pipe_t* handle, uv_pipe_accept_t* req, BOOL firstInstance) { |
|
|
HANDLE pipeHandle; |
|
|
|
|
|
|
|
|
|
|
|
assert(handle->flags & UV_HANDLE_LISTENING); |
|
|
assert(handle->flags & UV_HANDLE_LISTENING); |
|
|
|
|
|
|
|
|
|
|
|
if (!firstInstance) { |
|
|
assert(req->pipeHandle == INVALID_HANDLE_VALUE); |
|
|
assert(req->pipeHandle == INVALID_HANDLE_VALUE); |
|
|
|
|
|
|
|
|
pipeHandle = CreateNamedPipe(handle->name, |
|
|
req->pipeHandle = CreateNamedPipeW(handle->name, |
|
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, |
|
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, |
|
|
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, |
|
|
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, |
|
|
PIPE_UNLIMITED_INSTANCES, |
|
|
PIPE_UNLIMITED_INSTANCES, |
|
@ -277,31 +348,34 @@ static void uv_pipe_queue_accept(uv_pipe_t* handle, uv_pipe_accept_t* req) { |
|
|
0, |
|
|
0, |
|
|
NULL); |
|
|
NULL); |
|
|
|
|
|
|
|
|
if (pipeHandle == INVALID_HANDLE_VALUE) { |
|
|
if (req->pipeHandle == INVALID_HANDLE_VALUE) { |
|
|
req->error = uv_new_sys_error(GetLastError()); |
|
|
req->error = uv_new_sys_error(GetLastError()); |
|
|
uv_insert_pending_req((uv_req_t*) req); |
|
|
uv_insert_pending_req((uv_req_t*) req); |
|
|
handle->reqs_pending++; |
|
|
handle->reqs_pending++; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (CreateIoCompletionPort(pipeHandle, |
|
|
if (uv_set_pipe_handle(handle, req->pipeHandle)) { |
|
|
LOOP->iocp, |
|
|
CloseHandle(req->pipeHandle); |
|
|
(ULONG_PTR)handle, |
|
|
req->pipeHandle = INVALID_HANDLE_VALUE; |
|
|
0) == NULL) { |
|
|
|
|
|
req->error = uv_new_sys_error(GetLastError()); |
|
|
req->error = uv_new_sys_error(GetLastError()); |
|
|
uv_insert_pending_req((uv_req_t*) req); |
|
|
uv_insert_pending_req((uv_req_t*) req); |
|
|
handle->reqs_pending++; |
|
|
handle->reqs_pending++; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assert(req->pipeHandle != INVALID_HANDLE_VALUE); |
|
|
|
|
|
|
|
|
/* Prepare the overlapped structure. */ |
|
|
/* Prepare the overlapped structure. */ |
|
|
memset(&(req->overlapped), 0, sizeof(req->overlapped)); |
|
|
memset(&(req->overlapped), 0, sizeof(req->overlapped)); |
|
|
|
|
|
|
|
|
if (!ConnectNamedPipe(pipeHandle, &req->overlapped) && GetLastError() != ERROR_IO_PENDING) { |
|
|
if (!ConnectNamedPipe(req->pipeHandle, &req->overlapped) && GetLastError() != ERROR_IO_PENDING) { |
|
|
if (GetLastError() == ERROR_PIPE_CONNECTED) { |
|
|
if (GetLastError() == ERROR_PIPE_CONNECTED) { |
|
|
req->pipeHandle = pipeHandle; |
|
|
|
|
|
req->error = uv_ok_; |
|
|
req->error = uv_ok_; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
CloseHandle(req->pipeHandle); |
|
|
|
|
|
req->pipeHandle = INVALID_HANDLE_VALUE; |
|
|
/* Make this req pending reporting an error. */ |
|
|
/* Make this req pending reporting an error. */ |
|
|
req->error = uv_new_sys_error(GetLastError()); |
|
|
req->error = uv_new_sys_error(GetLastError()); |
|
|
} |
|
|
} |
|
@ -310,7 +384,6 @@ static void uv_pipe_queue_accept(uv_pipe_t* handle, uv_pipe_accept_t* req) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
req->pipeHandle = pipeHandle; |
|
|
|
|
|
handle->reqs_pending++; |
|
|
handle->reqs_pending++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -336,7 +409,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) { |
|
|
req->pipeHandle = INVALID_HANDLE_VALUE; |
|
|
req->pipeHandle = INVALID_HANDLE_VALUE; |
|
|
|
|
|
|
|
|
if (!(server->flags & UV_HANDLE_CLOSING)) { |
|
|
if (!(server->flags & UV_HANDLE_CLOSING)) { |
|
|
uv_pipe_queue_accept(server, req); |
|
|
uv_pipe_queue_accept(server, req, FALSE); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
@ -347,22 +420,35 @@ int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) { |
|
|
int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb) { |
|
|
int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb) { |
|
|
int i, errno; |
|
|
int i, errno; |
|
|
|
|
|
|
|
|
|
|
|
if (handle->flags & UV_HANDLE_BIND_ERROR) { |
|
|
|
|
|
LOOP->last_error = handle->error; |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!(handle->flags & UV_HANDLE_BOUND)) { |
|
|
|
|
|
uv_set_error(UV_ENOTCONN, 0); |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (handle->flags & UV_HANDLE_LISTENING || |
|
|
if (handle->flags & UV_HANDLE_LISTENING || |
|
|
handle->flags & UV_HANDLE_READING) { |
|
|
handle->flags & UV_HANDLE_READING) { |
|
|
uv_set_sys_error(UV_EALREADY); |
|
|
uv_set_error(UV_EALREADY, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!(handle->flags & UV_HANDLE_PIPESERVER)) { |
|
|
if (!(handle->flags & UV_HANDLE_PIPESERVER)) { |
|
|
uv_set_sys_error(UV_ENOTSUP); |
|
|
uv_set_error(UV_ENOTSUP, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handle->flags |= UV_HANDLE_LISTENING; |
|
|
handle->flags |= UV_HANDLE_LISTENING; |
|
|
handle->connection_cb = cb; |
|
|
handle->connection_cb = cb; |
|
|
|
|
|
|
|
|
|
|
|
/* First pipe handle should have already been created in uv_pipe_bind */ |
|
|
|
|
|
assert(handle->accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE); |
|
|
|
|
|
|
|
|
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) { |
|
|
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) { |
|
|
uv_pipe_queue_accept(handle, &handle->accept_reqs[i]); |
|
|
uv_pipe_queue_accept(handle, &handle->accept_reqs[i], i == 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
@ -403,17 +489,17 @@ static void uv_pipe_queue_read(uv_pipe_t* handle) { |
|
|
|
|
|
|
|
|
int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb) { |
|
|
int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_cb) { |
|
|
if (!(handle->flags & UV_HANDLE_CONNECTION)) { |
|
|
if (!(handle->flags & UV_HANDLE_CONNECTION)) { |
|
|
uv_set_sys_error(UV_EINVAL); |
|
|
uv_set_error(UV_EINVAL, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (handle->flags & UV_HANDLE_READING) { |
|
|
if (handle->flags & UV_HANDLE_READING) { |
|
|
uv_set_sys_error(UV_EALREADY); |
|
|
uv_set_error(UV_EALREADY, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (handle->flags & UV_HANDLE_EOF) { |
|
|
if (handle->flags & UV_HANDLE_EOF) { |
|
|
uv_set_sys_error(UV_EOF); |
|
|
uv_set_error(UV_EOF, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -435,19 +521,19 @@ int uv_pipe_write(uv_write_t* req, uv_pipe_t* handle, uv_buf_t bufs[], int bufcn |
|
|
int result; |
|
|
int result; |
|
|
|
|
|
|
|
|
if (bufcnt != 1) { |
|
|
if (bufcnt != 1) { |
|
|
uv_set_sys_error(UV_ENOTSUP); |
|
|
uv_set_error(UV_ENOTSUP, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
assert(handle->handle != INVALID_HANDLE_VALUE); |
|
|
assert(handle->handle != INVALID_HANDLE_VALUE); |
|
|
|
|
|
|
|
|
if (!(handle->flags & UV_HANDLE_CONNECTION)) { |
|
|
if (!(handle->flags & UV_HANDLE_CONNECTION)) { |
|
|
uv_set_sys_error(UV_EINVAL); |
|
|
uv_set_error(UV_EINVAL, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (handle->flags & UV_HANDLE_SHUTTING) { |
|
|
if (handle->flags & UV_HANDLE_SHUTTING) { |
|
|
uv_set_sys_error(UV_EOF); |
|
|
uv_set_error(UV_EOF, 0); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -485,7 +571,7 @@ int uv_pipe_write(uv_write_t* req, uv_pipe_t* handle, uv_buf_t bufs[], int bufcn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) { |
|
|
void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) { |
|
|
DWORD bytes, avail, err, mode; |
|
|
DWORD bytes, avail; |
|
|
uv_buf_t buf; |
|
|
uv_buf_t buf; |
|
|
|
|
|
|
|
|
assert(handle->type == UV_NAMED_PIPE); |
|
|
assert(handle->type == UV_NAMED_PIPE); |
|
@ -601,7 +687,7 @@ void uv_process_pipe_accept_req(uv_pipe_t* handle, uv_req_t* raw_req) { |
|
|
req->pipeHandle = INVALID_HANDLE_VALUE; |
|
|
req->pipeHandle = INVALID_HANDLE_VALUE; |
|
|
} |
|
|
} |
|
|
if (!(handle->flags & UV_HANDLE_CLOSING)) { |
|
|
if (!(handle->flags & UV_HANDLE_CLOSING)) { |
|
|
uv_pipe_queue_accept(handle, req); |
|
|
uv_pipe_queue_accept(handle, req, FALSE); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|