diff options
author | Ingela Anderton Andin <[email protected]> | 2017-11-14 08:53:01 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2017-11-17 09:35:12 +0100 |
commit | 6eba2a32f2585bfd1d94fa1066167901213d0408 (patch) | |
tree | 22d739a2649ecd6895c8876384d890569dbadcb4 /lib/inets/src | |
parent | 4c736d27d32b5334d8ba978c100a591caf0ac604 (diff) | |
download | otp-6eba2a32f2585bfd1d94fa1066167901213d0408.tar.gz otp-6eba2a32f2585bfd1d94fa1066167901213d0408.tar.bz2 otp-6eba2a32f2585bfd1d94fa1066167901213d0408.zip |
inets: Eliminate race condition
Only run test case for http as the socket manipulation done by the test case
requires much more manipulation to work for https. However, that this test case
started failing constantly instead of sporadically is proof that this change
is a good thing.
Diffstat (limited to 'lib/inets/src')
-rw-r--r-- | lib/inets/src/http_client/httpc_handler.erl | 16 | ||||
-rw-r--r-- | lib/inets/src/http_client/httpc_manager.erl | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 6907bf5262..1482f4f922 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -109,7 +109,7 @@ start_link(Parent, Request, Options, ProfileName) -> %% to be called by the httpc manager process. %%-------------------------------------------------------------------- send(Request, Pid) -> - call(Request, Pid, 5000). + call(Request, Pid). %%-------------------------------------------------------------------- @@ -712,12 +712,16 @@ do_handle_info({'EXIT', _, _}, State = #state{request = undefined}) -> do_handle_info({'EXIT', _, _}, State) -> {noreply, State#state{status = close}}. - call(Msg, Pid) -> - call(Msg, Pid, infinity). - -call(Msg, Pid, Timeout) -> - gen_server:call(Pid, Msg, Timeout). + try gen_server:call(Pid, Msg) + catch + exit:{noproc, _} -> + {error, closed}; + exit:{normal, _} -> + {error, closed}; + exit:{{shutdown, _},_} -> + {error, closed} + end. cast(Msg, Pid) -> gen_server:cast(Pid, Msg). diff --git a/lib/inets/src/http_client/httpc_manager.erl b/lib/inets/src/http_client/httpc_manager.erl index a63864493f..ffdf1603b3 100644 --- a/lib/inets/src/http_client/httpc_manager.erl +++ b/lib/inets/src/http_client/httpc_manager.erl @@ -849,11 +849,11 @@ pipeline_or_keep_alive(#request{id = Id, from = From} = Request, HandlerPid, #state{handler_db = HandlerDb} = State) -> - case (catch httpc_handler:send(Request, HandlerPid)) of + case httpc_handler:send(Request, HandlerPid) of ok -> HandlerInfo = {Id, HandlerPid, From}, ets:insert(HandlerDb, HandlerInfo); - _ -> % timeout pipelining failed + {error, closed} -> % timeout pipelining failed start_handler(Request, State) end. |