diff options
author | Loïc Hoguin <[email protected]> | 2015-03-06 18:47:33 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-03-06 18:47:33 +0100 |
commit | 02ff6533bbbc5dae95959c4979765d532d9e0af6 (patch) | |
tree | a1caf5f4ce58a99cce0f81662ba14b79f7770e05 /src/ranch_acceptor.erl | |
parent | 3d713aefd4600ec3f6b2c9d6e25943af94f90972 (diff) | |
download | ranch-02ff6533bbbc5dae95959c4979765d532d9e0af6.tar.gz ranch-02ff6533bbbc5dae95959c4979765d532d9e0af6.tar.bz2 ranch-02ff6533bbbc5dae95959c4979765d532d9e0af6.zip |
Handle Transport:controlling_socket/2 errors and close the socket
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. |