From eed6f395d1afb62ee93b916c5d52152481fcf350 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 29 Jul 2011 03:23:36 +0200 Subject: [PATCH] pipe: uv_pipe_listen raises UV_EINVAL on unbound socket --- src/uv-unix.c | 2 +- src/win/pipe.c | 4 ++-- test/test-pipe-bind-error.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uv-unix.c b/src/uv-unix.c index 0f6433d0..412072da 100644 --- a/src/uv-unix.c +++ b/src/uv-unix.c @@ -1956,7 +1956,7 @@ static int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { status = -1; if (handle->fd == -1) { - uv_err_new_artificial((uv_handle_t*)handle, UV_ENOTCONN); + uv_err_new_artificial((uv_handle_t*)handle, UV_EINVAL); goto out; } assert(handle->fd >= 0); diff --git a/src/win/pipe.c b/src/win/pipe.c index 7c98ab0e..ee627c88 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -444,13 +444,13 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { HANDLE pipeHandle; if (handle->flags & UV_HANDLE_BIND_ERROR) { - LOOP->last_error = handle->error; + uv_set_error(UV_EINVAL, 0); return -1; } if (!(handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_GIVEN_OS_HANDLE)) { - uv_set_error(UV_ENOTCONN, 0); + uv_set_error(UV_EINVAL, 0); return -1; } diff --git a/test/test-pipe-bind-error.c b/test/test-pipe-bind-error.c index 69aaaa20..80c76da8 100644 --- a/test/test-pipe-bind-error.c +++ b/test/test-pipe-bind-error.c @@ -64,7 +64,7 @@ TEST_IMPL(pipe_bind_error_addrinuse) { r = uv_listen((uv_stream_t*)&server2, SOMAXCONN, NULL); ASSERT(r == -1); - ASSERT(uv_last_error().code == UV_EADDRINUSE); + ASSERT(uv_last_error().code == UV_EINVAL); uv_close((uv_handle_t*)&server1, close_cb); uv_close((uv_handle_t*)&server2, close_cb); @@ -136,7 +136,7 @@ TEST_IMPL(pipe_listen_without_bind) { r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); ASSERT(r == -1); - ASSERT(uv_last_error().code == UV_ENOTCONN); + ASSERT(uv_last_error().code == UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb);