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

Commit

Permalink
unix, windows: return error if uv_pipe_open fails
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul authored and bnoordhuis committed Sep 17, 2012
1 parent 3d9de13 commit c8514b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/uv.h
Expand Up @@ -940,7 +940,7 @@ UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
/*
* Opens an existing file descriptor or HANDLE as a pipe.
*/
UV_EXTERN void uv_pipe_open(uv_pipe_t*, uv_file file);
UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file);

UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);

Expand Down
8 changes: 4 additions & 4 deletions src/unix/pipe.c
Expand Up @@ -156,10 +156,10 @@ void uv__pipe_close(uv_pipe_t* handle) {
}


void uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
uv__stream_open((uv_stream_t*)handle,
fd,
UV_STREAM_READABLE | UV_STREAM_WRITABLE);
int uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
return uv__stream_open((uv_stream_t*)handle,
fd,
UV_STREAM_READABLE | UV_STREAM_WRITABLE);
}


Expand Down
6 changes: 4 additions & 2 deletions src/win/pipe.c
Expand Up @@ -1634,12 +1634,13 @@ static void eof_timer_close_cb(uv_handle_t* handle) {
}


void uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
HANDLE os_handle = (HANDLE)_get_osfhandle(file);

if (os_handle == INVALID_HANDLE_VALUE ||
uv_set_pipe_handle(pipe->loop, pipe, os_handle, 0) == -1) {
return;
uv__set_sys_error(pipe->loop, WSAEINVAL);
return -1;
}

uv_pipe_connection_init(pipe);
Expand All @@ -1651,4 +1652,5 @@ void uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
pipe->ipc_pid = uv_parent_pid();
assert(pipe->ipc_pid != -1);
}
return 0;
}

0 comments on commit c8514b0

Please sign in to comment.