diff options
Diffstat (limited to 'src/ranch_acceptor.erl')
-rw-r--r-- | src/ranch_acceptor.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ranch_acceptor.erl b/src/ranch_acceptor.erl index 4acd04f..0a1b8a2 100644 --- a/src/ranch_acceptor.erl +++ b/src/ranch_acceptor.erl @@ -27,10 +27,14 @@ start_link(LSocket, Transport, ConnsSup) -> loop(LSocket, Transport, ConnsSup) -> _ = case Transport:accept(LSocket, infinity) of {ok, CSocket} -> - Transport:controlling_process(CSocket, ConnsSup), - %% This call will not return until process has been started - %% AND we are below the maximum number of connections. - ranch_conns_sup:start_protocol(ConnsSup, CSocket); + case Transport:controlling_process(CSocket, ConnsSup) of + ok -> + %% This call will not return until process has been started + %% AND we are below the maximum number of connections. + ranch_conns_sup:start_protocol(ConnsSup, CSocket); + {error, _} -> + Transport:close(CSocket) + end; %% Reduce the accept rate if we run out of file descriptors. %% We can't accept anymore anyway, so we might as well wait %% a little for the situation to resolve itself. |