Perchild: Setting Users and Groups per Virtual Host Page 3
The request processing then moves to the correct child processing. Once a socket is passed over the Unix Domain socket, the new child process is woken up out of poll with data its end of the Unix Domain socket. Each child has a table over sockets to use for this occasion, there is one socket in the table for each thread in the process. Usually, the sockets are set to -1, but when the passed socket descriptor is detected, we set this thread's spot in the table to -2. Later, the fact that the socket is -2 is used to determine that we must receive the socket descriptor from the Unix Domain socket. The received socket is then placed in the thread's position in the socket table.
Processing then continues as normal, reading from the Unix Domain socket, until the post_read_request phase. At this point, we know that the request has come from another child process in our server and we know that this request is meant for this child processes User and Group Id. The only thing left to do is replace the Unix Domain socket that is currently in the connection structure with the socket that was passed from the first child process. This child then continues serving the original request.
This will never be the fastest MPM, because it relies on passing socket descriptors between processes, which is inherently a slow process. It would be much faster to give the server multiple IP addresses, and have different Apache installations listen to port 80 on different IPs. However, that can get very difficult to administer.
This MPM was finished the day before the fifth alpha was released, so it is not well tested at all. Over the next few weeks and months, this MPM will become more stable and more portable. Currently, this MPM has only ever been tested on Linux, but with minor modifications, it should work on almost all Unices. There has been talk of modifying the Windows MPM to allow the threads to change their identities for each request, but that has not happened yet.