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

Commit

Permalink
Browse files Browse the repository at this point in the history
unix: replace uv__close() with close()
uv__close() was deprecated a while ago. It's been an alias for close() ever
since. Remove it.
  • Loading branch information
bnoordhuis committed Mar 21, 2012
1 parent ef47a62 commit 4ff0898
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 39 deletions.
10 changes: 5 additions & 5 deletions src/unix/core.c
Expand Up @@ -82,11 +82,11 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
uv_read_stop(stream);
ev_io_stop(stream->loop->ev, &stream->write_watcher);

uv__close(stream->fd);
close(stream->fd);
stream->fd = -1;

if (stream->accepted_fd >= 0) {
uv__close(stream->accepted_fd);
close(stream->accepted_fd);
stream->accepted_fd = -1;
}

Expand Down Expand Up @@ -752,7 +752,7 @@ int uv__socket(int domain, int type, int protocol) {
goto out;

if (uv__nonblock(sockfd, 1) || uv__cloexec(sockfd, 1)) {
uv__close(sockfd);
close(sockfd);
sockfd = -1;
}

Expand Down Expand Up @@ -788,7 +788,7 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
}

if (uv__cloexec(peerfd, 1) || uv__nonblock(peerfd, 1)) {
uv__close(peerfd);
close(peerfd);
peerfd = -1;
}

