From ae30ebb757bcb71e14b8e6bfccbcb2f414f0880e Mon Sep 17 00:00:00 2001 From: DirectPool Date: Fri, 23 Oct 2026 15:18:24 +0000 Subject: [PATCH] Always decrement worker connections when a Stratum connection ends --- p2poolv2_lib/src/stratum/server.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/p2poolv2_lib/src/stratum/server.rs b/p2poolv2_lib/src/stratum/server.rs index f33cc02..a03c494 100644 --- a/p2poolv2_lib/src/stratum/server.rs +++ b/p2poolv2_lib/src/stratum/server.rs @@ -479,6 +479,10 @@ where // need it. let is_hydrapool = ctx.mode == PoolMode::Hydrapool; + // Every way out of the loop below must reach the worker count decrement at the end, + // so errors are kept here and returned after it. + let mut result: Result<(), Box> = Ok(()); + // Process each line as it arrives loop { // After authorization, send the first notify from the current template @@ -572,12 +576,14 @@ where .await { error!("Error processing message from {}: {}", addr, e); - return Err(e); + result = Err(e); + break; } } Some(Err(e)) => { error!("Error reading line from {}: {}", addr, e); - return Err(Box::new(e)); + result = Err(Box::new(e)); + break; } None => { debug!("Connection closed by client: {}", addr); @@ -607,7 +613,7 @@ where session.workername.clone().unwrap_or_default(), ) .await; - Ok(()) + result } async fn process_incoming_message( -- 2.43.0