Synchronizing access to shared listening socket

Mark Brown (mbrown@OpenMarket.com)
Thu, 02 May 1996 11:54:23 -0400

Message-Id: <199605021554.LAA14510@breckenridge.openmarket.com>
To: Alan Yagoda/VGI <Alan_Yagoda@vanguard.com>
Subject: Synchronizing access to shared listening socket 
In-Reply-To: Your message of "02 May 1996 09:57:51 EST."
             <9605021658.AA2218@VGI1MAIL.vanguard.com> 
Date: Thu, 02 May 1996 11:54:23 -0400
From: Mark Brown <mbrown@OpenMarket.com>


Alan Yagoda asks:

    When multiple FCGI apps are started using cgi-fcgi utility, all
    processes are sharing the listen port.  When a connection request
    is sent from the server, it looks like the fast cgi library relies
    on the operating system to arbitrate which process will handle the
    request?  I would have expected some sort of mutex or semaphore
    logic required to arbitrate accepting of connections between the
    FCGI processes.

With a correct implementation of sockets, the mutex is provided
in the Unix kernel, so application processes can share one
listening socket.  This works really well on platforms
like HP-UX and Digital UNIX.

Some Sys V family Unixes don't do such a good emulation of
sockets, and require locking at the application level.
The application library provides this locking (see AcquireLock
and ReleaseLock in fcgiapp.c) on SunOS, Solaris, and IRIX.

On AIX you can't set a file lock on a socket, so the locking
code in the application library doesn't work.  That's why
you can't share listening sockets on AIX.

    --mark