[erlang-questions] Building a Non-blocking TCP server using OTP principles
Claes Wikström
klacke@REDACTED
Thu Aug 23 00:15:00 CEST 2007
Serge Aleynikov wrote:
>
> {ok, Socket} = gen_tcp:accept(Listener)
>
> So you would need to monitor how many accept failures you got in the
> last several seconds and do some intelligent recovery. This would
> complicate code by quite a bit.
Checking the errors that can occur for accept, the only ones
that apply are:
[EMFILE] The per-process descriptor table is full.
[ENFILE] The system file table is full.
In either of these cases, there is really nothing good that can
be done. I've just changed the default behavior of yaws to
terminate the entire yaws application when accept actually fails.
When running the standalone server, the entire node will die and
be restarted by heart.
This is a bit like trying to do something clever when malloc()
fails - pondering on the issue for a couple of years eventually
the only sane thing to do is exit(1), same thing with accept() here.
I think there are quite a few erlang/server apps that log the
accept() error an retry - which is very bad if the error is e{n,m}file.
/klacke
More information about the erlang-questions
mailing list