Skip to content

Commit

Permalink
Merge pull request #681 from benoitc/fix/gh680
Browse files Browse the repository at this point in the history
ensure we release socket in the pool when requester die
  • Loading branch information
benoitc authored Mar 17, 2021
2 parents 4cd8a5f + ab6f5a1 commit 7d9f598
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/hackney_pool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,19 @@ checkout(Host, Port, Transport, Client) ->
catch _:_ ->
{error, checkout_failure}
end,
Requester ! {checkout, Ref, Result}
case is_process_alive(Requester) of
true ->
Requester ! {checkout, Ref, Result};
false ->
case Result of
{ok, SocketRef, Socket} ->
checkin(SocketRef, Socket);
_Error ->
ok
end
end
end,
_ = spawn_link(Fun),
_ = spawn(Fun),
receive
{checkout, Ref, Result} ->
Result
Expand Down

0 comments on commit 7d9f598

Please sign in to comment.