unix: replace uv__close() with close()

uv__close() was deprecated a while ago. It's been an alias for close() ever
since. Remove it.
This commit is contained in:
Ben Noordhuis 2012-03-19 20:58:26 +01:00
parent ef47a627ad
commit 4ff0898c5f
10 changed files with 32 additions and 39 deletions

View File

@ -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;
}
@ -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;
}
@ -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;
}
@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -109,7 +109,7 @@ out:
assert(pipe_fname != NULL);
unlink(pipe_fname);
}
uv__close(sockfd);
close(sockfd);
free((void*)pipe_fname);
}
@ -210,7 +210,7 @@ void uv_pipe_connect(uv_connect_t* req,
if (r == -1) {
status = errno;
uv__close(sockfd);
close(sockfd);
goto out;
}

View File

@ -229,8 +229,8 @@ 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;
@ -238,7 +238,7 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
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 */
@ -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 */
@ -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 */
@ -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;
@ -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;
@ -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],
@ -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],
@ -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],
@ -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;
}

View File

@ -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;
}
@ -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;
}
}

View File

@ -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;

View File

@ -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;
@ -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;
}

View File

@ -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;
}
@ -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;