diff --git a/backend-fsevent/Cargo.toml b/backend-fsevent/Cargo.toml index 708ed847..f114a76c 100644 --- a/backend-fsevent/Cargo.toml +++ b/backend-fsevent/Cargo.toml @@ -8,7 +8,8 @@ workspace = ".." libc = "*" futures = "0.1.10" fsevent = "0.2" -fsevent-sys = "0.1.3" +fsevent-sys = "0.1.6" +tempdir = "0.3.5" [dependencies.notify-backend] path = "../backend" diff --git a/backend-fsevent/src/watcher.rs b/backend-fsevent/src/watcher.rs index 59ee06c4..e2da5b3b 100644 --- a/backend-fsevent/src/watcher.rs +++ b/backend-fsevent/src/watcher.rs @@ -54,41 +54,41 @@ impl FsEventWatcher { let latency = 0.0; let since_when = fs::kFSEventStreamEventIdSinceNow; - let ctx = Box::new(Context { queue }); - let stream_ctx = fs::FSEventStreamContext { - version: 0, - info: unsafe { mem::transmute(Box::into_raw(ctx)) }, - retain: cf::NULL, - copy_description: cf::NULL, - }; - - let cb = callback as *mut _; - unsafe { - let fse_stream = fs::FSEventStreamCreate(cf::kCFAllocatorDefault, - cb, - &stream_ctx, - paths, - since_when, - latency, - flags); - - let runloop = cf::CFRunLoopGetCurrent(); - - runloop_ptr2.store(runloop as *mut libc::c_void, - atomic::Ordering::Relaxed); - - ptr_set_barrier2.wait(); - - fs::FSEventStreamScheduleWithRunLoop(fse_stream, runloop, - cf::kCFRunLoopDefaultMode); - fs::FSEventStreamStart(fse_stream); + let ctx = Box::new(Context::new(queue)); + let stream_ctx = fs::FSEventStreamContext { + version: 0, + info: unsafe { mem::transmute(Box::into_raw(ctx)) }, + retain: cf::NULL, + copy_description: cf::NULL, + }; - cf::CFRunLoopRun(); - // the previous call blocks until we cancel from another thread - fs::FSEventStreamStop(fse_stream); - fs::FSEventStreamInvalidate(fse_stream); - fs::FSEventStreamRelease(fse_stream); - } + let cb = callback as *mut _; + unsafe { + let fse_stream = fs::FSEventStreamCreate(cf::kCFAllocatorDefault, + cb, + &stream_ctx, + paths, + since_when, + latency, + flags); + + let runloop = cf::CFRunLoopGetCurrent(); + + runloop_ptr2.store(runloop as *mut libc::c_void, + atomic::Ordering::Relaxed); + + ptr_set_barrier2.wait(); + + fs::FSEventStreamScheduleWithRunLoop(fse_stream, runloop, + cf::kCFRunLoopDefaultMode); + fs::FSEventStreamStart(fse_stream); + + cf::CFRunLoopRun(); + // the previous call blocks until we cancel from another thread + fs::FSEventStreamStop(fse_stream); + fs::FSEventStreamInvalidate(fse_stream); + fs::FSEventStreamRelease(fse_stream); + } }); ptr_set_barrier.wait(); diff --git a/ci/cross-tests.sh b/ci/cross-tests.sh index 86df7a57..5f8c1a03 100755 --- a/ci/cross-tests.sh +++ b/ci/cross-tests.sh @@ -38,8 +38,8 @@ target() { 2>&1 | tee $(logfile $check $target notify-backend-inotify) elif [[ "$target" =~ -darwin$ ]]; then echo not ready yet - #$check $target -p notify-backend-fsevents \ - # 2>&1 | tee $(logfile $check $target notify-backend-fsevents) + $check $target -p notify-backend-fsevent \ + 2>&1 | tee $(logfile $check $target notify-backend-fsevent) elif [[ "$target" =~ bsd ]]; then $check $target -p notify-backend-kqueue \ 2>&1 | tee $(logfile $check $target notify-backend-kqueue) diff --git a/ci/script.sh b/ci/script.sh index f8f1abd0..ec9cba51 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -30,7 +30,8 @@ main() { echo bothx test -p notify-backend-poll-tree if [[ "$TARGET" =~ -darwin$ ]]; then - echo bothx test -p notify-backend-fsevents + echo bothx test -p notify-backend-fsevent + bothx test -p notify-backend-fsevent elif [[ "$TARGET" =~ -linux- ]]; then bothx test -p notify-backend-inotify fi