From 23eb92dae35f918ff29ddd86f3ec3e7d6959c6e3 Mon Sep 17 00:00:00 2001 From: xfnw Date: Sat, 9 Mar 2024 12:15:33 -0500 Subject: [PATCH] use blocking stdout awaiting on stdout allows new lines to be processed when we are already done with and about to print a line, which causes lines arriving quickly (like the MOTD text) to appear out of order. --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5ba4821..fd08f68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use clap::Parser; -use std::{path::PathBuf, sync::Arc}; +use std::{io::Write, path::PathBuf, sync::Arc}; use tokio::{ io::{self, AsyncBufReadExt, AsyncWriteExt, BufReader}, net::TcpStream, @@ -185,7 +185,7 @@ async fn handle_irc(stream: impl io::AsyncReadExt + io::AsyncWriteExt) { trim_mut(&mut ircbuf); ircbuf.push(b'\n'); - io::stdout().write_all(&ircbuf).await.expect("broken pipe"); + std::io::stdout().write_all(&ircbuf).expect("broken pipe"); ircbuf.clear(); }