diff options
author | Juan Facorro <[email protected]> | 2015-06-21 20:09:10 -0300 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-04-30 17:42:27 +0200 |
commit | fb4bd38ffd2c330cbd677d958477aa909210a0b3 (patch) | |
tree | 1bef7a85e5f4204b144e96d4682a5c541bc3bdaa /test/gun_SUITE.erl | |
parent | 7a213b6a95357c5304e9d9a2a52930882bf8305e (diff) | |
download | gun-fb4bd38ffd2c330cbd677d958477aa909210a0b3.tar.gz gun-fb4bd38ffd2c330cbd677d958477aa909210a0b3.tar.bz2 gun-fb4bd38ffd2c330cbd677d958477aa909210a0b3.zip |
Monitor owner and terminate when it dies
Diffstat (limited to 'test/gun_SUITE.erl')
-rw-r--r-- | test/gun_SUITE.erl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl index c62c600..64b8885 100644 --- a/test/gun_SUITE.erl +++ b/test/gun_SUITE.erl @@ -42,6 +42,28 @@ connect_timeout_infinity(_) -> error(timeout) end. +detect_owner_gone(_) -> + Self = self(), + spawn(fun() -> + {ok, ConnPid} = gun:open("google.com", 80), + Self ! {conn, ConnPid}, + gun:await_up(ConnPid) + end), + Pid = receive + {conn, C} -> + C + after 1000 -> + error(timeout) + end, + Ref = monitor(process, Pid), + receive + {'DOWN', Ref, process, Pid, {owner_gone, _}} -> + ok + after 1000 -> + true = erlang:is_process_alive(Pid), + error(timeout) + end. + gone_reason(_) -> doc("The last connection failure must be propagated."), {ok, Pid} = gun:open("localhost", 12345, #{retry => 0}), |