Browse Source

Flush any message acceptors may receive and log them

Inspired by what supervisor does.
Loïc Hoguin 11 years ago
parent
commit
acd19f773b
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/ranch_acceptor.erl

+ 11 - 0
src/ranch_acceptor.erl

@@ -48,4 +48,15 @@ loop(LSocket, Transport, ConnsSup) ->
 		{error, Reason} when Reason =/= closed ->
 			ok
 	end,
+	flush(),
 	?MODULE:loop(LSocket, Transport, ConnsSup).
+
+flush() ->
+	receive Msg ->
+		error_logger:error_msg(
+			"Ranch acceptor received unexpected message: ~p~n",
+			[Msg]),
+		flush()
+	after 0 ->
+		ok
+	end.