hannobraun / inotify-rs

Idiomatic inotify wrapper for the Rust programming language
ISC License
260 stars 65 forks source link

panic when call event_stream #164

Open rink1969 opened 3 years ago

rink1969 commented 3 years ago

panic info:

   5: std::panicking::begin_panic
             at ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:505:12
   6: tokio::io::driver::Handle::current
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.5/src/io/driver/mod.rs:277:13
   7: tokio::io::async_fd::AsyncFd<T>::with_interest
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.5/src/io/async_fd.rs:99:51
   8: tokio::io::async_fd::AsyncFd<T>::new
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.5/src/io/async_fd.rs:89:9
   9: inotify::stream::EventStream<T>::new
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/inotify-0.9.1/src/stream.rs:35:17
  10: inotify::inotify::Inotify::event_stream
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/inotify-0.9.1/src/inotify.rs:406:9
  11: controller::sync::Notifier::watch::{{closure}}
             at ~/work/github/cita-cloud/controller_poc/src/sync.rs:128:26

related source code:

        let mut inotify = Inotify::init().expect("Failed to initialize inotify");

        let root_path = Path::new(&self.root);
        let mut wds = Vec::new();
        for dir in SYNC_FOLDERS.iter() {
            let path = root_path.join(dir);
            let wd = inotify.add_watch(path, WatchMask::MOVED_TO).unwrap();
            wds.push(wd);
        }

        let mut buffer = vec![0u8; 4096];
        let mut stream = inotify.event_stream(&mut buffer).unwrap();

        while let Some(event_or_error) = stream.next().await {

This happend when upgrade inotify to latest version (v0.9.1). After back to v0.8.3, it's ok.

hannobraun commented 3 years ago

Thank you for reporting!