From 4efc3b206e43d26f660d15d5051e7bdaa1910a55 Mon Sep 17 00:00:00 2001 From: Johannes Leupolz Date: Sat, 8 Nov 2025 22:37:42 +0000 Subject: [PATCH] Deduplicate error messages that spam the logs --- vuinputd/src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/vuinputd/src/main.rs b/vuinputd/src/main.rs index 9e08fea..eb10c35 100644 --- a/vuinputd/src/main.rs +++ b/vuinputd/src/main.rs @@ -88,10 +88,16 @@ impl std::fmt::Display for VuFileHandle { } } +#[derive(Debug)] +enum VuError { + WriteError +} + static VUINPUT_COUNTER: OnceLock = OnceLock::new(); static VUINPUT_STATE: OnceLock>>>> = OnceLock::new(); static JOB_DISPATCHER: OnceLock>= OnceLock::new(); static SELF_NAMESPACES: OnceLock= OnceLock::new(); +static DEDUP_LAST_ERROR: OnceLock>> = OnceLock::new(); const SYS_INPUT_DIR: &str = "/sys/devices/virtual/input/"; @@ -278,7 +284,15 @@ unsafe extern "C" fn vuinput_write( fuse_lowlevel::fuse_reply_write(_req, _size); } Err(e) => { - debug!("fh {}: error writing to uinput: {e:?}",fh); + let mut last_error = DEDUP_LAST_ERROR.get().unwrap().lock().unwrap(); + + match *last_error { + Some((last_fh,VuError::WriteError)) if *fh == last_fh => {}, + _ => {debug!("fh {}: error writing to uinput: {e:?}",fh);} + } + + *last_error = Some((*fh,VuError::WriteError)); + fuse_lowlevel::fuse_reply_err(_req, EIO); } } @@ -292,7 +306,7 @@ unsafe extern "C" fn vuinput_release( let vuinput_state_mutex = remove_vuinput_state(&VuFileHandle::from_fuse_file_info(_fi.as_ref().unwrap())).unwrap(); let mut vuinput_state = vuinput_state_mutex.lock().unwrap(); - let input_device = vuinput_state.input_device.take();; + let input_device = vuinput_state.input_device.take(); // Remove device in container, if the request was really from another namespace // Only do this in case it has not already been done by the ioctl UI_DEV_DESTROY @@ -694,6 +708,7 @@ fn main() -> std::io::Result<()> { VUINPUT_COUNTER.set(AtomicU64::new(3)).unwrap(); JOB_DISPATCHER.set(Mutex::new(Dispatcher::new())).unwrap(); SELF_NAMESPACES.set(get_namespaces(Pid::SelfPid)).unwrap(); + DEDUP_LAST_ERROR.set(Mutex::new(None)).unwrap(); JOB_DISPATCHER.get().unwrap().lock().unwrap().dispatch(Box::new(MonitorBackgroundLoop::new())); info!("Starting vuinputd");