Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: handle EINPROGRESS for unix sockets
Browse files Browse the repository at this point in the history
Before this commit, it was assumed that connect() on UNIX sockets never
returns EINPROGRESS. It turned out to be a bad assumption: Dave Pacheco
reports sporadic hangups on SmartOS because of that.

It's not clear to me _why_ the Illumos kernel returns that error but
that's inconsequential: whatever the cause, libuv needs to handle it
and now it does.

Fixes nodejs/node-v0.x-archive#4785.
  • Loading branch information
bnoordhuis committed Feb 21, 2013
1 parent 1d64c82 commit 3348cd7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/unix/pipe.c
Expand Up @@ -183,17 +183,15 @@ void uv_pipe_connect(uv_connect_t* req,
uv_strlcpy(saddr.sun_path, name, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;

/* We don't check for EINPROGRESS. Think about it: the socket
* is either there or not.
*/
do {
r = connect(uv__stream_fd(handle),
(struct sockaddr*)&saddr, sizeof saddr);
}
while (r == -1 && errno == EINTR);

if (r == -1)
goto out;
if (errno != EINPROGRESS)
goto out;

if (new_sock)
if (uv__stream_open((uv_stream_t*)handle,
Expand All @@ -213,8 +211,9 @@ void uv_pipe_connect(uv_connect_t* req,
req->cb = cb;
ngx_queue_init(&req->queue);

/* Run callback on next tick. */
uv__io_feed(handle->loop, &handle->io_watcher);
/* Force callback to run on next tick in case of error. */
if (err != 0)
uv__io_feed(handle->loop, &handle->io_watcher);

/* Mimic the Windows pipe implementation, always
* return 0 and let the callback handle errors.
Expand Down

0 comments on commit 3348cd7

Please sign in to comment.