diff options
author | Loïc Hoguin <[email protected]> | 2013-08-20 18:48:48 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-08-20 18:48:48 +0200 |
commit | 400b93e44c80e8ffe86a0fe6cd0cf827a94238c2 (patch) | |
tree | 599fd46345f481ecf0d7dc6e3ec21b43ed773e04 | |
parent | c767739ee3e917c9ce3c67827e655f10d6c191f9 (diff) | |
download | ranch-400b93e44c80e8ffe86a0fe6cd0cf827a94238c2.tar.gz ranch-400b93e44c80e8ffe86a0fe6cd0cf827a94238c2.tar.bz2 ranch-400b93e44c80e8ffe86a0fe6cd0cf827a94238c2.zip |
Report errors when connection processes fail
-rw-r--r-- | src/ranch_conns_sup.erl | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl index 54d6758..ab79ef1 100644 --- a/src/ranch_conns_sup.erl +++ b/src/ranch_conns_sup.erl @@ -147,11 +147,13 @@ loop(State=#state{parent=Parent, ref=Ref, conn_type=ConnType, CurConns, NbChildren, Sleepers); {'EXIT', Parent, Reason} -> exit(Reason); - {'EXIT', Pid, _} when Sleepers =:= [] -> + {'EXIT', Pid, Reason} when Sleepers =:= [] -> + report_error(Ref, Pid, Reason), erase(Pid), loop(State, CurConns - 1, NbChildren - 1, Sleepers); %% Resume a sleeping acceptor if needed. - {'EXIT', Pid, _} -> + {'EXIT', Pid, Reason} -> + report_error(Ref, Pid, Reason), erase(Pid), [To|Sleepers2] = Sleepers, To ! self(), @@ -188,3 +190,13 @@ system_terminate(Reason, _, _, _) -> system_code_change(Misc, _, _, _) -> {ok, Misc}. + +%% We use ~999999p here instead of ~w because the latter doesn't +%% support printable strings. +report_error(_, _, normal) -> + ok; +report_error(Ref, Pid, Reason) -> + error_logger:error_msg( + "Ranch listener ~p had connection process ~p " + "exit with reason: ~999999p~n", + [Ref, Pid, Reason]). |