void uv__stream_close(uv_stream_t* handle) { #if defined(__APPLE__) /* Terminate select loop first */ if (handle->select != NULL) { uv__stream_select_t* s; s = handle->select; uv_sem_post(&s->sem); uv__stream_osx_interrupt_select(handle); uv_thread_join(&s->thread); uv_sem_destroy(&s->sem); uv_mutex_destroy(&s->mutex); close(s->fake_fd); close(s->int_fd); uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close); handle->select = NULL; } #endif /* defined(__APPLE__) */ uv_read_stop(handle); uv__io_close(handle->loop, &handle->io_watcher); close(handle->io_watcher.fd); handle->io_watcher.fd = -1; if (handle->accepted_fd >= 0) { close(handle->accepted_fd); handle->accepted_fd = -1; } assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT)); }
int uv_fs_event_stop(uv_fs_event_t* handle) { if (!uv__is_active(handle)) return 0; uv__handle_stop(handle); #if defined(__APPLE__) if (uv__fsevents_close(handle)) #endif /* defined(__APPLE__) */ { uv__io_close(handle->loop, &handle->event_watcher); } uv__free(handle->path); handle->path = NULL; if (handle->event_watcher.fd != -1) { /* When FSEvents is used, we don't use the event_watcher's fd under certain * confitions. (see uv_fs_event_start) */ uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; } return 0; }
void uv__stream_close(uv_stream_t* handle) { unsigned int i; uv__stream_queued_fds_t* queued_fds; uv__io_close(handle->loop, &handle->io_watcher); uv_read_stop(handle); uv__handle_stop(handle); if (handle->io_watcher.fd != -1) { /* Don't close stdio file descriptors. Nothing good comes from it. */ if (handle->io_watcher.fd > STDERR_FILENO) uv__close(handle->io_watcher.fd); handle->io_watcher.fd = -1; } if (handle->accepted_fd != -1) { uv__close(handle->accepted_fd); handle->accepted_fd = -1; } /* Close all queued fds */ if (handle->queued_fds != NULL) { queued_fds = (uv__stream_queued_fds_t*)handle->queued_fds; for (i = 0; i < queued_fds->offset; i++) { uv__close(queued_fds->fds[i]); } free(handle->queued_fds); handle->queued_fds = NULL; } assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT)); }
void uv__udp_close(uv_udp_t* handle) { uv__io_close(handle->loop, &handle->io_watcher); uv__handle_stop(handle); if (handle->io_watcher.fd != -1) { uv__close(handle->io_watcher.fd); handle->io_watcher.fd = -1; } }
int uv_fs_event_stop(uv_fs_event_t* handle) { if (!uv__is_active(handle)) return 0; uv__io_close(handle->loop, &handle->event_watcher); uv__handle_stop(handle); if (uv__path_is_a_directory(handle->path) == 0) { uv__free(handle->dir_filename); handle->dir_filename = NULL; } uv__free(handle->path); handle->path = NULL; uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; return 0; }
int uv_fs_event_stop(uv_fs_event_t* handle) { if (!uv__is_active(handle)) return -EINVAL; uv__handle_stop(handle); #if defined(__APPLE__) if (uv__fsevents_close(handle)) #endif /* defined(__APPLE__) */ { uv__io_close(handle->loop, &handle->event_watcher); } free(handle->path); handle->path = NULL; uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; return 0; }
int uv_fs_event_stop(uv_fs_event_t* handle) { #ifdef HAVE_SYS_AHAFS_EVPRODS_H if (!uv__is_active(handle)) return 0; uv__io_close(handle->loop, &handle->event_watcher); uv__handle_stop(handle); if (uv__path_is_a_directory(handle->path) == 0) { uv__free(handle->dir_filename); handle->dir_filename = NULL; } uv__free(handle->path); handle->path = NULL; uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; return 0; #else return -ENOSYS; #endif }