Skip to content

Commit

Permalink
do not call worker_from_id with pid<1 (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtkaplan authored Feb 20, 2024
1 parent 25ee836 commit 8c03305
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/process_messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8c03305

Please sign in to comment.