0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Exit gracefully on parent exit/sys:terminate/2,3

This commit is contained in:
Loïc Hoguin 2018-10-28 10:20:43 +01:00
parent 21ff3ff256
commit d4129e6305
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
5 changed files with 11 additions and 17 deletions

View file

@ -209,8 +209,7 @@ loop(State=#state{parent=Parent, socket=Socket, transport=Transport, opts=Opts,
loop(State, Buffer);
%% System messages.
{'EXIT', Parent, Reason} ->
%% @todo We should exit gracefully, if possible.
exit(Reason);
terminate(State, {stop, {exit, Reason}, 'Parent process terminated.'});
{system, From, Request} ->
sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {State, Buffer});
%% Messages pertaining to a stream.
@ -1379,8 +1378,7 @@ system_continue(_, _, {State, Buffer}) ->
-spec system_terminate(any(), _, _, {#state{}, binary()}) -> no_return().
system_terminate(Reason, _, _, {State, _}) ->
%% @todo We should exit gracefully, if possible.
terminate(State, Reason).
terminate(State, {stop, {exit, Reason}, 'sys:terminate/2,3 was called.'}).
-spec system_code_change(Misc, _, _, _) -> {ok, Misc} when Misc::{#state{}, binary()}.
system_code_change(Misc, _, _, _) ->