Fix broken file watcher implementation

This one took a little bit of tracking down; the VfsWatcher used to spawn a new
thread and then stall/park forever. With one of the recent changes to get rid of
the extra thread, VfsWatcher started getting dropped, which in turn dropped the
watchers created by the notify crate.

Because the threads only tie back to the VfsWatcher was a cloned
Arc<Mutex<VfsSession>>, everything was fine, except that their mpsc::Receiver
objects were no longer receiving events.

This manifested itself as the file watcher magically not watching any files.
Oops.
This commit is contained in:
Lucien Greathouse
2018-01-08 12:33:36 -08:00
parent 1318842c36
commit c08a598d3f
2 changed files with 84 additions and 59 deletions

View File

@@ -1,6 +1,7 @@
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::process;
use std::sync::{Arc, Mutex};
use std::thread;
use rand;
@@ -87,6 +88,12 @@ pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
println!("Server listening on port {}", web_config.port);
VfsWatcher::new(vfs.clone()).start();
{
let vfs = vfs.clone();
thread::spawn(move || {
VfsWatcher::new(vfs).start();
});
}
web::start(web_config, project.clone(), &PLUGIN_CHAIN, vfs.clone());
}