From 580a5b464f304184478c4eb8d8374234071dae81 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 21 Jul 2011 17:55:24 +0200 Subject: [PATCH] uv-unix: uv_pipe_listen: raise UV_ENOTCONN if pipe not bound Fixes failing test pipe_listen_without_bind. --- src/uv-unix.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uv-unix.c b/src/uv-unix.c index 52ce5b2c..db5b1b9e 100644 --- a/src/uv-unix.c +++ b/src/uv-unix.c @@ -1862,6 +1862,13 @@ int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb) { int status; saved_errno = errno; + status = -1; + + if (handle->fd == -1) { + uv_err_new_artificial((uv_handle_t*)handle, UV_ENOTCONN); + goto out; + } + assert(handle->fd >= 0); if ((status = listen(handle->fd, SOMAXCONN)) == -1) { uv_err_new((uv_handle_t*)handle, errno); @@ -1871,6 +1878,7 @@ int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb) { ev_io_start(EV_DEFAULT_ &handle->read_watcher); } +out: errno = saved_errno; return status; }