From 467451e24ca5ef145d691fc350bed4b3d6ef4fae Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Tue, 7 Dec 2021 16:09:30 -0600 Subject: [PATCH 1/2] inotify: Ignore any error sending the `RenameTimeout` event. The `unwrap()` call here causes thread panics in our application. We notice them because we use `set_panic_hook`. I think ordinarily a panic here would be printed to stderr and otherwise ignored. For us, I think the usual pattern is that several files are renamed at once, and as soon as we notice the first rename, we drop the watcher. Therefore, when this thread wakes up, it's trying to send an event to a queue that has been closed. --- src/inotify.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/inotify.rs b/src/inotify.rs index 3a4c4c9f..d284eb98 100644 --- a/src/inotify.rs +++ b/src/inotify.rs @@ -416,9 +416,11 @@ impl EventLoop { let cookie = rename_event.tracker().unwrap(); // unwrap is safe because rename_event is always set with some cookie thread::spawn(move || { thread::sleep(Duration::from_millis(10)); // wait up to 10 ms for a subsequent event - event_loop_tx - .send(EventLoopMsg::RenameTimeout(cookie)) - .unwrap(); + + // An error here means the other end of the channel was closed, a thing that can + // happen normally. + let _ = event_loop_tx + .send(EventLoopMsg::RenameTimeout(cookie)); waker.wake().unwrap(); }); } From f932258c47997fed380e66fd12294da4dba3ba9a Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Tue, 7 Dec 2021 17:04:08 -0600 Subject: [PATCH 2/2] Also ignore errors from Waker::wake. --- src/inotify.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/inotify.rs b/src/inotify.rs index d284eb98..5277e0ab 100644 --- a/src/inotify.rs +++ b/src/inotify.rs @@ -419,9 +419,8 @@ impl EventLoop { // An error here means the other end of the channel was closed, a thing that can // happen normally. - let _ = event_loop_tx - .send(EventLoopMsg::RenameTimeout(cookie)); - waker.wake().unwrap(); + let _ = event_loop_tx.send(EventLoopMsg::RenameTimeout(cookie)); + let _ = waker.wake(); }); } }