Lines Matching defs:handle

29 int uv__fsevents_init(uv_fs_event_t* handle) {
34 int uv__fsevents_close(uv_fs_event_t* handle) {
84 uv_fs_event_t* handle;
109 uv_fs_event_t* handle,
153 #define UV__FSEVENTS_PROCESS(handle, block) \
159 uv_mutex_lock(&(handle)->cf_mutex); \
161 QUEUE_MOVE(&(handle)->cf_events, &events); \
163 err = (handle)->cf_error; \
164 (handle)->cf_error = 0; \
165 uv_mutex_unlock(&(handle)->cf_mutex); \
171 /* NOTE: Checking uv__is_active() is required here, because handle \
172 * callback may close handle and invoking it after it will lead to \
174 if (!uv__is_closing((handle)) && uv__is_active((handle))) \
179 if (err != 0 && !uv__is_closing((handle)) && uv__is_active((handle))) \
180 (handle)->cb((handle), NULL, 0, err); \
184 /* Runs in UV loop's thread, when there're events to report to handle */
186 uv_fs_event_t* handle;
188 handle = cb->data;
190 UV__FSEVENTS_PROCESS(handle, {
191 handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0);
196 /* Runs in CF thread, pushed event into handle's event list */
197 static void uv__fsevents_push_event(uv_fs_event_t* handle,
201 uv_mutex_lock(&handle->cf_mutex);
205 QUEUE_ADD(&handle->cf_events, events);
209 handle->cf_error = err;
210 uv_mutex_unlock(&handle->cf_mutex);
212 uv_async_send(handle->cf_cb);
228 uv_fs_event_t* handle;
241 /* For each handle */
244 handle = QUEUE_DATA(q, uv_fs_event_t, cf_member);
258 if (handle->realpath_len == 0)
261 /* Filter out paths that are outside handle's request */
262 if (len < handle->realpath_len)
268 if (handle->realpath_len != len &&
269 handle->realpath_len > 1 &&
270 path[handle->realpath_len] != '/')
273 if (memcmp(path, handle->realpath, handle->realpath_len) != 0)
276 if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) {
278 path += handle->realpath_len;
279 len -= handle->realpath_len;
289 while (len < handle->realpath_len && path[-1] != '/') {
303 if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') {
327 uv__fsevents_push_event(handle, &head, 0);
411 static void uv__fsevents_reschedule(uv_fs_event_t* handle,
422 state = handle->loop->cf_state;
441 uv__fsevents_destroy_stream(handle->loop);
481 err = uv__fsevents_create_stream(handle->loop, cf_paths);
506 * Main thread will block until the removal of handle from the list,
548 #define V(handle, symbol) \
550 *(void **)(&p ## symbol) = dlsym((handle), #symbol); \
767 if (s->handle == NULL)
770 uv__fsevents_reschedule(s->handle, s->type);
779 uv_fs_event_t* handle,
788 item->handle = handle;
805 /* Runs in UV loop to initialize handle */
806 int uv__fsevents_init(uv_fs_event_t* handle) {
810 err = uv__fsevents_loop_init(handle->loop);
815 handle->realpath = realpath(handle->path, NULL);
816 if (handle->realpath == NULL)
818 handle->realpath_len = strlen(handle->realpath);
821 QUEUE_INIT(&handle->cf_events);
822 handle->cf_error = 0;
828 handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb));
829 if (handle->cf_cb == NULL) {
834 handle->cf_cb->data = handle;
835 uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb);
836 handle->cf_cb->flags |= UV_HANDLE_INTERNAL;
837 uv_unref((uv_handle_t*) handle->cf_cb);
839 err = uv_mutex_init(&handle->cf_mutex);
843 /* Insert handle into the list */
844 state = handle->loop->cf_state;
846 QUEUE_INSERT_TAIL(&state->fsevent_handles, &handle->cf_member);
852 assert(handle != NULL);
853 err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalRegular);
860 uv_mutex_destroy(&handle->cf_mutex);
863 uv__free(handle->cf_cb);
864 handle->cf_cb = NULL;
867 uv__free(handle->realpath);
868 handle->realpath = NULL;
869 handle->realpath_len = 0;
875 /* Runs in UV loop to de-initialize handle */
876 int uv__fsevents_close(uv_fs_event_t* handle) {
880 if (handle->cf_cb == NULL)
883 /* Remove handle from the list */
884 state = handle->loop->cf_state;
886 QUEUE_REMOVE(&handle->cf_member);
892 assert(handle != NULL);
893 err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalClosing);
900 uv_close((uv_handle_t*) handle->cf_cb, (uv_close_cb) uv__free);
901 handle->cf_cb = NULL;
904 UV__FSEVENTS_PROCESS(handle, {
908 uv_mutex_destroy(&handle->cf_mutex);
909 uv__free(handle->realpath);
910 handle->realpath = NULL;
911 handle->realpath_len = 0;