Ignore ENOBUFS when writing to VM's socket (#18)

* Ignore ENOBUFS when writing to VM's socket

* Hint the into() target type to the compiler to fix the build error

* Fix Clippy warnings
This commit is contained in:
Nikolay Edigaryev
2022-12-15 00:15:19 +04:00
committed by GitHub
parent 4ab3cd7e5c
commit 59cd9098e0
3 changed files with 24 additions and 7 deletions
+15 -4
View File
@@ -16,10 +16,21 @@ impl Proxy {
self.snoop(frame);
}
self.vm
.write(frame.as_ref())
.map(|_| ())
.context("failed to write to the VM")
match self.vm.write(frame.as_ref()) {
Ok(_) => Ok(()),
Err(err) => {
if let Some(libc::ENOBUFS) = err.raw_os_error() {
sentry::capture_message(
"No buffer space available in VM's socket",
sentry::Level::Warning,
);
return Ok(());
}
Err(err).context("failed to write to the VM")
}
}
}
fn allowed_from_host(&mut self, frame: &EthernetFrame<&[u8]>) -> Option<()> {