Skip to content

Commit 8c03305

Browse files
authored
do not call worker_from_id with pid<1 (#92)
1 parent 25ee836 commit 8c03305

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cluster.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mutable struct WorkerConfig
9292
end
9393
end
9494

95-
@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED
95+
@enum WorkerState W_CREATED W_CONNECTED W_TERMINATING W_TERMINATED W_UNKNOWN_STATE
9696
mutable struct Worker
9797
id::Int
9898
msg_lock::Threads.ReentrantLock # Lock for del_msgs, add_msgs, and gcflag

src/process_messages.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool)
210210
handle_msg(msg, header, r_stream, w_stream, version)
211211
end
212212
catch e
213-
werr = worker_from_id(wpid)
214-
oldstate = werr.state
213+
oldstate = W_UNKNOWN_STATE
215214

216215
# Check again as it may have been set in a message handler but not propagated to the calling block above
217216
if wpid < 1
@@ -222,6 +221,8 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool)
222221
println(stderr, e, CapturedException(e, catch_backtrace()))
223222
println(stderr, "Process($(myid())) - Unknown remote, closing connection.")
224223
elseif !(wpid in map_del_wrkr)
224+
werr = worker_from_id(wpid)
225+
oldstate = werr.state
225226
set_worker_state(werr, W_TERMINATED)
226227

227228
# If unhandleable error occurred talking to pid 1, exit

0 commit comments

Comments
 (0)