From ea276166e3cd575bab00bef87d9ca085b3bed005 Mon Sep 17 00:00:00 2001 From: David Goldstein Date: Mon, 9 Nov 2026 14:36:12 -0500 Subject: [PATCH] Row 3028: cleanup writes nothing to a client that is gone Whatever cleanup tells the client (a trade's offer given back, a shop closed) went to a socket that may be shut, and a partner leaving a trade by quitting logged "Failed to finish trade ... Broken pipe". The player still got the offer back; only the write failed. --- runtime/src/actor/client.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/runtime/src/actor/client.rs b/runtime/src/actor/client.rs index fdd473421..557b9c2c7 100644 --- a/runtime/src/actor/client.rs +++ b/runtime/src/actor/client.rs @@ -174,6 +174,10 @@ pub struct ClientActor { ola_seed: u64, npc_request_id: u64, changing_channel: bool, + /// The connection is over and cleanup has begun: whatever cleanup + /// would tell the client (an offer given back, a shop closed) is not + /// written, as the socket may already be shut. + closing: bool, /// The player left their field for the Cash Shop. in_cash_shop: bool, /// The gift last asked about (SN, receiver, message), which the same ask @@ -291,6 +295,7 @@ impl ClientActor { ola_seed: thread_rng().gen(), npc_request_id: 0, changing_channel: false, + closing: false, in_cash_shop: false, gift_lookup: None, locker_expiry: HashMap::new(), @@ -424,6 +429,9 @@ impl ClientActor { } async fn write(&mut self, packet: &mut Packet) -> Result<(), RuntimeError> { + if self.closing { + return Ok(()); + } let kill = self.kill.clone(); tokio::select! { biased; @@ -2444,6 +2452,7 @@ impl ClientActor { } async fn cleanup(&mut self) { + self.closing = true; if self.game.is_some() { // Before the save: the player gets their offer back, or the // partner's, and their unsold stock.