Skip to content

Commit b97f4f3

Browse files
authored
Ensure that unused TCP connections are closed (#1073)
Otherwise, the new preemptive connection strategy can possibly leave a lot of extra connections open until garbage collection kicks in.
1 parent 233d07a commit b97f4f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Connections.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,11 @@ function getconnection(::Type{TCPSocket},
517517
isready(ch) && return
518518
keepalive && keepalive!(tcp)
519519
Base.@lock ch begin
520-
isready(ch) && return
520+
if isready(ch)
521+
# a valid connection was already made and returned, so close ours
522+
close(tcp)
523+
return
524+
end
521525
put!(ch, tcp)
522526
end
523527
catch e

0 commit comments

Comments
 (0)