From 988f1546a1fb40f7d71d68ef81b00d0a81fdfa5f Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Tue, 20 Feb 2024 18:05:43 +0100 Subject: [PATCH] do not call worker_from_id with pid<1 --- stdlib/Distributed/src/cluster.jl | 2 +- stdlib/Distributed/src/process_messages.jl | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index d8cc052967d50..2444695f90afd 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -92,7 +92,7 @@ mutable struct WorkerConfig end end -@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED +@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED W_UNKNOWN_STATE mutable struct Worker id::Int msg_lock::Threads.ReentrantLock # Lock for del_msgs, add_msgs, and gcflag diff --git a/stdlib/Distributed/src/process_messages.jl b/stdlib/Distributed/src/process_messages.jl index e68e05b9db52b..3032917e49f93 100644 --- a/stdlib/Distributed/src/process_messages.jl +++ b/stdlib/Distributed/src/process_messages.jl @@ -210,8 +210,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) handle_msg(msg, header, r_stream, w_stream, version) end catch e - werr = worker_from_id(wpid) - oldstate = werr.state + oldstate = W_UNKNOWN_STATE # Check again as it may have been set in a message handler but not propagated to the calling block above if wpid < 1 @@ -222,6 +221,8 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) println(stderr, e, CapturedException(e, catch_backtrace())) println(stderr, "Process($(myid())) - Unknown remote, closing connection.") elseif !(wpid in map_del_wrkr) + werr = worker_from_id(wpid) + oldstate = werr.state set_worker_state(werr, W_TERMINATED) # If unhandleable error occurred talking to pid 1, exit