windows: return UV_ENOTSOCK when doing uv_pipe_connect to a file
This commit is contained in:
parent
0459097745
commit
6bbccf1fe0
@ -115,6 +115,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
|
|||||||
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
|
case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
|
||||||
case WSAETIMEDOUT: return UV_ETIMEDOUT;
|
case WSAETIMEDOUT: return UV_ETIMEDOUT;
|
||||||
case WSAHOST_NOT_FOUND: return UV_ENOENT;
|
case WSAHOST_NOT_FOUND: return UV_ENOENT;
|
||||||
|
case WSAENOTSOCK: return UV_ENOTSOCK;
|
||||||
default: return UV_UNKNOWN;
|
default: return UV_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -560,6 +560,12 @@ void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
|
|||||||
|
|
||||||
assert(handle->handle != INVALID_HANDLE_VALUE);
|
assert(handle->handle != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
/* Ensure that what we just opened is actually a pipe */
|
||||||
|
if (!GetNamedPipeInfo(handle->handle, NULL, NULL, NULL, NULL)) {
|
||||||
|
errno = WSAENOTSOCK;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (uv_set_pipe_handle(loop, (uv_pipe_t*)req->handle, handle->handle)) {
|
if (uv_set_pipe_handle(loop, (uv_pipe_t*)req->handle, handle->handle)) {
|
||||||
errno = GetLastError();
|
errno = GetLastError();
|
||||||
goto error;
|
goto error;
|
||||||
|
|||||||
@ -58,6 +58,7 @@ TEST_DECLARE (pipe_bind_error_addrnotavail)
|
|||||||
TEST_DECLARE (pipe_bind_error_inval)
|
TEST_DECLARE (pipe_bind_error_inval)
|
||||||
TEST_DECLARE (pipe_listen_without_bind)
|
TEST_DECLARE (pipe_listen_without_bind)
|
||||||
TEST_DECLARE (pipe_connect_bad_name)
|
TEST_DECLARE (pipe_connect_bad_name)
|
||||||
|
TEST_DECLARE (pipe_connect_to_file)
|
||||||
TEST_DECLARE (connection_fail)
|
TEST_DECLARE (connection_fail)
|
||||||
TEST_DECLARE (connection_fail_doesnt_auto_close)
|
TEST_DECLARE (connection_fail_doesnt_auto_close)
|
||||||
TEST_DECLARE (shutdown_eof)
|
TEST_DECLARE (shutdown_eof)
|
||||||
@ -159,6 +160,7 @@ TASK_LIST_START
|
|||||||
TEST_OUTPUT_ENTRY (platform_output)
|
TEST_OUTPUT_ENTRY (platform_output)
|
||||||
|
|
||||||
TEST_ENTRY (pipe_connect_bad_name)
|
TEST_ENTRY (pipe_connect_bad_name)
|
||||||
|
TEST_ENTRY (pipe_connect_to_file)
|
||||||
|
|
||||||
TEST_ENTRY (tty)
|
TEST_ENTRY (tty)
|
||||||
TEST_ENTRY (stdio_over_pipes)
|
TEST_ENTRY (stdio_over_pipes)
|
||||||
|
|||||||
@ -50,6 +50,14 @@ static void connect_cb(uv_connect_t* connect_req, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void connect_cb_file(uv_connect_t* connect_req, int status) {
|
||||||
|
ASSERT(status == -1);
|
||||||
|
ASSERT(uv_last_error(uv_default_loop()).code == UV_ENOTSOCK);
|
||||||
|
uv_close((uv_handle_t*)connect_req->handle, close_cb);
|
||||||
|
connect_cb_called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_IMPL(pipe_connect_bad_name) {
|
TEST_IMPL(pipe_connect_bad_name) {
|
||||||
uv_pipe_t client;
|
uv_pipe_t client;
|
||||||
uv_connect_t req;
|
uv_connect_t req;
|
||||||
@ -66,3 +74,22 @@ TEST_IMPL(pipe_connect_bad_name) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_IMPL(pipe_connect_to_file) {
|
||||||
|
const char* path = "test/fixtures/empty_file";
|
||||||
|
uv_pipe_t client;
|
||||||
|
uv_connect_t req;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = uv_pipe_init(uv_default_loop(), &client, 0);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
uv_pipe_connect(&req, &client, path, connect_cb_file);
|
||||||
|
|
||||||
|
uv_run(uv_default_loop());
|
||||||
|
|
||||||
|
ASSERT(close_cb_called == 1);
|
||||||
|
ASSERT(connect_cb_called == 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user