ext/libuv/src/unix/stream.c in libuv-0.12.4 vs ext/libuv/src/unix/stream.c in libuv-1.0.0

- old
+ new

@@ -442,10 +442,11 @@ * thread opens a file or creates a socket in the time window between us * calling close() and accept(). */ static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) { int err; + int emfile_fd; if (loop->emfile_fd == -1) return -EMFILE; uv__close(loop->emfile_fd); @@ -455,10 +456,13 @@ err = uv__accept(accept_fd); if (err >= 0) uv__close(err); } while (err >= 0 || err == -EINTR); - SAVE_ERRNO(loop->emfile_fd = uv__open_cloexec("/", O_RDONLY)); + emfile_fd = uv__open_cloexec("/", O_RDONLY); + if (emfile_fd >= 0) + loop->emfile_fd = emfile_fd; + return err; } #if defined(UV_HAVE_KQUEUE)