Expand Down Expand Up @@ -862,7 +862,7 @@ int uv__dup(int fd) {
return -1;

if (uv__cloexec(fd, 1)) {
SAVE_ERRNO(uv__close(fd));
SAVE_ERRNO(close(fd));
return -1;
}

Expand Down
7 changes: 0 additions & 7 deletions src/unix/internal.h
Expand Up @@ -172,13 +172,6 @@ int uv__cloexec(int fd, int set) __attribute__((unused));
int uv__socket(int domain, int type, int protocol);
int uv__dup(int fd);

/* We used to handle EINTR in uv__close() but linux 2.6 will have closed the
* file descriptor anyway, even on EINTR. Retrying in that case isn't merely
* useless, it's actively harmful - the file descriptor may have been acquired
* by another thread.
*/
#define uv__close(fd) close(fd)

/* error */
uv_err_code uv_translate_sys_error(int sys_errno);
void uv_fatal_error(const int errorno, const char* syscall);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/kqueue.c
Expand Up @@ -124,7 +124,7 @@ int uv_fs_event_init(uv_loop_t* loop,
void uv__fs_event_destroy(uv_fs_event_t* handle) {
uv__fs_event_stop(handle);
free(handle->filename);
uv__close(handle->fd);
close(handle->fd);
handle->fd = -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux/inotify.c
Expand Up @@ -169,7 +169,7 @@ static int new_inotify_fd(void) {
return -1;

if (uv__cloexec(fd, 1) || uv__nonblock(fd, 1)) {
SAVE_ERRNO(uv__close(fd));
SAVE_ERRNO(close(fd));
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/unix/pipe.c
Expand Up @@ -109,7 +109,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
assert(pipe_fname != NULL);
unlink(pipe_fname);
}
uv__close(sockfd);
close(sockfd);

free((void*)pipe_fname);
}
Expand Down Expand Up @@ -210,7 +210,7 @@ void uv_pipe_connect(uv_connect_t* req,

if (r == -1) {
status = errno;
uv__close(sockfd);
close(sockfd);
goto out;
}

Expand Down
32 changes: 16 additions & 16 deletions src/unix/process.c
Expand Up @@ -229,16 +229,16 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,

if (pid == -1) {
#if SPAWN_WAIT_EXEC
uv__close(signal_pipe[0]);
uv__close(signal_pipe[1]);
close(signal_pipe[0]);
close(signal_pipe[1]);
#endif
environ = save_our_env;
goto error;
}

if (pid == 0) {
if (stdin_pipe[0] >= 0) {
uv__close(stdin_pipe[1]);
close(stdin_pipe[1]);
dup2(stdin_pipe[0], STDIN_FILENO);
} else {
/* Reset flags that might be set by Node */
Expand All @@ -247,7 +247,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
}

if (stdout_pipe[1] >= 0) {
uv__close(stdout_pipe[0]);
close(stdout_pipe[0]);
dup2(stdout_pipe[1], STDOUT_FILENO);
} else {
/* Reset flags that might be set by Node */
Expand All @@ -256,7 +256,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
}

if (stderr_pipe[1] >= 0) {
uv__close(stderr_pipe[0]);
close(stderr_pipe[0]);
dup2(stderr_pipe[1], STDERR_FILENO);
} else {
/* Reset flags that might be set by Node */
Expand Down Expand Up @@ -284,7 +284,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,

#if SPAWN_WAIT_EXEC
/* POLLHUP signals child has exited or execve()'d. */
uv__close(signal_pipe[1]);
close(signal_pipe[1]);
do {
pfd.fd = signal_pipe[0];
pfd.events = POLLIN|POLLHUP;
Expand All @@ -294,7 +294,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
while (status == -1 && (errno == EINTR || errno == ENOMEM));

assert((status == 1) && "poll() on pipe read end failed");
uv__close(signal_pipe[0]);
close(signal_pipe[0]);
#endif

process->pid = pid;
Expand All @@ -306,7 +306,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
if (stdin_pipe[1] >= 0) {
assert(options.stdin_stream);
assert(stdin_pipe[0] >= 0);
uv__close(stdin_pipe[0]);
close(stdin_pipe[0]);
uv__nonblock(stdin_pipe[1], 1);
flags = UV_WRITABLE | (options.stdin_stream->ipc ? UV_READABLE : 0);
uv__stream_open((uv_stream_t*)options.stdin_stream, stdin_pipe[1],
Expand All @@ -316,7 +316,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
if (stdout_pipe[0] >= 0) {
assert(options.stdout_stream);
assert(stdout_pipe[1] >= 0);
uv__close(stdout_pipe[1]);
close(stdout_pipe[1]);
uv__nonblock(stdout_pipe[0], 1);
flags = UV_READABLE | (options.stdout_stream->ipc ? UV_WRITABLE : 0);
uv__stream_open((uv_stream_t*)options.stdout_stream, stdout_pipe[0],
Expand All @@ -326,7 +326,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
if (stderr_pipe[0] >= 0) {
assert(options.stderr_stream);
assert(stderr_pipe[1] >= 0);
uv__close(stderr_pipe[1]);
close(stderr_pipe[1]);
uv__nonblock(stderr_pipe[0], 1);
flags = UV_READABLE | (options.stderr_stream->ipc ? UV_WRITABLE : 0);
uv__stream_open((uv_stream_t*)options.stderr_stream, stderr_pipe[0],
Expand All @@ -337,12 +337,12 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,

error:
uv__set_sys_error(process->loop, errno);
uv__close(stdin_pipe[0]);
uv__close(stdin_pipe[1]);
uv__close(stdout_pipe[0]);
uv__close(stdout_pipe[1]);
uv__close(stderr_pipe[0]);
uv__close(stderr_pipe[1]);
close(stdin_pipe[0]);
close(stdin_pipe[1]);
close(stdout_pipe[0]);
close(stdout_pipe[1]);
close(stderr_pipe[0]);
close(stderr_pipe[1]);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/unix/stream.c
Expand Up @@ -225,7 +225,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) {
if (uv__stream_open(streamClient, streamServer->accepted_fd,
UV_READABLE | UV_WRITABLE)) {
/* TODO handle error */
uv__close(streamServer->accepted_fd);
close(streamServer->accepted_fd);
streamServer->accepted_fd = -1;
goto out;
}
Expand Down Expand Up @@ -793,7 +793,7 @@ int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
}

if (uv__stream_open(stream, sockfd, UV_READABLE | UV_WRITABLE)) {
uv__close(sockfd);
close(sockfd);
return -2;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/sunos.c
Expand Up @@ -193,7 +193,7 @@ int uv_fs_event_init(uv_loop_t* loop,
void uv__fs_event_destroy(uv_fs_event_t* handle) {
ev_ref(handle->loop->ev);
ev_io_stop(handle->loop->ev, &handle->event_watcher);
uv__close(handle->fd);
close(handle->fd);
handle->fd = -1;
free(handle->filename);
handle->filename = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/unix/tcp.c
Expand Up @@ -51,7 +51,7 @@ static int uv__bind(uv_tcp_t* tcp,
}

if (uv__stream_open((uv_stream_t*)tcp, tcp->fd, UV_READABLE | UV_WRITABLE)) {
uv__close(tcp->fd);
close(tcp->fd);
tcp->fd = -1;
status = -2;
goto out;
Expand Down Expand Up @@ -182,7 +182,7 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
}

if (uv__stream_open((uv_stream_t*)tcp, tcp->fd, UV_READABLE)) {
uv__close(tcp->fd);
close(tcp->fd);
tcp->fd = -1;
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/unix/udp.c
Expand Up @@ -88,7 +88,7 @@ static void uv__udp_stop_write_watcher(uv_udp_t* handle) {
void uv__udp_start_close(uv_udp_t* handle) {
uv__udp_stop_write_watcher(handle);
uv__udp_stop_read_watcher(handle);
uv__close(handle->fd);
close(handle->fd);
handle->fd = -1;
}

Expand Down Expand Up @@ -383,7 +383,7 @@ static int uv__bind(uv_udp_t* handle,

out:
if (status)
uv__close(fd);
close(fd);

errno = saved_errno;
return status;
Expand Down

0 comments on commit 4ff0898

Please sign in to comment.