pipe: uv_pipe_listen raises UV_EINVAL on unbound socket
This commit is contained in:
parent
8e8af8fd34
commit
eed6f395d1
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user