diff options
author | Loïc Hoguin <[email protected]> | 2013-04-08 19:01:59 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-04-08 19:01:59 +0200 |
commit | 120d37cf752357a5b31ab8c94656fbfe2d2c7c35 (patch) | |
tree | 5aff8d4d1c025b9642c5760d2d4f6569a3f3b616 /src/ranch_acceptor.erl | |
parent | 7eb82e6750c28335b0bd58009cddfc1630364516 (diff) | |
download | ranch-120d37cf752357a5b31ab8c94656fbfe2d2c7c35.tar.gz ranch-120d37cf752357a5b31ab8c94656fbfe2d2c7c35.tar.bz2 ranch-120d37cf752357a5b31ab8c94656fbfe2d2c7c35.zip |
Wait in the acceptor if we get emfile errors
This should avoid using all CPU because we keep trying to accept.
Diffstat (limited to 'src/ranch_acceptor.erl')
-rw-r--r-- | src/ranch_acceptor.erl | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ranch_acceptor.erl b/src/ranch_acceptor.erl index 44cf52d..f838b7d 100644 --- a/src/ranch_acceptor.erl +++ b/src/ranch_acceptor.erl @@ -39,6 +39,11 @@ loop(LSocket, Transport, 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); + %% 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. + {error, emfile} -> + receive after 100 -> ok end; %% We want to crash if the listening socket got closed. {error, Reason} when Reason =/= closed -> ok |