Skip to content

Commit 67fdf91

Browse files
WhatAmISupposedToPutHereslp
authored andcommitted
Reduce bridge spamminess
Truncated messages are just a fact of life, we handle them correctly Same for clients disconnecting with ECONNRESET, both were useful debug aids, but now they are just useless spam that can look like an error to an unknowing user. Signed-off-by: Sasha Finkelstein <[email protected]>
1 parent 7b84815 commit 67fdf91

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

crates/muvm/src/guest/bridge/common.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::rc::{Rc, Weak};
1111
use std::{env, fs, mem, slice, thread};
1212

1313
use anyhow::Result;
14+
use log::debug;
1415
use nix::errno::Errno;
1516
use nix::libc::{c_int, c_void, off_t, O_RDWR};
1617
use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags, EpollTimeout};
@@ -849,9 +850,15 @@ impl<'a, P: ProtocolHandler> Client<'a, P> {
849850
if fd == self.socket.as_raw_fd() as u64 {
850851
let event = self
851852
.process_socket(events)
852-
.map_err(|e| {
853-
eprintln!("Client {fd} disconnected with error: {e:?}");
854-
e
853+
.map_err(|err| {
854+
if let Some(errno) = err.downcast_ref::<Errno>() {
855+
if errno == &Errno::ECONNRESET {
856+
debug!("Client {fd} disconnected with error: {err:?}");
857+
return err;
858+
}
859+
}
860+
eprintln!("Client {fd} disconnected with error: {err:?}");
861+
err
855862
})
856863
.unwrap_or(ClientEvent::Close);
857864
match event {

crates/muvm/src/guest/bridge/pipewire.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::os::fd::{AsFd, AsRawFd, OwnedFd};
44
use std::{env, mem};
55

66
use anyhow::Result;
7+
use log::debug;
78
use nix::errno::Errno;
89
use nix::sys::epoll::EpollFlags;
910
use nix::sys::eventfd::{EfdFlags, EventFd};
@@ -249,7 +250,7 @@ impl ProtocolHandler for PipeWireProtocolHandler {
249250
resources: &mut VecDeque<CrossDomainResource>,
250251
) -> Result<StreamRecvResult> {
251252
if data.len() < PipeWireHeader::SIZE {
252-
eprintln!(
253+
debug!(
253254
"Pipewire message truncated (expected at least 16 bytes, got {})",
254255
data.len(),
255256
);
@@ -288,7 +289,7 @@ impl ProtocolHandler for PipeWireProtocolHandler {
288289
data: &mut [u8],
289290
) -> Result<StreamSendResult<Self::ResourceFinalizer>> {
290291
if data.len() < PipeWireHeader::SIZE {
291-
eprintln!(
292+
debug!(
292293
"Pipewire message truncated (expected at least 16 bytes, got {})",
293294
data.len(),
294295
);

crates/muvm/src/guest/bridge/x11.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::thread::JoinHandle;
1212
use std::{fs, mem, ptr, thread};
1313

1414
use anyhow::Result;
15+
use log::debug;
1516
use nix::errno::Errno;
1617
use nix::fcntl::readlink;
1718
use nix::libc::{
@@ -177,7 +178,7 @@ impl ProtocolHandler for X11ProtocolHandler {
177178
});
178179
}
179180
if data.len() < 32 {
180-
eprintln!(
181+
debug!(
181182
"X11 message truncated (expected at least 32 bytes, got {})",
182183
data.len(),
183184
);
@@ -228,7 +229,7 @@ impl ProtocolHandler for X11ProtocolHandler {
228229
});
229230
}
230231
if buf.len() < 4 {
231-
eprintln!(
232+
debug!(
232233
"X11 message truncated (expected at least 4 bytes, got {})",
233234
buf.len(),
234235
);
@@ -237,7 +238,7 @@ impl ProtocolHandler for X11ProtocolHandler {
237238
let mut req_len = u16::from_ne_bytes(buf[2..4].try_into().unwrap()) as usize * 4;
238239
if req_len == 0 {
239240
if buf.len() < 8 {
240-
eprintln!(
241+
debug!(
241242
"X11 message truncated (expected at least 8 bytes, got {})",
242243
buf.len(),
243244
);

0 commit comments

Comments
 (0)