Skip to content

Commit 76b9d3f

Browse files
committed
fix terminate_async_response
following observations of @obmarg delay the monitoring of the stream process in wait_async_response instead of doing it in monitor_child. fix #498
1 parent d2661ef commit 76b9d3f

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

src/hackney_manager.erl

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -540,32 +540,20 @@ clean_requests([], _Pid, _Reason, _PoolHandler, State) ->
540540
monitor_child(Pid) ->
541541
erlang:monitor(process, Pid),
542542
unlink(Pid),
543-
544543
receive
545-
{'EXIT', Pid, Reason} ->
546-
receive
547-
{'DOWN', _, process, Pid, normal} ->
548-
ok;
549-
{'DOWN', _, process, Pid, noproc} ->
550-
ok;
551-
{'DOWN', _, process, Pid, _} ->
552-
{error, Reason}
553-
end
544+
{'EXIT', Pid, _} ->
545+
true
554546
after 0 ->
555-
ok
547+
true
556548
end.
557549

558-
terminate_async_response(Stream) ->
559-
terminate_async_response(Stream, shutdown).
550+
terminate_async_response(StreamPid) ->
551+
terminate_async_response(StreamPid, shutdown).
560552

561-
terminate_async_response(Stream, Reason) ->
562-
case monitor_child(Stream) of
563-
ok ->
564-
exit(Stream, Reason),
565-
wait_async_response(Stream);
566-
Error ->
567-
Error
568-
end.
553+
terminate_async_response(StreamPid, Reason) ->
554+
_ = monitor_child(StreamPid),
555+
exit(StreamPid, Reason),
556+
wait_async_response(StreamPid).
569557

570558
wait_async_response(Stream) ->
571559
receive

0 commit comments

Comments
 (0)