Skip to content

Commit a597e64

Browse files
authored
Merge pull request edgurgel#395 from chazsconi/exit-transformer-on-target-exit
Exit transformer on target process exit
2 parents 1b61003 + 0bbb1b3 commit a597e64

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/httpoison/base.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ defmodule HTTPoison.Base do
576576
process_response_headers,
577577
process_response_chunk
578578
) do
579+
# Track the target process so we can exit when it dies
580+
Process.monitor(target)
581+
579582
receive do
580583
{:hackney_response, id, {:status, code, _reason}} ->
581584
send(target, %HTTPoison.AsyncStatus{id: id, code: process_response_status_code.(code)})
@@ -622,6 +625,10 @@ defmodule HTTPoison.Base do
622625
process_response_headers,
623626
process_response_chunk
624627
)
628+
629+
# Exit if the target process dies as this will be a zombie
630+
{:DOWN, _ref, :process, ^target, _reason} ->
631+
:ok
625632
end
626633
end
627634

0 commit comments

Comments
 (0)