Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
uv: upgrade to 4d7f1e18
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Jun 13, 2012
1 parent 029e01b commit 37d75ba
Show file tree
Hide file tree
Showing 7 changed files with 571 additions and 430 deletions.
2 changes: 1 addition & 1 deletion deps/uv/include/uv-private/uv-win.h
Expand Up @@ -456,7 +456,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
struct uv_process_close_s { \
UV_REQ_FIELDS \
} close_req; \
void* child_stdio_buffer; \
BYTE* child_stdio_buffer; \
int exit_signal; \
DWORD spawn_errno; \
HANDLE wait_handle; \
Expand Down
16 changes: 16 additions & 0 deletions deps/uv/include/uv.h
Expand Up @@ -1580,6 +1580,22 @@ UV_EXTERN uint64_t uv_get_total_memory(void);
UV_EXTERN extern uint64_t uv_hrtime(void);


/*
* Disables inheritance for file descriptors / handles that this process
* inherited from its parent. The effect is that child processes spawned by
* this proces don't accidently inherit these handles.
*
* It is recommended to call this function as early in your program as possible,
* before the inherited file descriptors can be closed or duplicated.
*
* Note that this function works on a best-effort basis: there is no guarantee
* that libuv can discover all file descriptors that were inherited. In general
* it does a better job on Windows than it does on unix.
*
* TODO(bb): insert snarky remark to annoy bnoordhuis and the folks at joyent.
*/
UV_EXTERN void uv_disable_stdio_inheritance(void);

/*
* Opens a shared library. The filename is in utf-8. Returns 0 on success and
* -1 on error. Call `uv_dlerror(uv_lib_t*)` to get the error message.
Expand Down
78 changes: 52 additions & 26 deletions deps/uv/src/unix/core.c
Expand Up @@ -462,55 +462,69 @@ int uv__accept(int sockfd) {


int uv__nonblock(int fd, int set) {
int r;

#if FIONBIO
return ioctl(fd, FIONBIO, &set);
do
r = ioctl(fd, FIONBIO, &set);
while (r == -1 && errno == EINTR);

return r;
#else
int flags;

if ((flags = fcntl(fd, F_GETFL)) == -1) {
do
r = fcntl(fd, F_GETFL);
while (r == -1 && errno == EINTR);

if (r == -1)
return -1;
}

if (set) {
flags |= O_NONBLOCK;
} else {
flags &= ~O_NONBLOCK;
}
if (set)
flags = r | O_NONBLOCK;
else
flags = r & ~O_NONBLOCK;

if (fcntl(fd, F_SETFL, flags) == -1) {
return -1;
}
do
r = fcntl(fd, F_SETFL, flags);
while (r == -1 && errno == EINTR);

return 0;
return r;
#endif
}


int uv__cloexec(int fd, int set) {
int flags;
int r;

#if __linux__
/* Linux knows only FD_CLOEXEC so we can safely omit the fcntl(F_GETFD)
* syscall. CHECKME: That's probably true for other Unices as well.
*/
return fcntl(fd, F_SETFD, set ? FD_CLOEXEC : 0);
if (set)
flags = FD_CLOEXEC;
else
flags = 0;
#else
int flags;
do
r = fcntl(fd, F_GETFD);
while (r == -1 && errno == EINTR);

if ((flags = fcntl(fd, F_GETFD)) == -1) {
if (r == -1)
return -1;
}

if (set) {
flags |= FD_CLOEXEC;
} else {
flags &= ~FD_CLOEXEC;
}
if (set)
flags = r | FD_CLOEXEC;
else
flags = r & ~FD_CLOEXEC;
#endif

if (fcntl(fd, F_SETFD, flags) == -1) {
return -1;
}
do
r = fcntl(fd, F_SETFD, flags);
while (r == -1 && errno == EINTR);

return 0;
#endif
return r;
}


Expand Down Expand Up @@ -572,6 +586,18 @@ uv_err_t uv_chdir(const char* dir) {
}


void uv_disable_stdio_inheritance(void) {
int fd;

/* Set the CLOEXEC flag on all open descriptors. Unconditionally try the
* first 16 file descriptors. After that, bail out after the first error.
*/
for (fd = 0; ; fd++)
if (uv__cloexec(fd, 1) && fd > 15)
break;
}


static void uv__io_set_cb(uv__io_t* handle, uv__io_cb cb) {
union { void* data; uv__io_cb cb; } u;
u.cb = cb;
Expand Down
12 changes: 12 additions & 0 deletions deps/uv/src/win/internal.h
Expand Up @@ -279,6 +279,18 @@ void uv_fatal_error(const int errorno, const char* syscall);
uv_err_code uv_translate_sys_error(int sys_errno);


/*
* Process stdio handles.
*/
int uv__stdio_create(uv_loop_t* loop, uv_process_options_t* options,
BYTE** buffer_ptr);
void uv__stdio_destroy(BYTE* buffer);
void uv__stdio_noinherit(BYTE* buffer);
int uv__stdio_verify(BYTE* buffer, WORD size);
WORD uv__stdio_size(BYTE* buffer);
HANDLE uv__stdio_handle(BYTE* buffer, int fd);


/*
* Winapi and ntapi utility functions
*/
Expand Down

0 comments on commit 37d75ba

Please sign in to comment.