Lines Matching defs:pipe

44 /* The timeout that the pipe will wait for the remote end to write data when
51 static char pipe_prefix[] = "\\\\?\\pipe";
93 static void eof_timer_init(uv_pipe_t* pipe);
94 static void eof_timer_start(uv_pipe_t* pipe);
95 static void eof_timer_stop(uv_pipe_t* pipe);
97 static void eof_timer_destroy(uv_pipe_t* pipe);
110 snprintf(name, size, "\\\\?\\pipe\\uv\\%p-%lu", ptr, GetCurrentProcessId());
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;
125 handle->pipe.conn.non_overlapped_writes_tail = NULL;
135 handle->pipe.conn.eof_timer = NULL;
143 * Assume that we have a duplex pipe first, so attempt to
159 * If the pipe is not duplex CreateFileW fails with
197 static void close_pipe(uv_pipe_t* pipe) {
198 assert(pipe->u.fd == -1 || pipe->u.fd > 2);
199 if (pipe->u.fd == -1)
200 CloseHandle(pipe->handle);
202 _close(pipe->u.fd);
204 pipe->u.fd = -1;
205 pipe->handle = INVALID_HANDLE_VALUE;
285 /* Create server pipe handle. */
294 /* Create client pipe handle. */
312 /* Validate that the pipe was opened in the right mode. */
326 * both ends of the pipe created. */
410 * the state of the write buffer when we're trying to shutdown the pipe. */
494 * something that is not a pipe. */
502 /* Check if the pipe was created with FILE_FLAG_OVERLAPPED. */
514 /* Non-overlapped pipe. */
516 handle->pipe.conn.readfile_thread_handle = NULL;
517 InitializeCriticalSection(&handle->pipe.conn.readfile_thread_lock);
519 /* Overlapped pipe. Try to associate with IOCP. */
605 /* Try to avoid flushing the pipe buffer in the thread pool. */
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;
682 DeleteCriticalSection(&handle->pipe.conn.readfile_thread_lock);
686 assert(handle->pipe.serv.accept_reqs);
687 uv__free(handle->pipe.serv.accept_reqs);
688 handle->pipe.serv.accept_reqs = NULL;
698 handle->pipe.serv.pending_instances = count;
703 /* Creates a pipe server. */
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];
779 * Attempt to create the first pipe with FILE_FLAG_FIRST_PIPE_INSTANCE.
780 * If this fails then there's already a pipe server for the given pipe name.
784 &handle->pipe.serv.accept_reqs[0],
797 handle->pipe.serv.pending_accepts = NULL;
804 uv__free(handle->pipe.serv.accept_reqs);
807 handle->pipe.serv.accept_reqs = NULL;
828 /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. We wait
829 * up to 30 seconds for the pipe to become available with WaitNamedPipe. */
831 /* The pipe is now available, try to connect. */
952 /* Wait for the server to make a pipe instance available. */
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);
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;
1152 if (uv__queue_empty(&server->pipe.conn.ipc_xfer_queue)) {
1157 q = uv__queue_head(&server->pipe.conn.ipc_xfer_queue);
1159 server->pipe.conn.ipc_xfer_queue_length--;
1176 req = server->pipe.serv.pending_accepts;
1188 server->pipe.serv.pending_accepts = req->next_pending;
1202 /* Starts listening for connections for the given pipe. */
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);
1246 volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle;
1247 CRITICAL_SECTION* lock = &handle->pipe.conn.readfile_thread_lock;
1284 /* Block the thread until data is available on the pipe, or the read is
1391 handle->pipe.conn.readfile_thread_handle = NULL; /* Reset cancellation. */
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;
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 =
1731 DWORD* pid = &handle->pipe.conn.ipc_remote_pid;
1733 /* If the both ends of the IPC pipe are owned by the same process,
1857 /* IPC pipe write: use framing protocol. */
1860 /* Non-IPC pipe write: put data on the wire directly. */
1914 uv__queue_insert_tail(&handle->pipe.conn.ipc_xfer_queue, &item->member);
1915 handle->pipe.conn.ipc_xfer_queue_length++;
1919 /* Read an exact number of bytes from a pipe. If an error or end-of-file is
1979 uint32_t* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining;
2069 * reading the pipe in the meantime, there is nothing left to do, since there
2097 /* Depending on the type of pipe, read either IPC frames or raw data. */
2166 handle->pipe.conn.non_overlapped_writes_tail) {
2194 req->next_pending = handle->pipe.serv.pending_accepts;
2195 handle->pipe.serv.pending_accepts = req;
2264 /* Initialize and optionally start the eof timer. Only do this if the pipe
2275 /* This pipe is not readable. We can just close it to let the other end
2289 static void eof_timer_init(uv_pipe_t* pipe) {
2292 assert(pipe->pipe.conn.eof_timer == NULL);
2293 assert(pipe->flags & UV_HANDLE_CONNECTION);
2295 pipe->pipe.conn.eof_timer = (uv_timer_t*) uv__malloc(sizeof *pipe->pipe.conn.eof_timer);
2297 r = uv_timer_init(pipe->loop, pipe->pipe.conn.eof_timer);
2300 pipe->pipe.conn.eof_timer->data = pipe;
2301 uv_unref((uv_handle_t*) pipe->pipe.conn.eof_timer);
2305 static void eof_timer_start(uv_pipe_t* pipe) {
2306 assert(pipe->flags & UV_HANDLE_CONNECTION);
2308 if (pipe->pipe.conn.eof_timer != NULL) {
2309 uv_timer_start(pipe->pipe.conn.eof_timer, eof_timer_cb, eof_timeout, 0);
2314 static void eof_timer_stop(uv_pipe_t* pipe) {
2315 assert(pipe->flags & UV_HANDLE_CONNECTION);
2317 if (pipe->pipe.conn.eof_timer != NULL) {
2318 uv_timer_stop(pipe->pipe.conn.eof_timer);
2324 uv_pipe_t* pipe = (uv_pipe_t*) timer->data;
2327 assert(pipe->type == UV_NAMED_PIPE);
2333 assert(pipe->flags & UV_HANDLE_READ_PENDING);
2339 if ((pipe->flags & UV_HANDLE_READ_PENDING) &&
2340 HasOverlappedIoCompleted(&pipe->read_req.u.io.overlapped)) {
2344 /* Force both ends off the pipe. */
2345 close_pipe(pipe);
2349 uv_read_stop((uv_stream_t*) pipe);
2353 uv__pipe_read_eof(loop, pipe, uv_null_buf_);
2357 static void eof_timer_destroy(uv_pipe_t* pipe) {
2358 assert(pipe->flags & UV_HANDLE_CONNECTION);
2360 if (pipe->pipe.conn.eof_timer) {
2361 uv_close((uv_handle_t*) pipe->pipe.conn.eof_timer, eof_timer_close_cb);
2362 pipe->pipe.conn.eof_timer = NULL;
2373 int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
2383 if (pipe->flags & UV_HANDLE_PIPESERVER)
2385 if (pipe->flags & UV_HANDLE_CONNECTION)
2388 uv__pipe_connection_init(pipe);
2410 * Cygwin opens the pipe in message mode, but we can support it,
2421 if (pipe->ipc) {
2433 err = uv__set_pipe_handle(pipe->loop,
2434 pipe,
2444 if (pipe->ipc) {
2445 assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE));
2446 GetNamedPipeClientProcessId(os_handle, &pipe->pipe.conn.ipc_remote_pid);
2447 if (pipe->pipe.conn.ipc_remote_pid == GetCurrentProcessId()) {
2448 GetNamedPipeServerProcessId(os_handle, &pipe->pipe.conn.ipc_remote_pid);
2450 assert(pipe->pipe.conn.ipc_remote_pid != (DWORD)(uv_pid_t) -1);
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
2533 /* "\\\\.\\pipe" + name */
2553 return handle->pipe.conn.ipc_xfer_queue_length;
2591 if (handle->pipe.conn.ipc_xfer_queue_length == 0)