From 272f164e6a4f5c1e34b57bcbf136bda1c8291b25 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 21 Jul 2011 19:43:30 +0200 Subject: [PATCH] uv-unix: uv_pipe_bind: raise UV_EACCESS on inaccessible socket Fixes failing test pipe_bind_error_addrnotavail. --- src/uv-unix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uv-unix.c b/src/uv-unix.c index 869daf73..3c486a85 100644 --- a/src/uv-unix.c +++ b/src/uv-unix.c @@ -1831,7 +1831,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) { * on EADDRINUSE. Unlinking and trying to bind again opens * a window for races with other threads and processes. */ - uv_err_new((uv_handle_t*)handle, errno); + uv_err_new((uv_handle_t*)handle, (errno == ENOENT) ? EACCES : errno); goto out; #else /* @@ -1840,7 +1840,8 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) { if (errno != EADDRINUSE || unlink(pipe_fname) == -1 || bind(sockfd, (struct sockaddr*)&sun, sizeof sun) == -1) { - uv_err_new((uv_handle_t*)handle, errno); + /* Convert ENOENT to EACCES for compatibility with Windows. */ + uv_err_new((uv_handle_t*)handle, (errno == ENOENT) ? EACCES : errno); goto out; } #endif