Lines Matching refs:handle

28 #include "handle-inl.h"
98 static void eof_timer_close_cb(uv_handle_t* handle);
114 int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
115 uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE);
117 handle->reqs_pending = 0;
118 handle->handle = INVALID_HANDLE_VALUE;
119 handle->name = NULL;
120 handle->pipe.conn.ipc_remote_pid = 0;
121 handle->pipe.conn.ipc_data_frame.payload_remaining = 0;
122 uv__queue_init(&handle->pipe.conn.ipc_xfer_queue);
123 handle->pipe.conn.ipc_xfer_queue_length = 0;
124 handle->ipc = ipc;
125 handle->pipe.conn.non_overlapped_writes_tail = NULL;
131 static void uv__pipe_connection_init(uv_pipe_t* handle) {
132 assert(!(handle->flags & UV_HANDLE_PIPESERVER));
133 uv__connection_init((uv_stream_t*) handle);
134 handle->read_req.data = handle;
135 handle->pipe.conn.eof_timer = NULL;
200 CloseHandle(pipe->handle);
205 pipe->handle = INVALID_HANDLE_VALUE;
285 /* Create server pipe handle. */
294 /* Create client pipe handle. */
436 parent_pipe->handle = server_pipe;
459 uv_pipe_t* handle,
470 assert(handle->flags & UV_HANDLE_CONNECTION);
471 assert(!(handle->flags & UV_HANDLE_PIPESERVER));
472 if (handle->flags & UV_HANDLE_CLOSING)
474 if (handle->handle != INVALID_HANDLE_VALUE)
481 * SetNamedPipeHandleState can fail if the handle doesn't have either
483 * But if the handle already has the desired wait and blocking modes
515 handle->flags |= UV_HANDLE_NON_OVERLAPPED_PIPE;
516 handle->pipe.conn.readfile_thread_handle = NULL;
517 InitializeCriticalSection(&handle->pipe.conn.readfile_thread_lock);
522 (ULONG_PTR) handle,
524 handle->flags |= UV_HANDLE_EMULATE_IOCP;
528 handle->handle = pipeHandle;
529 handle->u.fd = fd;
530 handle->flags |= duplex_flags;
536 static int pipe_alloc_accept(uv_loop_t* loop, uv_pipe_t* handle,
541 CreateNamedPipeW(handle->name,
554 (ULONG_PTR) handle,
559 /* Stash a handle in the server object for use from places such as
562 handle->handle = req->pipeHandle;
570 uv_pipe_t* handle;
575 handle = (uv_pipe_t*) req->handle;
576 assert(handle);
577 loop = handle->loop;
580 FlushFileBuffers(handle->handle);
589 void uv__pipe_shutdown(uv_loop_t* loop, uv_pipe_t* handle, uv_shutdown_t *req) {
595 assert(handle->flags & UV_HANDLE_CONNECTION);
597 assert(handle->stream.conn.write_reqs_pending == 0);
600 if (handle->flags & UV_HANDLE_CLOSING) {
606 nt_status = pNtQueryInformationFile(handle->handle,
614 handle->flags |= UV_HANDLE_WRITABLE; /* Questionable. */
632 handle->flags |= UV_HANDLE_WRITABLE; /* Questionable. */
639 void uv__pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
642 assert(handle->reqs_pending == 0);
643 assert(handle->flags & UV_HANDLE_CLOSING);
644 assert(!(handle->flags & UV_HANDLE_CLOSED));
646 if (handle->flags & UV_HANDLE_CONNECTION) {
648 while (!uv__queue_empty(&handle->pipe.conn.ipc_xfer_queue)) {
652 q = uv__queue_head(&handle->pipe.conn.ipc_xfer_queue);
668 handle->pipe.conn.ipc_xfer_queue_length = 0;
670 if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
671 if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) {
672 UnregisterWait(handle->read_req.wait_handle);
673 handle->read_req.wait_handle = INVALID_HANDLE_VALUE;
675 if (handle->read_req.event_handle != NULL) {
676 CloseHandle(handle->read_req.event_handle);
677 handle->read_req.event_handle = NULL;
681 if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)
682 DeleteCriticalSection(&handle->pipe.conn.readfile_thread_lock);
685 if (handle->flags & UV_HANDLE_PIPESERVER) {
686 assert(handle->pipe.serv.accept_reqs);
687 uv__free(handle->pipe.serv.accept_reqs);
688 handle->pipe.serv.accept_reqs = NULL;
691 uv__handle_close(handle);
695 void uv_pipe_pending_instances(uv_pipe_t* handle, int count) {
696 if (handle->flags & UV_HANDLE_BOUND)
698 handle->pipe.serv.pending_instances = count;
699 handle->flags |= UV_HANDLE_PIPESERVER;
704 int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
705 return uv_pipe_bind2(handle, name, strlen(name), 0);
709 int uv_pipe_bind2(uv_pipe_t* handle,
713 uv_loop_t* loop = handle->loop;
734 if (handle->flags & UV_HANDLE_BOUND) {
738 if (uv__is_closing(handle)) {
750 if (!(handle->flags & UV_HANDLE_PIPESERVER)) {
751 handle->pipe.serv.pending_instances = default_pending_pipe_instances;
755 handle->pipe.serv.accept_reqs = (uv_pipe_accept_t*)
756 uv__malloc(sizeof(uv_pipe_accept_t) * handle->pipe.serv.pending_instances);
757 if (handle->pipe.serv.accept_reqs == NULL) {
761 for (i = 0; i < handle->pipe.serv.pending_instances; i++) {
762 req = &handle->pipe.serv.accept_reqs[i];
764 req->data = handle;
770 err = uv__convert_utf8_to_utf16(name_copy, &handle->name);
783 handle,
784 &handle->pipe.serv.accept_reqs[0],
797 handle->pipe.serv.pending_accepts = NULL;
798 handle->flags |= UV_HANDLE_PIPESERVER;
799 handle->flags |= UV_HANDLE_BOUND;
804 uv__free(handle->pipe.serv.accept_reqs);
805 uv__free(handle->name);
807 handle->pipe.serv.accept_reqs = NULL;
808 handle->name = NULL;
816 uv_pipe_t* handle;
823 handle = (uv_pipe_t*) req->handle;
824 assert(handle);
825 loop = handle->loop;
857 uv_pipe_t* handle,
863 err = uv_pipe_connect2(req, handle, name, strlen(name), 0, cb);
866 loop = handle->loop;
870 handle->reqs_pending++;
871 REGISTER_HANDLE_REQ(loop, handle, req);
877 uv_pipe_t* handle,
889 loop = handle->loop;
891 req->handle = (uv_stream_t*) handle;
921 if (handle->flags & UV_HANDLE_PIPESERVER) {
925 if (handle->flags & UV_HANDLE_CONNECTION) {
929 uv__pipe_connection_init(handle);
932 err = uv__convert_utf8_to_utf16(name_copy, &handle->name);
941 pipeHandle = open_named_pipe(handle->name, &duplex_flags);
944 nameSize = (wcslen(handle->name) + 1) * sizeof(WCHAR);
950 memcpy(req->u.connect.name, handle->name, nameSize);
962 REGISTER_HANDLE_REQ(loop, handle, req);
963 handle->reqs_pending++;
976 handle->reqs_pending++;
977 REGISTER_HANDLE_REQ(loop, handle, req);
983 if (handle->name) {
984 uv__free(handle->name);
985 handle->name = NULL;
994 handle->reqs_pending++;
995 REGISTER_HANDLE_REQ(loop, handle, req);
1000 void uv__pipe_interrupt_read(uv_pipe_t* handle) {
1003 if (!(handle->flags & UV_HANDLE_READ_PENDING))
1005 if (handle->flags & UV_HANDLE_CANCELLATION_PENDING)
1007 if (handle->handle == INVALID_HANDLE_VALUE)
1008 return; /* Pipe handle closed. */
1010 if (!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)) {
1012 r = CancelIoEx(handle->handle, &handle->read_req.u.io.overlapped);
1018 volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle;
1020 EnterCriticalSection(&handle->pipe.conn.readfile_thread_lock);
1039 LeaveCriticalSection(&handle->pipe.conn.readfile_thread_lock);
1043 handle->flags |= UV_HANDLE_CANCELLATION_PENDING;
1047 void uv__pipe_read_stop(uv_pipe_t* handle) {
1048 handle->flags &= ~UV_HANDLE_READING;
1049 DECREASE_ACTIVE_COUNT(handle->loop, handle);
1050 uv__pipe_interrupt_read(handle);
1056 void uv__pipe_close(uv_loop_t* loop, uv_pipe_t* handle) {
1060 if (handle->flags & UV_HANDLE_READING) {
1061 handle->flags &= ~UV_HANDLE_READING;
1062 DECREASE_ACTIVE_COUNT(loop, handle);
1065 if (handle->flags & UV_HANDLE_LISTENING) {
1066 handle->flags &= ~UV_HANDLE_LISTENING;
1067 DECREASE_ACTIVE_COUNT(loop, handle);
1070 handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
1072 uv__handle_closing(handle);
1074 uv__pipe_interrupt_read(handle);
1076 if (handle->name) {
1077 uv__free(handle->name);
1078 handle->name = NULL;
1081 if (handle->flags & UV_HANDLE_PIPESERVER) {
1082 for (i = 0; i < handle->pipe.serv.pending_instances; i++) {
1083 pipeHandle = handle->pipe.serv.accept_reqs[i].pipeHandle;
1086 handle->pipe.serv.accept_reqs[i].pipeHandle = INVALID_HANDLE_VALUE;
1089 handle->handle = INVALID_HANDLE_VALUE;
1092 if (handle->flags & UV_HANDLE_CONNECTION) {
1093 eof_timer_destroy(handle);
1096 if ((handle->flags & UV_HANDLE_CONNECTION)
1097 && handle->handle != INVALID_HANDLE_VALUE) {
1099 close_pipe(handle);
1102 if (handle->reqs_pending == 0)
1103 uv__want_endgame(loop, (uv_handle_t*) handle);
1107 static void uv__pipe_queue_accept(uv_loop_t* loop, uv_pipe_t* handle,
1109 assert(handle->flags & UV_HANDLE_LISTENING);
1111 if (!firstInstance && !pipe_alloc_accept(loop, handle, req, FALSE)) {
1114 handle->reqs_pending++;
1134 handle->reqs_pending++;
1139 handle->reqs_pending++;
1183 /* Initialize the client handle and copy the pipeHandle to the client */
1184 pipe_client->handle = req->pipeHandle;
1192 server->handle = INVALID_HANDLE_VALUE;
1203 int uv__pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
1204 uv_loop_t* loop = handle->loop;
1207 if (handle->flags & UV_HANDLE_LISTENING) {
1208 handle->stream.serv.connection_cb = cb;
1211 if (!(handle->flags & UV_HANDLE_BOUND)) {
1215 if (handle->flags & UV_HANDLE_READING) {
1219 if (!(handle->flags & UV_HANDLE_PIPESERVER)) {
1223 if (handle->ipc) {
1227 handle->flags |= UV_HANDLE_LISTENING;
1228 INCREASE_ACTIVE_COUNT(loop, handle);
1229 handle->stream.serv.connection_cb = cb;
1231 /* First pipe handle should have already been created in uv_pipe_bind */
1232 assert(handle->pipe.serv.accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE);
1234 for (i = 0; i < handle->pipe.serv.pending_instances; i++) {
1235 uv__pipe_queue_accept(loop, handle, &handle->pipe.serv.accept_reqs[i], i == 0);
1244 uv_pipe_t* handle = (uv_pipe_t*) req->data;
1245 uv_loop_t* loop = handle->loop;
1246 volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle;
1247 CRITICAL_SECTION* lock = &handle->pipe.conn.readfile_thread_lock;
1253 assert(handle->type == UV_NAMED_PIPE);
1257 /* Create a handle to the current thread. */
1269 /* The lock needs to be held when thread handle is modified. */
1286 if (!ReadFile(handle->handle, &uv_zero_, 0, &bytes, NULL))
1300 /* Close the handle to the current thread. */
1319 uv_pipe_t* handle = (uv_pipe_t*) req->handle;
1320 uv_loop_t* loop = handle->loop;
1324 assert(handle->type == UV_NAMED_PIPE);
1326 result = WriteFile(handle->handle,
1343 uv_tcp_t* handle;
1347 handle = (uv_tcp_t*)req->data;
1348 assert(handle != NULL);
1351 if (!PostQueuedCompletionStatus(handle->loop->iocp,
1362 uv_tcp_t* handle;
1366 handle = (uv_tcp_t*)req->handle;
1367 assert(handle != NULL);
1370 if (!PostQueuedCompletionStatus(handle->loop->iocp,
1379 static void uv__pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) {
1383 assert(handle->flags & UV_HANDLE_READING);
1384 assert(!(handle->flags & UV_HANDLE_READ_PENDING));
1386 assert(handle->handle != INVALID_HANDLE_VALUE);
1388 req = &handle->read_req;
1390 if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
1391 handle->pipe.conn.readfile_thread_handle = NULL; /* Reset cancellation. */
1401 if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
1407 result = ReadFile(handle->handle,
1419 if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
1432 eof_timer_start(handle);
1433 handle->flags |= UV_HANDLE_READ_PENDING;
1434 handle->reqs_pending++;
1439 handle->flags |= UV_HANDLE_READ_PENDING;
1440 handle->reqs_pending++;
1444 int uv__pipe_read_start(uv_pipe_t* handle,
1447 uv_loop_t* loop = handle->loop;
1449 handle->flags |= UV_HANDLE_READING;
1450 INCREASE_ACTIVE_COUNT(loop, handle);
1451 handle->read_cb = read_cb;
1452 handle->alloc_cb = alloc_cb;
1456 if (!(handle->flags & UV_HANDLE_READ_PENDING)) {
1457 if (handle->flags & UV_HANDLE_EMULATE_IOCP &&
1458 handle->read_req.event_handle == NULL) {
1459 handle->read_req.event_handle = CreateEvent(NULL, 0, 0, NULL);
1460 if (handle->read_req.event_handle == NULL) {
1464 uv__pipe_queue_read(loop, handle);
1471 static void uv__insert_non_overlapped_write_req(uv_pipe_t* handle,
1474 if (handle->pipe.conn.non_overlapped_writes_tail) {
1476 handle->pipe.conn.non_overlapped_writes_tail->next_req;
1477 handle->pipe.conn.non_overlapped_writes_tail->next_req = (uv_req_t*)req;
1478 handle->pipe.conn.non_overlapped_writes_tail = req;
1481 handle->pipe.conn.non_overlapped_writes_tail = req;
1486 static uv_write_t* uv_remove_non_overlapped_write_req(uv_pipe_t* handle) {
1489 if (handle->pipe.conn.non_overlapped_writes_tail) {
1490 req = (uv_write_t*)handle->pipe.conn.non_overlapped_writes_tail->next_req;
1492 if (req == handle->pipe.conn.non_overlapped_writes_tail) {
1493 handle->pipe.conn.non_overlapped_writes_tail = NULL;
1495 handle->pipe.conn.non_overlapped_writes_tail->next_req =
1507 static void uv__queue_non_overlapped_write(uv_pipe_t* handle) {
1508 uv_write_t* req = uv_remove_non_overlapped_write_req(handle);
1581 uv_pipe_t* handle,
1590 assert(handle->handle != INVALID_HANDLE_VALUE);
1593 req->handle = (uv_stream_t*) handle;
1603 if (handle->flags & (UV_HANDLE_EMULATE_IOCP | UV_HANDLE_BLOCKING_WRITES)) {
1626 if ((handle->flags &
1631 WriteFile(handle->handle, write_buf.base, write_buf.len, &bytes, NULL);
1641 REGISTER_HANDLE_REQ(loop, handle, req);
1642 handle->reqs_pending++;
1643 handle->stream.conn.write_reqs_pending++;
1646 } else if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
1648 uv__insert_non_overlapped_write_req(handle, req);
1649 if (handle->stream.conn.write_reqs_pending == 0) {
1650 uv__queue_non_overlapped_write(handle);
1655 handle->write_queue_size += req->u.io.queued_bytes;
1656 } else if (handle->flags & UV_HANDLE_BLOCKING_WRITES) {
1658 result = WriteFile(handle->handle,
1677 handle->write_queue_size += req->u.io.queued_bytes;
1689 REGISTER_HANDLE_REQ(loop, handle, req);
1690 handle->reqs_pending++;
1691 handle->stream.conn.write_reqs_pending++;
1694 result = WriteFile(handle->handle,
1710 handle->write_queue_size += req->u.io.queued_bytes;
1713 if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
1722 REGISTER_HANDLE_REQ(loop, handle, req);
1723 handle->reqs_pending++;
1724 handle->stream.conn.write_reqs_pending++;
1730 static DWORD uv__pipe_get_ipc_remote_pid(uv_pipe_t* handle) {
1731 DWORD* pid = &handle->pipe.conn.ipc_remote_pid;
1737 GetNamedPipeClientProcessId(handle->handle, pid);
1739 GetNamedPipeServerProcessId(handle->handle, pid);
1749 uv_pipe_t* handle,
1775 /* Verify that `send_handle` it is indeed a tcp handle. */
1779 /* Export the tcp handle. */
1781 uv__pipe_get_ipc_remote_pid(handle),
1838 err = uv__pipe_write_data(loop, req, handle, bufs, buf_count, cb, 1);
1851 uv_pipe_t* handle,
1856 if (handle->ipc) {
1858 return uv__pipe_write_ipc(loop, req, handle, bufs, nbufs, send_handle, cb);
1862 return uv__pipe_write_data(loop, req, handle, bufs, nbufs, cb, 0);
1867 static void uv__pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
1871 eof_timer_destroy(handle);
1873 uv_read_stop((uv_stream_t*) handle);
1875 handle->read_cb((uv_stream_t*) handle, UV_EOF, &buf);
1879 static void uv__pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error,
1883 eof_timer_destroy(handle);
1885 uv_read_stop((uv_stream_t*) handle);
1887 handle->read_cb((uv_stream_t*)handle, uv_translate_sys_error(error), &buf);
1891 static void uv__pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle,
1894 uv__pipe_read_eof(loop, handle, buf);
1896 uv__pipe_read_error(loop, handle, error, buf);
1902 uv_pipe_t* handle,
1914 uv__queue_insert_tail(&handle->pipe.conn.ipc_xfer_queue, &item->member);
1915 handle->pipe.conn.ipc_xfer_queue_length++;
1944 uv_pipe_t* handle,
1952 handle->alloc_cb((uv_handle_t*) handle, suggested_bytes, &buf);
1954 handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf);
1966 if (!ReadFile(handle->handle, buf.base, max_bytes, &bytes_read, NULL)) {
1967 uv__pipe_read_error_or_eof(loop, handle, GetLastError(), buf);
1972 handle->read_cb((uv_stream_t*) handle, bytes_read, &buf);
1978 static DWORD uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) {
1979 uint32_t* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining;
1985 uv__pipe_read_data(loop, handle, *data_remaining, *data_remaining);
1998 handle->handle, &frame_header, sizeof frame_header);
2038 err = uv__pipe_read_exactly(handle->handle, &xfer_info, sizeof xfer_info);
2043 uv__pipe_queue_ipc_xfer_info(handle, xfer_type, &xfer_info);
2054 uv__pipe_read_error_or_eof(loop, handle, err, uv_null_buf_);
2060 uv_pipe_t* handle,
2062 assert(handle->type == UV_NAMED_PIPE);
2064 handle->flags &= ~(UV_HANDLE_READ_PENDING | UV_HANDLE_CANCELLATION_PENDING);
2065 DECREASE_PENDING_REQ_COUNT(handle);
2066 eof_timer_stop(handle);
2071 if (!(handle->flags & UV_HANDLE_READING))
2082 uv__pipe_read_error_or_eof(loop, handle, err, uv_null_buf_);
2091 if (!PeekNamedPipe(handle->handle, NULL, 0, NULL, &avail, NULL))
2092 uv__pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_);
2096 while (avail > 0 && handle->flags & UV_HANDLE_READING) {
2099 handle->ipc ? uv__pipe_read_ipc(loop, handle)
2100 : uv__pipe_read_data(loop, handle, avail, (DWORD) -1);
2119 if ((handle->flags & UV_HANDLE_READING) &&
2120 !(handle->flags & UV_HANDLE_READ_PENDING)) {
2121 uv__pipe_queue_read(loop, handle);
2126 void uv__process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
2130 assert(handle->type == UV_NAMED_PIPE);
2132 assert(handle->write_queue_size >= req->u.io.queued_bytes);
2133 handle->write_queue_size -= req->u.io.queued_bytes;
2135 UNREGISTER_HANDLE_REQ(loop, handle, req);
2137 if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
2163 handle->stream.conn.write_reqs_pending--;
2165 if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE &&
2166 handle->pipe.conn.non_overlapped_writes_tail) {
2167 assert(handle->stream.conn.write_reqs_pending > 0);
2168 uv__queue_non_overlapped_write(handle);
2171 if (handle->stream.conn.write_reqs_pending == 0 &&
2172 uv__is_stream_shutting(handle))
2173 uv__pipe_shutdown(loop, handle, handle->stream.conn.shutdown_req);
2175 DECREASE_PENDING_REQ_COUNT(handle);
2179 void uv__process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle,
2183 assert(handle->type == UV_NAMED_PIPE);
2185 if (handle->flags & UV_HANDLE_CLOSING) {
2188 DECREASE_PENDING_REQ_COUNT(handle);
2194 req->next_pending = handle->pipe.serv.pending_accepts;
2195 handle->pipe.serv.pending_accepts = req;
2197 if (handle->stream.serv.connection_cb) {
2198 handle->stream.serv.connection_cb((uv_stream_t*)handle, 0);
2205 if (!(handle->flags & UV_HANDLE_CLOSING)) {
2206 uv__pipe_queue_accept(loop, handle, req, FALSE);
2210 DECREASE_PENDING_REQ_COUNT(handle);
2214 void uv__process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle,
2220 assert(handle->type == UV_NAMED_PIPE);
2222 UNREGISTER_HANDLE_REQ(loop, handle, req);
2228 if (handle->flags & UV_HANDLE_CLOSING)
2231 err = uv__set_pipe_handle(loop, handle, pipeHandle, -1, duplex_flags);
2241 DECREASE_PENDING_REQ_COUNT(handle);
2246 void uv__process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle,
2250 assert(handle->type == UV_NAMED_PIPE);
2253 handle->stream.conn.shutdown_req = NULL;
2254 UNREGISTER_HANDLE_REQ(loop, handle, req);
2256 if (handle->flags & UV_HANDLE_CLOSING) {
2263 if (handle->flags & UV_HANDLE_READABLE) {
2266 eof_timer_init(handle);
2270 if (handle->flags & UV_HANDLE_READ_PENDING) {
2271 eof_timer_start(handle);
2277 close_pipe(handle);
2285 DECREASE_PENDING_REQ_COUNT(handle);
2367 static void eof_timer_close_cb(uv_handle_t* handle) {
2368 assert(handle->type == UV_TIMER);
2369 uv__free(handle);
2391 * underlying OS handle and forget about the original fd.
2392 * We could also opt to use the original OS handle and just never close it,
2409 /* Determine what kind of permissions we have on this handle.
2456 static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) {
2469 if (handle->name != NULL) {
2472 return uv__copy_utf16_to_utf8(handle->name, -1, buffer, size);
2475 if (handle->handle == INVALID_HANDLE_VALUE) {
2481 * blocking operation on the queried handle. If the pipe handle is
2483 * the pipe handle, which could cause a deadlock. To avoid this, interrupt
2485 if (handle->flags & UV_HANDLE_CONNECTION &&
2486 handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
2487 uv__pipe_interrupt_read((uv_pipe_t*) handle); /* cast away const warning */
2490 nt_status = pNtQueryInformationFile(handle->handle,
2503 nt_status = pNtQueryInformationFile(handle->handle,
2550 int uv_pipe_pending_count(uv_pipe_t* handle) {
2551 if (!handle->ipc)
2553 return handle->pipe.conn.ipc_xfer_queue_length;
2557 int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) {
2558 if (handle->flags & UV_HANDLE_BOUND)
2559 return uv__pipe_getname(handle, buffer, size);
2561 if (handle->flags & UV_HANDLE_CONNECTION ||
2562 handle->handle != INVALID_HANDLE_VALUE) {
2571 int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) {
2573 if (handle->flags & UV_HANDLE_BOUND)
2576 if (handle->handle != INVALID_HANDLE_VALUE)
2577 return uv__pipe_getname(handle, buffer, size);
2579 if (handle->flags & UV_HANDLE_CONNECTION) {
2580 if (handle->name != NULL)
2581 return uv__pipe_getname(handle, buffer, size);
2588 uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) {
2589 if (!handle->ipc)
2591 if (handle->pipe.conn.ipc_xfer_queue_length == 0)
2597 int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
2605 if (handle == NULL || handle->handle == INVALID_HANDLE_VALUE)
2622 if (GetSecurityInfo(handle->handle,
2651 if (SetSecurityInfo(handle->handle,