From 3be51df0410588a27bb5932c9822864aec9b7c51 Mon Sep 17 00:00:00 2001 From: Damjan Georgievski Date: Sat, 22 Aug 2015 10:11:22 +0200 Subject: [PATCH 1/2] receive ...; Error -> ... eats gen_server:call/cast messages this receive should not even get any other response than {Ref, ok} since the stream never sends anything else. but in highly concurent scenarios, will eat messages sent with gen_server:call/cast and weird stuff will happen --- src/hackney_client/hackney_manager.erl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hackney_client/hackney_manager.erl b/src/hackney_client/hackney_manager.erl index 3f59c3a5..deaf239f 100644 --- a/src/hackney_client/hackney_manager.erl +++ b/src/hackney_client/hackney_manager.erl @@ -370,9 +370,7 @@ handle_call({stop_async_response, Ref, To}, _From, State) -> dict:erase(Owner, Pids1)) end, - {reply, {ok, Ref}, State#mstate{pids=Pids2}}; - Error -> - {reply, Error, State} + {reply, {ok, Ref}, State#mstate{pids=Pids2}} after 5000 -> {reply, {error, timeout}, State} end From e594b88690998ea712f4625d1a1518b8c366fbfd Mon Sep 17 00:00:00 2001 From: Damjan Georgievski Date: Sat, 22 Aug 2015 10:15:43 +0200 Subject: [PATCH 2/2] gen_server:handle_call should return {reply,...,State} this is probably a typo --- src/hackney_client/hackney_manager.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hackney_client/hackney_manager.erl b/src/hackney_client/hackney_manager.erl index deaf239f..8141ed29 100644 --- a/src/hackney_client/hackney_manager.erl +++ b/src/hackney_client/hackney_manager.erl @@ -343,7 +343,7 @@ handle_call({stop_async_response, Ref, To}, _From, State) -> [] -> {reply, {ok, Ref}, State}; [{Ref, {_Owner, nil, _Info}}] -> %% there is no async request to handle, just return - {ok, Ref}; + {reply, {ok, Ref}, State}; [{Ref, {Owner, Stream, Info}}] -> %% tell to the stream to stop Stream ! {Ref, stop_async, self()},