Subject: | Explicitely rejecting incoming connections when all workers are busy |
Hi,
We're using Net::Server::PreFork for an LMTP mail server. So far so
good, everything works. Great work on a very useful module.
Our problem is the project specs say when no workers are available and
email arrives, we should return "432 Too many sessions" instead of
waiting until a worker finishes and is able to call accept() on the
socket. We have set the *_spare_servers variables to 0 since we don't
actually want to spawn more children. (We're only using PreFork
instead of PreForkSimple to have a chance to get more accurate tallies
of waiting/processing workers, really.)
There doesn't seem to be a way to do this in Net::Server::PreFork (or
Simple). I've tried various things with e.g. the idle_loop_hook, but
that doesn't get run when I need it. The accept_deny stuff is ideally
placed (even though that's not what it's for), but it only runs in the
workers, who have no idea what the other workers are doing anyway.
Basically I'm looking for:
(a) if and only if all workers are busy
(b) and at least one incoming connection is pending
(c) the master process itself (not necessarily, but it's the only one
who has a reasonable expection of knowing if (a) is true) takes
responsability for servicing the pending connections, if only to
tell the client that they have to come back later
Is there such a thing in Net::Server, or a workaround for it?
(Also on the wishlist: exposing the various worker tallies as methods
available in the master process, with documentation on when they are
available/correct/out of date.)