Lines Matching +full:dlclose +full:- +full:skip
26 /* iOS (currently) doesn't provide the FSEvents-API (nor CoreServices) */
44 #include "darwin-stub.h"
112 /* Lazy-loaded by uv__fsevents_global_init(). */
159 uv_mutex_lock(&(handle)->cf_mutex); \
160 /* Split-off all events and empty original queue */ \
161 QUEUE_MOVE(&(handle)->cf_events, &events); \
163 err = (handle)->cf_error; \
164 (handle)->cf_error = 0; \
165 uv_mutex_unlock(&(handle)->cf_mutex); \
180 (handle)->cb((handle), NULL, 0, err); \
188 handle = cb->data; in uv__fsevents_cb()
191 handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0); in uv__fsevents_cb()
201 uv_mutex_lock(&handle->cf_mutex); in uv__fsevents_push_event()
205 QUEUE_ADD(&handle->cf_events, events); in uv__fsevents_push_event()
209 handle->cf_error = err; in uv__fsevents_push_event()
210 uv_mutex_unlock(&handle->cf_mutex); in uv__fsevents_push_event()
212 uv_async_send(handle->cf_cb); in uv__fsevents_push_event()
237 state = loop->cf_state; in uv__fsevents_event_cb()
242 uv_mutex_lock(&state->fsevent_mutex); in uv__fsevents_event_cb()
243 QUEUE_FOREACH(q, &state->fsevent_handles) { in uv__fsevents_event_cb()
258 if (handle->realpath_len == 0) in uv__fsevents_event_cb()
262 if (len < handle->realpath_len) in uv__fsevents_event_cb()
268 if (handle->realpath_len != len && in uv__fsevents_event_cb()
269 handle->realpath_len > 1 && in uv__fsevents_event_cb()
270 path[handle->realpath_len] != '/') in uv__fsevents_event_cb()
273 if (memcmp(path, handle->realpath, handle->realpath_len) != 0) in uv__fsevents_event_cb()
276 if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) { in uv__fsevents_event_cb()
278 path += handle->realpath_len; in uv__fsevents_event_cb()
279 len -= handle->realpath_len; in uv__fsevents_event_cb()
289 while (len < handle->realpath_len && path[-1] != '/') { in uv__fsevents_event_cb()
290 path--; in uv__fsevents_event_cb()
296 /* Skip forward slash */ in uv__fsevents_event_cb()
298 len--; in uv__fsevents_event_cb()
303 if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') { in uv__fsevents_event_cb()
314 memcpy(event->path, path, len + 1); in uv__fsevents_event_cb()
315 event->events = UV_RENAME; in uv__fsevents_event_cb()
320 event->events = UV_CHANGE; in uv__fsevents_event_cb()
323 QUEUE_INSERT_TAIL(&head, &event->member); in uv__fsevents_event_cb()
329 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_event_cb()
348 * 1. NoDefer - without this flag, events that are happening continuously in uv__fsevents_create_stream()
356 * 2. FileEvents - fire callback for file changes too (by default it is firing in uv__fsevents_create_stream()
376 state = loop->cf_state; in uv__fsevents_create_stream()
378 state->loop, in uv__fsevents_create_stream()
386 state->fsevent_stream = ref; in uv__fsevents_create_stream()
395 state = loop->cf_state; in uv__fsevents_destroy_stream()
397 if (state->fsevent_stream == NULL) in uv__fsevents_destroy_stream()
401 pFSEventStreamStop(state->fsevent_stream); in uv__fsevents_destroy_stream()
404 pFSEventStreamInvalidate(state->fsevent_stream); in uv__fsevents_destroy_stream()
405 pFSEventStreamRelease(state->fsevent_stream); in uv__fsevents_destroy_stream()
406 state->fsevent_stream = NULL; in uv__fsevents_destroy_stream()
422 state = handle->loop->cf_state; in uv__fsevents_reschedule()
432 uv_mutex_lock(&state->fsevent_mutex); in uv__fsevents_reschedule()
433 if (state->fsevent_need_reschedule == 0) { in uv__fsevents_reschedule()
434 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_reschedule()
437 state->fsevent_need_reschedule = 0; in uv__fsevents_reschedule()
438 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_reschedule()
441 uv__fsevents_destroy_stream(handle->loop); in uv__fsevents_reschedule()
447 uv_mutex_lock(&state->fsevent_mutex); in uv__fsevents_reschedule()
448 path_count = state->fsevent_handle_count; in uv__fsevents_reschedule()
452 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_reschedule()
456 q = &state->fsevent_handles; in uv__fsevents_reschedule()
459 assert(q != &state->fsevent_handles); in uv__fsevents_reschedule()
462 assert(curr->realpath != NULL); in uv__fsevents_reschedule()
464 pCFStringCreateWithFileSystemRepresentation(NULL, curr->realpath); in uv__fsevents_reschedule()
466 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_reschedule()
471 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_reschedule()
481 err = uv__fsevents_create_stream(handle->loop, cf_paths); in uv__fsevents_reschedule()
489 pCFRelease(paths[--i]); in uv__fsevents_reschedule()
492 /* CFArray takes ownership of both strings and original C-array */ in uv__fsevents_reschedule()
497 uv_mutex_lock(&state->fsevent_mutex); in uv__fsevents_reschedule()
498 QUEUE_FOREACH(q, &state->fsevent_handles) { in uv__fsevents_reschedule()
502 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_reschedule()
512 uv_sem_post(&state->fsevent_sem); in uv__fsevents_reschedule()
530 * per-event loop properties and have the dynamic linker keep track for us. in uv__fsevents_global_init()
580 dlclose(core_services_handle); in uv__fsevents_global_init()
585 dlclose(core_foundation_handle); in uv__fsevents_global_init()
601 if (loop->cf_state != NULL) in uv__fsevents_loop_init()
612 err = uv_mutex_init(&loop->cf_mutex); in uv__fsevents_loop_init()
616 err = uv_sem_init(&loop->cf_sem, 0); in uv__fsevents_loop_init()
620 QUEUE_INIT(&loop->cf_signals); in uv__fsevents_loop_init()
622 err = uv_sem_init(&state->fsevent_sem, 0); in uv__fsevents_loop_init()
626 err = uv_mutex_init(&state->fsevent_mutex); in uv__fsevents_loop_init()
630 QUEUE_INIT(&state->fsevent_handles); in uv__fsevents_loop_init()
631 state->fsevent_need_reschedule = 0; in uv__fsevents_loop_init()
632 state->fsevent_handle_count = 0; in uv__fsevents_loop_init()
637 state->signal_source = pCFRunLoopSourceCreate(NULL, 0, &ctx); in uv__fsevents_loop_init()
638 if (state->signal_source == NULL) { in uv__fsevents_loop_init()
649 loop->cf_state = state; in uv__fsevents_loop_init()
652 err = UV__ERR(pthread_create(&loop->cf_thread, &attr, uv__cf_loop_runner, loop)); in uv__fsevents_loop_init()
661 uv_sem_wait(&loop->cf_sem); in uv__fsevents_loop_init()
665 loop->cf_state = NULL; in uv__fsevents_loop_init()
668 uv_mutex_destroy(&state->fsevent_mutex); in uv__fsevents_loop_init()
671 uv_sem_destroy(&state->fsevent_sem); in uv__fsevents_loop_init()
674 uv_sem_destroy(&loop->cf_sem); in uv__fsevents_loop_init()
677 uv_mutex_destroy(&loop->cf_mutex); in uv__fsevents_loop_init()
691 if (loop->cf_state == NULL) in uv__fsevents_loop_delete()
697 uv_thread_join(&loop->cf_thread); in uv__fsevents_loop_delete()
698 uv_sem_destroy(&loop->cf_sem); in uv__fsevents_loop_delete()
699 uv_mutex_destroy(&loop->cf_mutex); in uv__fsevents_loop_delete()
702 while (!QUEUE_EMPTY(&loop->cf_signals)) { in uv__fsevents_loop_delete()
703 q = QUEUE_HEAD(&loop->cf_signals); in uv__fsevents_loop_delete()
710 state = loop->cf_state; in uv__fsevents_loop_delete()
711 uv_sem_destroy(&state->fsevent_sem); in uv__fsevents_loop_delete()
712 uv_mutex_destroy(&state->fsevent_mutex); in uv__fsevents_loop_delete()
713 pCFRelease(state->signal_source); in uv__fsevents_loop_delete()
715 loop->cf_state = NULL; in uv__fsevents_loop_delete()
725 state = loop->cf_state; in uv__cf_loop_runner()
726 state->loop = pCFRunLoopGetCurrent(); in uv__cf_loop_runner()
728 pCFRunLoopAddSource(state->loop, in uv__cf_loop_runner()
729 state->signal_source, in uv__cf_loop_runner()
732 uv_sem_post(&loop->cf_sem); in uv__cf_loop_runner()
735 pCFRunLoopRemoveSource(state->loop, in uv__cf_loop_runner()
736 state->signal_source, in uv__cf_loop_runner()
739 state->loop = NULL; in uv__cf_loop_runner()
754 state = loop->cf_state; in uv__cf_loop_cb()
756 uv_mutex_lock(&loop->cf_mutex); in uv__cf_loop_cb()
757 QUEUE_MOVE(&loop->cf_signals, &split_head); in uv__cf_loop_cb()
758 uv_mutex_unlock(&loop->cf_mutex); in uv__cf_loop_cb()
767 if (s->handle == NULL) in uv__cf_loop_cb()
768 pCFRunLoopStop(state->loop); in uv__cf_loop_cb()
770 uv__fsevents_reschedule(s->handle, s->type); in uv__cf_loop_cb()
788 item->handle = handle; in uv__cf_loop_signal()
789 item->type = type; in uv__cf_loop_signal()
791 uv_mutex_lock(&loop->cf_mutex); in uv__cf_loop_signal()
792 QUEUE_INSERT_TAIL(&loop->cf_signals, &item->member); in uv__cf_loop_signal()
794 state = loop->cf_state; in uv__cf_loop_signal()
796 pCFRunLoopSourceSignal(state->signal_source); in uv__cf_loop_signal()
797 pCFRunLoopWakeUp(state->loop); in uv__cf_loop_signal()
799 uv_mutex_unlock(&loop->cf_mutex); in uv__cf_loop_signal()
810 err = uv__fsevents_loop_init(handle->loop); in uv__fsevents_init()
815 handle->realpath = realpath(handle->path, NULL); in uv__fsevents_init()
816 if (handle->realpath == NULL) in uv__fsevents_init()
818 handle->realpath_len = strlen(handle->realpath); in uv__fsevents_init()
821 QUEUE_INIT(&handle->cf_events); in uv__fsevents_init()
822 handle->cf_error = 0; in uv__fsevents_init()
828 handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb)); in uv__fsevents_init()
829 if (handle->cf_cb == NULL) { in uv__fsevents_init()
834 handle->cf_cb->data = handle; in uv__fsevents_init()
835 uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); in uv__fsevents_init()
836 handle->cf_cb->flags |= UV_HANDLE_INTERNAL; in uv__fsevents_init()
837 uv_unref((uv_handle_t*) handle->cf_cb); in uv__fsevents_init()
839 err = uv_mutex_init(&handle->cf_mutex); in uv__fsevents_init()
844 state = handle->loop->cf_state; in uv__fsevents_init()
845 uv_mutex_lock(&state->fsevent_mutex); in uv__fsevents_init()
846 QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member); in uv__fsevents_init()
847 state->fsevent_handle_count++; in uv__fsevents_init()
848 state->fsevent_need_reschedule = 1; in uv__fsevents_init()
849 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_init()
853 err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular); in uv__fsevents_init()
860 uv_mutex_destroy(&handle->cf_mutex); in uv__fsevents_init()
863 uv__free(handle->cf_cb); in uv__fsevents_init()
864 handle->cf_cb = NULL; in uv__fsevents_init()
867 uv__free(handle->realpath); in uv__fsevents_init()
868 handle->realpath = NULL; in uv__fsevents_init()
869 handle->realpath_len = 0; in uv__fsevents_init()
875 /* Runs in UV loop to de-initialize handle */
880 if (handle->cf_cb == NULL) in uv__fsevents_close()
884 state = handle->loop->cf_state; in uv__fsevents_close()
885 uv_mutex_lock(&state->fsevent_mutex); in uv__fsevents_close()
886 QUEUE_REMOVE(&handle->cf_member); in uv__fsevents_close()
887 state->fsevent_handle_count--; in uv__fsevents_close()
888 state->fsevent_need_reschedule = 1; in uv__fsevents_close()
889 uv_mutex_unlock(&state->fsevent_mutex); in uv__fsevents_close()
893 err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalClosing); in uv__fsevents_close()
898 uv_sem_wait(&state->fsevent_sem); in uv__fsevents_close()
900 uv_close((uv_handle_t*) handle->cf_cb, (uv_close_cb) uv__free); in uv__fsevents_close()
901 handle->cf_cb = NULL; in uv__fsevents_close()
908 uv_mutex_destroy(&handle->cf_mutex); in uv__fsevents_close()
909 uv__free(handle->realpath); in uv__fsevents_close()
910 handle->realpath = NULL; in uv__fsevents_close()
911 handle->realpath_len = 0; in uv__fsevents_close()