aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-04-26 13:35:33 +0200
committerLoïc Hoguin <[email protected]>2019-04-26 13:35:33 +0200
commita943324efff332c76a9738561b42c086fd910552 (patch)
tree9f5363ee1c21debba507d06891356c0aaa974481
parent3f3ed57a5e49a0d61644fae5556c4315e6d05506 (diff)
downloadgun-a943324efff332c76a9738561b42c086fd910552.tar.gz
gun-a943324efff332c76a9738561b42c086fd910552.tar.bz2
gun-a943324efff332c76a9738561b42c086fd910552.zip
No longer error out when the owner exits
No need to have the error repeated in the logs by the Gun process.
-rw-r--r--src/gun.erl2
-rw-r--r--test/gun_SUITE.erl27
2 files changed, 28 insertions, 1 deletions
diff --git a/src/gun.erl b/src/gun.erl
index 7ab13c0..d8aa15b 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -1005,4 +1005,4 @@ keepalive_cancel(State=#state{keepalive_ref=KeepaliveRef}) ->
owner_gone(normal) -> stop;
owner_gone(shutdown) -> {stop, shutdown};
owner_gone(Shutdown = {shutdown, _}) -> {stop, Shutdown};
-owner_gone(Reason) -> {stop, {owner_gone, Reason}}.
+owner_gone(Reason) -> {stop, {shutdown, {owner_gone, Reason}}}.
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index 9f5aa3a..166089b 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -100,6 +100,33 @@ detect_owner_gone(_) ->
error(timeout)
end.
+detect_owner_gone_unexpected(_) ->
+ {ok, ListenSocket} = gen_tcp:listen(0, [binary, {active, false}]),
+ {ok, {_, Port}} = inet:sockname(ListenSocket),
+ Self = self(),
+ spawn(fun() ->
+ {ok, ConnPid} = gun:open("localhost", Port),
+ Self ! {conn, ConnPid},
+ gun:await_up(ConnPid),
+ timer:sleep(100),
+ exit(unexpected)
+ end),
+ {ok, _} = gen_tcp:accept(ListenSocket, 5000),
+ Pid = receive
+ {conn, C} ->
+ C
+ after 1000 ->
+ error(timeout)
+ end,
+ Ref = monitor(process, Pid),
+ receive
+ {'DOWN', Ref, process, Pid, {shutdown, {owner_gone, unexpected}}} ->
+ ok
+ after 1000 ->
+ true = erlang:is_process_alive(Pid),
+ error(timeout)
+ end.
+
detect_owner_gone_ws(_) ->
Name = name(),
{ok, _} = cowboy:start_clear(Name, [], #{env => #{