diff --git a/src/mochiweb_socket_server.erl b/src/mochiweb_socket_server.erl index ad9194b..e52427f 100644 --- a/src/mochiweb_socket_server.erl +++ b/src/mochiweb_socket_server.erl @@ -296,17 +296,16 @@ handle_info(Msg, State) when ?is_old_state(State) -> handle_info(Msg, upgrade_state(State)); handle_info({'EXIT', Pid, normal}, State) -> {noreply, recycle_acceptor(Pid, State)}; -handle_info({'EXIT', Pid, Reason}, - State=#mochiweb_socket_server{acceptor_pool=Pool}) -> - case sets:is_element(Pid, Pool) of - true -> - %% If there was an unexpected error accepting, log and sleep. - error_logger:error_report({?MODULE, ?LINE, - {acceptor_error, Reason}}), - timer:sleep(100); - false -> - ok +handle_info({'EXIT', Pid, {error, emfile}}, State) -> + error_logger:error_msg("No more file descriptors, reducing request rate.~n"), + timer:sleep(100), + {noreply, recycle_acceptor(Pid, State)}; +handle_info({'EXIT', Pid, Reason}, State=#mochiweb_socket_server{acceptor_pool=Pool}) -> + ErrorType = case sets:is_element(Pid, Pool) of + true -> acceptor_error; + false -> request_error end, + error_logger:error_report({?MODULE, ?LINE, {ErrorType, Reason}}), {noreply, recycle_acceptor(Pid, State)}; % this is what release_handler needs to get a list of modules,