fix: resolve self-deadlock in PeerDisconnected handler

The handler held a read guard on the client-context RwLock while calling
process_failed_uploads, which acquires a write guard on the same lock on the
same thread. std RwLock write() then blocks forever, wedging the entire client
operations loop. The read guard is now scoped to just the registry cleanup and
dropped before the write is taken.
This commit is contained in:
michel
2026-07-18 14:37:35 +02:00
parent 846d9750b4
commit c5f57cccea
+9 -1
View File
@@ -722,7 +722,14 @@ impl Client {
username, username,
error, error,
) => { ) => {
let context = match client_context.read_safe() { // Scope the read guard: process_failed_uploads
// below acquires a write lock on the same
// RwLock, which would self-deadlock the entire
// client ops loop if this read guard were still
// held on this thread.
{
let context =
match client_context.read_safe() {
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {
error!( error!(
@@ -739,6 +746,7 @@ impl Client {
{ {
let _ = handle.stop(); let _ = handle.stop();
} }
}
if let Some(error) = error { if let Some(error) = error {
warn!( warn!(
"[client] Peer {} disconnected with error: {:?}", "[client] Peer {} disconnected with error: {:?}",