|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
use crate::{
|
|
|
|
|
constants::{SERVER_WATCHER_CAPACITY, SERVER_WATCHER_PAUSE_MILLIS},
|
|
|
|
|
constants::SERVER_WATCHER_CAPACITY,
|
|
|
|
|
data::{
|
|
|
|
|
self, Change, ChangeKind, ChangeKindSet, DirEntry, FileType, Metadata, PtySize, Request,
|
|
|
|
|
RequestData, Response, ResponseData, RunningProcess, SystemInfo,
|
|
|
|
@ -19,7 +19,7 @@ use std::{
|
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
|
pin::Pin,
|
|
|
|
|
sync::Arc,
|
|
|
|
|
time::{Duration, SystemTime},
|
|
|
|
|
time::SystemTime,
|
|
|
|
|
};
|
|
|
|
|
use tokio::{
|
|
|
|
|
io::{self, AsyncWriteExt},
|
|
|
|
@ -406,28 +406,16 @@ where
|
|
|
|
|
// with a large volume of watch requests
|
|
|
|
|
let (tx, mut rx) = mpsc::channel(SERVER_WATCHER_CAPACITY);
|
|
|
|
|
|
|
|
|
|
let mut watcher = notify::recommended_watcher(move |res| {
|
|
|
|
|
let mut res = res;
|
|
|
|
|
|
|
|
|
|
// Attempt to send our result, breaking out of the loop
|
|
|
|
|
// if we succeed or it is impossible, otherwise trying
|
|
|
|
|
// again after a brief sleep
|
|
|
|
|
loop {
|
|
|
|
|
match tx.try_send(res) {
|
|
|
|
|
Ok(_) => break,
|
|
|
|
|
Err(TrySendError::Full(x)) => {
|
|
|
|
|
warn!(
|
|
|
|
|
"Reached watcher capacity of {}! Trying again after {}ms",
|
|
|
|
|
SERVER_WATCHER_CAPACITY, SERVER_WATCHER_PAUSE_MILLIS
|
|
|
|
|
);
|
|
|
|
|
res = x;
|
|
|
|
|
std::thread::sleep(Duration::from_millis(SERVER_WATCHER_PAUSE_MILLIS));
|
|
|
|
|
}
|
|
|
|
|
Err(TrySendError::Closed(_)) => {
|
|
|
|
|
warn!("Skipping watch event because watcher channel closed");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let mut watcher = notify::recommended_watcher(move |res| match tx.try_send(res) {
|
|
|
|
|
Ok(_) => {}
|
|
|
|
|
Err(TrySendError::Full(_)) => {
|
|
|
|
|
warn!(
|
|
|
|
|
"Reached watcher capacity of {}! Dropping watcher event!",
|
|
|
|
|
SERVER_WATCHER_CAPACITY,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Err(TrySendError::Closed(_)) => {
|
|
|
|
|
warn!("Skipping watch event because watcher channel closed");
|
|
|
|
|
}
|
|
|
|
|
})?;
|
|
|
|
|
|
|
|
|
|