diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gun.erl | 4 | ||||
-rw-r--r-- | src/gun_ws.erl | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/gun.erl b/src/gun.erl index 3eafe10..bf988da 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -769,6 +769,10 @@ ws_loop(State=#state{parent=Parent, owner=Owner, socket=Socket, {shutdown, Owner} -> %% @todo Protocol:shutdown? %% @todo close frame ok; + {'DOWN', OwnerRef, process, Owner, Reason} -> + Protocol:close(owner_gone, ProtoState), + Transport:close(Socket), + error({owner_gone, Reason}); {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {ws_loop, State}); diff --git a/src/gun_ws.erl b/src/gun_ws.erl index 81682d6..6501893 100644 --- a/src/gun_ws.erl +++ b/src/gun_ws.erl @@ -18,6 +18,7 @@ -export([name/0]). -export([init/7]). -export([handle/2]). +-export([close/2]). -export([send/2]). -export([down/1]). @@ -135,6 +136,8 @@ close(Reason, State) -> %% @todo We need to send a close frame from gun:ws_loop on close. % Normal when Normal =:= stop; Normal =:= timeout -> % send({close, 1000, <<>>}, State); + owner_gone -> + send({close, 1001, <<>>}, State); {error, badframe} -> send({close, 1002, <<>>}, State); {error, badencoding} -> |