Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Upgrade libuv to 2b7774a

  • Loading branch information...
ry committed Nov 9, 2011
1 parent 2d13cdf commit 05727f6e3e334061ce5a592757509fc1d43d76b8
Showing with 31 additions and 11 deletions.
  1. +2 −1 deps/uv/include/uv.h
  2. +2 −0 deps/uv/src/unix/error.c
  3. +9 −2 deps/uv/src/uv-common.c
  4. +1 −0 deps/uv/src/uv-common.h
  5. +13 −6 deps/uv/src/win/process.c
  6. +4 −2 deps/uv/test/test-spawn.c
@@ -116,7 +116,8 @@ typedef enum {
UV_EAISERVICE,
UV_EAISOCKTYPE,
UV_ESHUTDOWN,
UV_EEXIST
UV_EEXIST,
UV_ESRCH
} uv_err_code;

typedef enum {
@@ -79,6 +79,7 @@ static int uv__translate_lib_error(int code) {
case UV_ENOTCONN: return ENOTCONN;
case UV_EEXIST: return EEXIST;
case UV_EHOSTUNREACH: return EHOSTUNREACH;
case UV_ESRCH: return ESRCH;
default: return -1;
}

@@ -112,6 +113,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EEXIST: return UV_EEXIST;
case EHOSTUNREACH: return UV_EHOSTUNREACH;
case EAI_NONAME: return UV_ENOENT;
case ESRCH: return UV_ESRCH;
default: return UV_UNKNOWN;
}

@@ -121,8 +121,7 @@ void uv__set_sys_error(uv_loop_t* loop, int sys_error) {


void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code) {
loop->last_err.code = code;
loop->last_err.sys_errno_ = 0;
loop->last_err = uv__new_artificial_error(code);
}


@@ -134,6 +133,14 @@ uv_err_t uv__new_sys_error(int sys_error) {
}


uv_err_t uv__new_artificial_error(uv_err_code code) {
uv_err_t error;
error.code = code;
error.sys_errno_ = 0;
return error;
}


uv_err_t uv_last_error(uv_loop_t* loop) {
return loop->last_err;
}
@@ -55,6 +55,7 @@ void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error);
void uv__set_sys_error(uv_loop_t* loop, int sys_error);
void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code);
uv_err_t uv__new_sys_error(int sys_error);
uv_err_t uv__new_artificial_error(uv_err_code code);

int uv__tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr);
int uv__tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr);
@@ -1082,14 +1082,17 @@ static uv_err_t uv__kill(HANDLE process_handle, int signum) {
}
} else if (signum == 0) {
/* Health check: is the process still alive? */
if (GetExitCodeProcess(process_handle, &status) &&
status == STILL_ACTIVE) {
err = uv_ok_;
if (GetExitCodeProcess(process_handle, &status)) {
if (status == STILL_ACTIVE) {
err = uv_ok_;
} else {
err = uv__new_artificial_error(UV_ESRCH);
}
} else {
err = uv__new_sys_error(GetLastError());
}
} else {
err.code = UV_ENOSYS;
err = uv__new_artificial_error(UV_ENOSYS);
}

return err;
@@ -1122,8 +1125,12 @@ uv_err_t uv_kill(int pid, int signum) {
HANDLE process_handle = OpenProcess(PROCESS_TERMINATE |
PROCESS_QUERY_INFORMATION, FALSE, pid);

if (process_handle == INVALID_HANDLE_VALUE) {
return uv__new_sys_error(GetLastError());
if (process_handle == NULL) {
if (GetLastError() == ERROR_INVALID_PARAMETER) {
return uv__new_artificial_error(UV_ESRCH);
} else {
return uv__new_sys_error(GetLastError());
}
}

err = uv__kill(process_handle, signum);
@@ -68,11 +68,13 @@ static void kill_cb(uv_process_t* process, int exit_status, int term_signal) {
ASSERT(no_term_signal || term_signal == 15);
uv_close((uv_handle_t*)process, close_cb);

/* Sending signum == 0 should check if the
/*
* Sending signum == 0 should check if the
* child process is still alive, not kill it.
* This process should be dead.
*/
err = uv_kill(process->pid, 0);
ASSERT(err.code != UV_OK);
ASSERT(err.code == UV_ESRCH);
}


0 comments on commit 05727f6

Please sign in to comment.
You can’t perform that action at this time.