[hwinfo] Log request stream handler errors instead of panicking.
When clients drop connections to hwinfo without awaiting a response, the
server may receive a PEER_CLOSED error. Since this is a Result::Err,
this propagates up to an expect() call that causes a panic and crashes
the component.
Instead of panicking, these errors are logged and the task that
services the client is allowed to end.
Bug: b/257979013
Bug: 110564
Test: CQ
Change-Id: I97f7c1e648f31e8129b44a13fd838c33351ff5ce
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/761963
Reviewed-by: Devon H. O'Dell <dhobsd@google.com>
Commit-Queue: Michael Brunson <mbrunson@google.com>
(cherry picked from commit 09df80bbf3e9a5f1759cf1e4164e93275f86610e)
diff --git a/src/hwinfo/src/hwinfo_server.rs b/src/hwinfo/src/hwinfo_server.rs
index 1d23140..9f49e4ba 100644
--- a/src/hwinfo/src/hwinfo_server.rs
+++ b/src/hwinfo/src/hwinfo_server.rs
@@ -10,6 +10,7 @@
ProductRequestStream,
},
fuchsia_async as fasync,
+ fuchsia_syslog::fx_log_err,
futures::prelude::*,
std::sync::{Arc, RwLock},
};
@@ -115,14 +116,20 @@
pub fn spawn_device_info_server(server: DeviceInfoServer, stream: DeviceRequestStream) {
fasync::Task::spawn(async move {
- server.handle_requests_from_stream(stream).await.expect("Failed to run device_info service")
+ server
+ .handle_requests_from_stream(stream)
+ .await
+ .unwrap_or_else(|e| fx_log_err!("Failed to run device_info service: {:?}", e));
})
.detach();
}
pub fn spawn_board_info_server(server: BoardInfoServer, stream: BoardRequestStream) {
fasync::Task::spawn(async move {
- server.handle_requests_from_stream(stream).await.expect("Failed to run board_info service")
+ server
+ .handle_requests_from_stream(stream)
+ .await
+ .unwrap_or_else(|e| fx_log_err!("Failed to run board_info service: {:?}", e));
})
.detach();
}
@@ -132,7 +139,7 @@
server
.handle_requests_from_stream(stream)
.await
- .expect("Failed to run product_info service")
+ .unwrap_or_else(|e| fx_log_err!("Failed to run product_info service: {:?}", e));
})
.detach();
}