suspend/resume in trouble...

Dag-Erling Smørgrav des at
Thu Mar 23 12:39:46 CET 2006

"Poul-Henning Kamp" <phk at> writes:
> I love it when I learn something, but I hate when it is a new bug in
> It seems that once you have listen(2)'ed a socket, there is no way
> to unlisten(2) again.
> I might intuitively be expected that listen(2) with a queue length
> of zero would make it reject all future connection attempts, but the
> semantics for that case is to accept the one connection and reject
> all others while that connection exists.

Well, we can easily fix that in FreeBSD.

Strictly speaking, POSIX allows listen(0) to work as we want it to:

  A backlog argument of 0 may allow the socket to accept connections,
  in which case the length of the listen queue may be set to an
  implementation-defined minimum value.

(note "may")

However, there's a significant chance this may break existing
applications which expect listen(0) to be equivalent to
hard to test for in a configure script.  Therefore, it's probably
simpler to add an unlisten() syscall.

I'm fairly certain I can come up with a patch for Linux as well, but
it will take time to get it accepted.

On systems which lack unlisten(), a suspended server can simply reply
to any incoming connections with 503 Service Unavailable, without even
bothering to look at the request.

Dag-Erling Smørgrav
Senior Software Developer
Linpro AS -

More information about the varnish-dev mailing list