You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was doing some debugging of the tests trying to figure out why a CREATE event was delivered even though a file should have existed before the watch. My debugging uncovered a deadlock in watch when a sleep_ms is performed before it. Something about the CFRunLoop code I imagine but I couldn't track it down.
This causes the deadlock:
diff --git a/tests/notify.rs b/tests/notify.rs
index 7fb5bb9..73fb23f 100644
--- a/tests/notify.rs+++ b/tests/notify.rs@@ -25,6 +25,7 @@ fn validate_watch_single_file<F, W>(ctor: F) where
let mut file = NamedTempFile::new().unwrap();
let (tx, rx) = channel();
let mut w = ctor(tx).unwrap();
+ thread::sleep_ms(1000);
w.watch(file.path()).unwrap();
thread::sleep_ms(1000);
file.write_all(b"foo").unwrap();
The text was updated successfully, but these errors were encountered:
More of a hang than a deadlock really, putting the sleep here causes the fsevent watcher to miss the modify events (maybe a bug, maybe just really hard to get the timing right on multi-threaded tests). Then validate_recv waits on an event that never occurs. The test should probably use rx.try_recv() in a loop with a timeout so if a failure results from a missing event it doesn't hang the test.
jakerr
changed the title
Sleeping before watch on OS X causes deadlock
Tests hang if no events are received
Aug 30, 2015
I was doing some debugging of the tests trying to figure out why a CREATE event was delivered even though a file should have existed before the watch. My debugging uncovered a deadlock in
watch
when asleep_ms
is performed before it. Something about theCFRunLoop
code I imagine but I couldn't track it down.This causes the deadlock:
The text was updated successfully, but these errors were encountered: