
des at linpro
Mar 23, 2006, 4:39 AM
Post #3 of 10
(89 views)
Permalink
|
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes: > I love it when I learn something, but I hate when it is a new bug in > UNIX. > > 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 listen(SOME_IMPLEMENTATION_DEFINED_NON_ZERO_VALUE). It's also very 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. DES -- Dag-Erling Sm?rgrav Senior Software Developer Linpro AS - www.linpro.no
|