Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests hang if no events are received #26

Closed
jakerr opened this issue Aug 29, 2015 · 2 comments
Closed

Tests hang if no events are received #26

jakerr opened this issue Aug 29, 2015 · 2 comments

Comments

@jakerr
Copy link

jakerr commented Aug 29, 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 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();
@jakerr
Copy link
Author

jakerr commented Aug 30, 2015

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 jakerr changed the title Sleeping before watch on OS X causes deadlock Tests hang if no events are received Aug 30, 2015
@octplane octplane mentioned this issue Aug 31, 2015
@passcod
Copy link
Member

passcod commented Dec 27, 2015

Okay, the fix for this was apparently merged all the way back in #27, closing.

@passcod passcod closed this as completed Dec 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants