Lines Matching refs:handle
29 int uv__fsevents_init(uv_fs_event_t* handle) { in uv__fsevents_init() argument
34 int uv__fsevents_close(uv_fs_event_t* handle) { in uv__fsevents_close() argument
84 uv_fs_event_t* handle; member
109 uv_fs_event_t* handle,
151 #define UV__FSEVENTS_PROCESS(handle, block) \ argument
157 uv_mutex_lock(&(handle)->cf_mutex); \
159 uv__queue_move(&(handle)->cf_events, &events); \
161 err = (handle)->cf_error; \
162 (handle)->cf_error = 0; \
163 uv_mutex_unlock(&(handle)->cf_mutex); \
172 if (!uv__is_closing((handle)) && uv__is_active((handle))) \
177 if (err != 0 && !uv__is_closing((handle)) && uv__is_active((handle))) \
178 (handle)->cb((handle), NULL, 0, err); \
184 uv_fs_event_t* handle; in uv__fsevents_cb() local
186 handle = cb->data; in uv__fsevents_cb()
188 UV__FSEVENTS_PROCESS(handle, { in uv__fsevents_cb()
189 handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0); in uv__fsevents_cb()
195 static void uv__fsevents_push_event(uv_fs_event_t* handle, in uv__fsevents_push_event() argument
199 uv_mutex_lock(&handle->cf_mutex); in uv__fsevents_push_event()
203 uv__queue_add(&handle->cf_events, events); in uv__fsevents_push_event()
207 handle->cf_error = err; in uv__fsevents_push_event()
208 uv_mutex_unlock(&handle->cf_mutex); in uv__fsevents_push_event()
210 uv_async_send(handle->cf_cb); in uv__fsevents_push_event()
226 uv_fs_event_t* handle; in uv__fsevents_event_cb() local
242 handle = uv__queue_data(q, uv_fs_event_t, cf_member); in uv__fsevents_event_cb()
256 if (handle->realpath_len == 0) in uv__fsevents_event_cb()
260 if (len < handle->realpath_len) in uv__fsevents_event_cb()
266 if (handle->realpath_len != len && in uv__fsevents_event_cb()
267 handle->realpath_len > 1 && in uv__fsevents_event_cb()
268 path[handle->realpath_len] != '/') in uv__fsevents_event_cb()
271 if (memcmp(path, handle->realpath, handle->realpath_len) != 0) in uv__fsevents_event_cb()
274 if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) { in uv__fsevents_event_cb()
276 path += handle->realpath_len; in uv__fsevents_event_cb()
277 len -= handle->realpath_len; in uv__fsevents_event_cb()
283 while (len < handle->realpath_len && path[-1] != '/') { in uv__fsevents_event_cb()
297 if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') { in uv__fsevents_event_cb()
321 uv__fsevents_push_event(handle, &head, 0); in uv__fsevents_event_cb()
535 #define V(handle, symbol) \ in uv__fsevents_global_init() argument
537 *(void **)(&p ## symbol) = dlsym((handle), #symbol); \ in uv__fsevents_global_init()
752 if (s->handle == NULL) in uv__cf_loop_cb()
764 uv_fs_event_t* handle, in uv__cf_loop_signal() argument
773 item->handle = handle; in uv__cf_loop_signal()
791 int uv__fsevents_init(uv_fs_event_t* handle) { in uv__fsevents_init() argument
796 err = uv__fsevents_loop_init(handle->loop); in uv__fsevents_init()
801 buf = realpath(handle->path, NULL); in uv__fsevents_init()
804 handle->realpath = uv__strdup(buf); in uv__fsevents_init()
806 if (handle->realpath == NULL) in uv__fsevents_init()
808 handle->realpath_len = strlen(handle->realpath); in uv__fsevents_init()
811 uv__queue_init(&handle->cf_events); in uv__fsevents_init()
812 handle->cf_error = 0; in uv__fsevents_init()
818 handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb)); in uv__fsevents_init()
819 if (handle->cf_cb == NULL) { in uv__fsevents_init()
824 handle->cf_cb->data = handle; in uv__fsevents_init()
825 uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb); in uv__fsevents_init()
826 handle->cf_cb->flags |= UV_HANDLE_INTERNAL; in uv__fsevents_init()
827 uv_unref((uv_handle_t*) handle->cf_cb); in uv__fsevents_init()
829 err = uv_mutex_init(&handle->cf_mutex); in uv__fsevents_init()
834 state = handle->loop->cf_state; in uv__fsevents_init()
836 uv__queue_insert_tail(&state->fsevent_handles, &handle->cf_member); in uv__fsevents_init()
842 assert(handle != NULL); in uv__fsevents_init()
843 err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular); in uv__fsevents_init()
850 uv_mutex_destroy(&handle->cf_mutex); in uv__fsevents_init()
853 uv__free(handle->cf_cb); in uv__fsevents_init()
854 handle->cf_cb = NULL; in uv__fsevents_init()
857 uv__free(handle->realpath); in uv__fsevents_init()
858 handle->realpath = NULL; in uv__fsevents_init()
859 handle->realpath_len = 0; in uv__fsevents_init()
866 int uv__fsevents_close(uv_fs_event_t* handle) { in uv__fsevents_close() argument
870 if (handle->cf_cb == NULL) in uv__fsevents_close()
874 state = handle->loop->cf_state; in uv__fsevents_close()
876 uv__queue_remove(&handle->cf_member); in uv__fsevents_close()
882 assert(handle != NULL); in uv__fsevents_close()
883 err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalClosing); in uv__fsevents_close()
890 uv_close((uv_handle_t*) handle->cf_cb, (uv_close_cb) uv__free); in uv__fsevents_close()
891 handle->cf_cb = NULL; in uv__fsevents_close()
894 UV__FSEVENTS_PROCESS(handle, { in uv__fsevents_close()
898 uv_mutex_destroy(&handle->cf_mutex); in uv__fsevents_close()
899 uv__free(handle->realpath); in uv__fsevents_close()
900 handle->realpath = NULL; in uv__fsevents_close()
901 handle->realpath_len = 0; in uv__fsevents_close()