Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jun 2002 14:50:41 -0700
From:      Alfred Perlstein <bright@mu.org>
To:        Julian Elischer <julian@elischer.org>
Cc:        net@freebsd.org
Subject:   Re: apache and option USE_FLOCK_SERIALIZED_ACCEPT
Message-ID:  <20020624215041.GA53232@elvis.mu.org>
In-Reply-To: <Pine.BSF.4.21.0206241416130.53897-100000@InterJet.elischer.org>
References:  <Pine.BSF.4.21.0206241416130.53897-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
* Julian Elischer <julian@elischer.org> [020624 14:20] wrote:
> 
> for FreeBSD we seem to get this option set..
> 
> this seems bogus..
> 
> it assumes that multiple processes can't listen on the accept 
> at one time...
> 
> does anyone know if FreeBSD is safe for having multiple processes do
> accept() on the same listenning socket?
> 
> My perusal of the code suggests it should be but 
> I'm unsure why the option is set by default for FreeBSD.
> 
> WHat it does is allow only one process to do an accept at one time, 
> by using a file flock() as a semaphore...
> 
> seems to be it should be un-needed.
> 
> am I dreaming? what am I missing?

Having multiple processes blocked in accept(2) is ok, however having
multiple processes blocking in select(2) on the same objects can
cause select collisions which cause superfolous wakeup()s and much
pain.  The flock when listening on multiple sockets mitigates this
_somewhat_, but still causes all processes to be woken up each
time an accept succeeds because the flock is dropped.

I think by using some sort of signalling between a single process
doing select and the rest which get a signal telling them to call
accept, or perhaps using fd passing might work better, but I'm
unsure as I haven't had the time to actually do these modifications.
Basically using some token passing mechanism instead of a broadcast
system, however doing so introduces complexity of course. :)

-- 
-Alfred Perlstein [alfred@freebsd.org]
'Instead of asking why a piece of software is using "1970s technology,"
 start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020624215041.GA53232>