ws: don't yield unnecessarily in run_in_message_loop, improve logging

This commit is contained in:
Joakim Frostegård 2024-01-05 23:13:31 +01:00
parent d48deeff8c
commit 579fcb2140
2 changed files with 7 additions and 9 deletions

View file

@ -20,7 +20,7 @@ use futures_rustls::TlsAcceptor;
use glommio::channels::channel_mesh::Senders;
use glommio::channels::local_channel::{LocalReceiver, LocalSender};
use glommio::net::TcpStream;
use glommio::timer::{sleep, timeout};
use glommio::timer::timeout;
use glommio::{enclose, prelude::*};
use hashbrown::hash_map::Entry;
use hashbrown::HashMap;
@ -214,12 +214,6 @@ struct ConnectionReader<S> {
impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionReader<S> {
async fn run_in_message_loop(&mut self) -> anyhow::Result<()> {
loop {
while self.out_message_sender.is_full() {
sleep(Duration::from_millis(100)).await;
yield_if_needed().await;
}
let message = self
.ws_in
.next()

View file

@ -287,10 +287,14 @@ async fn receive_out_messages(
match reference.out_message_sender.try_send((meta, out_message)) {
Ok(()) => {}
Err(GlommioError::Closed(_)) => {}
Err(GlommioError::WouldBlock(_)) => {}
Err(GlommioError::WouldBlock(_)) => {
::log::debug!(
"couldn't send OutMessage over local channel to Connection, channel full"
);
}
Err(err) => {
::log::debug!(
"Couldn't send out_message from shared channel to local receiver: {:?}",
"couldn't send OutMessage over local channel to Connection: {:?}",
err
);
}