Merge pull request #1390 from zed-industries/fix-fs-watch-leak

Ensure that FS watchers are dropped when dropping their event stream
This commit is contained in:
Max Brunsfeld
2022-07-18 15:16:41 -07:00
committed by GitHub
+4 -2
View File
@@ -226,11 +226,13 @@ impl Fs for RealFs {
) -> Pin<Box<dyn Send + Stream<Item = Vec<fsevent::Event>>>> {
let (tx, rx) = smol::channel::unbounded();
let (stream, handle) = EventStream::new(&[path], latency);
std::mem::forget(handle);
std::thread::spawn(move || {
stream.run(move |events| smol::block_on(tx.send(events)).is_ok());
});
Box::pin(rx)
Box::pin(rx.chain(futures::stream::once(async move {
drop(handle);
vec![]
})))
}
fn is_fake(&self) -> bool {