Skip to content

Commit

Permalink
Fix windows ECONNRESET bug
Browse files Browse the repository at this point in the history
Don't close sockets eagerly. Let GC handle it.
  • Loading branch information
savq committed Sep 23, 2022
1 parent 3347b79 commit 6a1593e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/Malt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ function _recv(socket)
response.result
catch e
rethrow(e)
finally
close(socket)
end
end

Expand Down Expand Up @@ -225,7 +223,6 @@ function worker_channel(w::Worker, expr)::Channel
while isopen(channel) && isopen(s)
put!(channel, deserialize(s))
end
close(s)
return
end)
end
Expand Down
8 changes: 3 additions & 5 deletions src/worker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,14 @@ function handle(::Val{:call}, socket, msg)
catch e
# @debug("Exception!", e)
serialize(socket, (status=:err, result=e))
finally
close(socket)
end
end

function handle(::Val{:remote_do}, socket, msg)
try
msg.f(msg.args...; msg.kwargs...)
finally
close(socket)
catch e
nothing
end
end

Expand All @@ -76,7 +74,7 @@ function handle(::Val{:channel}, socket, msg)
while isopen(channel) && isopen(socket)
serialize(socket, take!(channel))
end
isopen(socket) && close(socket)

isopen(channel) && close(channel)
return
end
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using Test

# Terminating workers takes about 0.5s
m.stop(w)
sleep(1)
sleep(2)
@test m.isrunning(w) === false
end

Expand Down Expand Up @@ -74,7 +74,7 @@ end
@test m.isrunning(w) === true

m.stop(w)
sleep(1)
sleep(2)
@test m.isrunning(w) === false
end

Expand Down

0 comments on commit 6a1593e

Please sign in to comment.