quic-client: Return error when `send_data` fails (#32918)

quic-client: Return error when `send_data` fails
This commit is contained in:
Jon Cinque 2023-08-21 15:02:50 +02:00 committed by GitHub
parent 9a6cf3f528
commit 4d3bcc55a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 16 deletions

View File

@ -4,7 +4,7 @@
use {
async_mutex::Mutex,
async_trait::async_trait,
futures::future::join_all,
futures::future::{join_all, TryFutureExt},
itertools::Itertools,
log::*,
quinn::{
@ -554,20 +554,22 @@ impl ClientConnection for QuicClientConnection {
async fn send_data(&self, data: &[u8]) -> TransportResult<()> {
let stats = Arc::new(ClientStats::default());
let send_buffer = self
.client
.send_buffer(data, &stats, self.connection_stats.clone());
if let Err(e) = send_buffer.await {
warn!(
"Failed to send data async to {}, error: {:?} ",
self.server_addr(),
e
);
datapoint_warn!("send-wire-async", ("failure", 1, i64),);
self.connection_stats.add_client_stats(&stats, 1, false);
} else {
self.connection_stats.add_client_stats(&stats, 1, true);
}
Ok(())
self.client
.send_buffer(data, &stats, self.connection_stats.clone())
.map_ok(|v| {
self.connection_stats.add_client_stats(&stats, 1, true);
v
})
.map_err(|e| {
warn!(
"Failed to send data async to {}, error: {:?} ",
self.server_addr(),
e
);
datapoint_warn!("send-wire-async", ("failure", 1, i64),);
self.connection_stats.add_client_stats(&stats, 1, false);
e.into()
})
.await
}
}