提交 d9a0458a 编写于 作者: B bp

fix bug where a failed stat would cause the consumer thread to hang

上级 53a723b4
......@@ -69,7 +69,8 @@ impl<'a> Exa<'a> {
// Communication between consumer thread and producer threads
enum StatResult<'a> {
File(File<'a>),
Path(Path)
Path(Path),
Error
}
let (results_tx, results_rx) = channel();
......@@ -84,7 +85,8 @@ impl<'a> Exa<'a> {
match results_rx.recv() {
Ok(result) => match result {
StatResult::File(file) => self.files.push(file),
StatResult::Path(path) => self.dirs.push(path)
StatResult::Path(path) => self.dirs.push(path),
StatResult::Error => ()
},
Err(_) => unreachable!()
}
......@@ -116,7 +118,10 @@ impl<'a> Exa<'a> {
let _ = results_tx.send(StatResult::File(File::with_stat(stat, &path, None, false)));
}
}
Err(e) => println!("{}: {}", file, e),
Err(e) => {
println!("{}: {}", file, e);
let _ = results_tx.send(StatResult::Error);
}
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册