Skip to content

Commit

Permalink
Revert "win: implement uv_try_write() for pipes(libuv#3825 1/2)"
Browse files Browse the repository at this point in the history
This reverts commit 244e0e2.

For some reason this is breaking node.js IPC. I plan to investigate it
but we can let this for the next release.t

PR-URL: libuv#4003
  • Loading branch information
santigimeno committed May 19, 2023
1 parent 03bb703 commit 0726149
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 207 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-pipe-close-stdout-read-stdin.c \
test/test-pipe-set-non-blocking.c \
test/test-pipe-set-fchmod.c \
test/test-pipe-try-write.c \
test/test-platform-output.c \
test/test-poll.c \
test/test-poll-close.c \
Expand Down
2 changes: 0 additions & 2 deletions src/win/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ int uv__pipe_write(uv_loop_t* loop,
uv_stream_t* send_handle,
uv_write_cb cb);
void uv__pipe_shutdown(uv_loop_t* loop, uv_pipe_t* handle, uv_shutdown_t* req);
int uv__pipe_try_write(uv_pipe_t* handle, const uv_buf_t bufs[],
unsigned int nbufs);

void uv__process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
uv_req_t* req);
Expand Down
72 changes: 0 additions & 72 deletions src/win/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,78 +1782,6 @@ int uv__pipe_write(uv_loop_t* loop,
}


int uv__pipe_try_write(uv_pipe_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs) {
OVERLAPPED overlapped;
const uv_buf_t* buf;
int bytes_written;
unsigned int idx;
DWORD timeout;
DWORD err;

if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
return UV_EAGAIN;
}

if (handle->stream.conn.write_reqs_pending > 0) {
return UV_EAGAIN;
}

timeout = 0;
if (handle->flags & UV_HANDLE_BLOCKING_WRITES) {
timeout = INFINITE;
}

memset(&overlapped, 0, sizeof(overlapped));

overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (overlapped.hEvent == NULL) {
uv_fatal_error(GetLastError(), "CreateEvent");
}

bytes_written = 0;
for (err = 0, idx = 0; idx < nbufs; err = 0, idx += 1) {
buf = &bufs[idx];

if (WriteFile(handle->handle, buf->base, buf->len, NULL, &overlapped)) {
bytes_written += buf->len;
continue;
}

err = GetLastError();
if (err != ERROR_IO_PENDING) {
break;
}

err = WaitForSingleObject(overlapped.hEvent, timeout);
if (err == WAIT_OBJECT_0) {
bytes_written += buf->len;
continue;
}

if (err == WAIT_TIMEOUT &&
CancelIo(handle->handle) &&
GetOverlappedResult(handle->handle, &overlapped, &err, TRUE)) {
bytes_written += err;
err = WSAEWOULDBLOCK; /* Translates to UV_EAGAIN. */
} else {
err = GetLastError();
}

break;
}

CloseHandle(overlapped.hEvent);

if (bytes_written == 0 && err != 0) {
return uv_translate_sys_error(err);
}

return bytes_written;
}


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
Expand Down
2 changes: 1 addition & 1 deletion src/win/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int uv_try_write(uv_stream_t* stream,
case UV_TTY:
return uv__tty_try_write((uv_tty_t*) stream, bufs, nbufs);
case UV_NAMED_PIPE:
return uv__pipe_try_write((uv_pipe_t*) stream, bufs, nbufs);
return UV_EAGAIN;
default:
assert(0);
return UV_ENOSYS;
Expand Down
6 changes: 0 additions & 6 deletions test/test-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,6 @@ TEST_DECLARE (pipe_getsockname_blocking)
TEST_DECLARE (pipe_pending_instances)
TEST_DECLARE (pipe_sendmsg)
TEST_DECLARE (pipe_server_close)
TEST_DECLARE (pipe_try_write_0)
TEST_DECLARE (pipe_try_write_1)
TEST_DECLARE (pipe_try_write_2)
TEST_DECLARE (connection_fail)
TEST_DECLARE (connection_fail_doesnt_auto_close)
TEST_DECLARE (shutdown_close_tcp)
Expand Down Expand Up @@ -597,9 +594,6 @@ TASK_LIST_START
TEST_ENTRY (pipe_connect_on_prepare)

TEST_ENTRY (pipe_server_close)
TEST_ENTRY (pipe_try_write_0)
TEST_ENTRY (pipe_try_write_1)
TEST_ENTRY (pipe_try_write_2)
#ifndef _WIN32
TEST_ENTRY (pipe_close_stdout_read_stdin)
#endif
Expand Down
125 changes: 0 additions & 125 deletions test/test-pipe-try-write.c

This file was deleted.

0 comments on commit 0726149

Please sign in to comment.