Browse Source

Make the acceptors exit rather than crash on socket close

This will avoid some unnecessary logs by default.
SASL can be enabled to log these events.
Loïc Hoguin 6 years ago
parent
commit
2b8ef9b606
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/ranch_acceptor.erl

+ 5 - 2
src/ranch_acceptor.erl

@@ -43,8 +43,11 @@ loop(LSocket, Transport, Logger, ConnsSup) ->
 				"Ranch acceptor reducing accept rate: out of file descriptors~n",
 				[], Logger),
 			receive after 100 -> ok end;
-		%% We want to crash if the listening socket got closed.
-		{error, Reason} when Reason =/= closed ->
+		%% Exit if the listening socket got closed.
+		{error, closed} ->
+			exit(closed);
+		%% Continue otherwise.
+		{error, _} ->
 			ok
 	end,
 	flush(Logger),