From d86d55c1f90b37d991e20ad0f1ac37b1e38b36e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 26 Sep 2019 10:43:12 +0200 Subject: Add a function to change the connection owner While at it the gun:info/1 function has been fixed to work even when we are in the not_connected state, and the owner is now also returned. --- test/gun_SUITE.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl index a0ecddd..715bec5 100644 --- a/test/gun_SUITE.erl +++ b/test/gun_SUITE.erl @@ -384,6 +384,20 @@ retry_timeout(_) -> error(shutdown_too_late) end. +set_owner(_) -> + doc("The owner of the connection can be changed."), + Self = self(), + Pid = spawn(fun() -> + {ok, ConnPid} = gun:open("localhost", 12345), + gun:set_owner(ConnPid, Self), + Self ! {conn, ConnPid} + end), + Ref = monitor(process, Pid), + receive {'DOWN', Ref, process, Pid, _} -> ok after 1000 -> error(timeout) end, + ConnPid = receive {conn, C} -> C after 1000 -> error(timeout) end, + #{owner := Self} = gun:info(ConnPid), + gun:close(ConnPid). + shutdown_reason(_) -> doc("The last connection failure must be propagated."), {ok, Pid} = gun:open("localhost", 12345, #{retry => 0}), -- cgit v1.2.3