Skip to content

Commit d4c4f39

Browse files
authored
Merge pull request #499 from benoitc/fix/terminate_async_response
fix terminate_async_response
2 parents d2661ef + adb676d commit d4c4f39

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
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

src/hackney_response.erl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ stream_body1(Error, _Client) ->
164164
-spec stream_body_recv(binary(), #client{})
165165
-> {ok, binary(), #client{}} | {error, term()}.
166166
stream_body_recv(Buffer, Client=#client{version=Version, clen=CLen}) ->
167-
io:format("receive ~p~n", [Buffer]),
168-
169167
case recv(Client) of
170168
{ok, Data} ->
171169
stream_body(Data, Client);

0 commit comments

Comments
 (0)