Ryan Bloom wrote:
On Sunday 09 December 2001 06:55 pm, Brian Pane wrote:
...
Thus the change that I'm thinking of is: - on the first sononblock() call on a newly accepted socket, skip the F_GETFL operation and assume that the current flags are zero.
By my reading of the man pages, this ought to be safe because the fcntl-set options on the listener socket aren't inherited by the new socket that's created upon accept. But is there any platform (among the UNIXes supported by APR) where it's *not* safe to make this assumption?
Yeah, unfortunately some platforms do inherit these flags.
Can we improve the performance by only doing the F_GETFL once though? If we do it once, and cache the results in the apr_sockopt, we should be safe. Then the only problem is that we have to keep them up to date whenever we use F_SETFL, but I think we can handle that.
That would work in general, although in the case of Apache it's the very first F_SETFL after the accept that's the problem. Is it feasible to ifdef the platforms where the flags are inherited, so that we can optimize away this first F_GETFL on the platforms where it's safe (and optimize away the second F_GETFL on the platforms that do inherit the flag)?
Alternately, how about an API for "set this socket to nonblocking and clear any other fcntl flags that might be set"? That would allow us to duplicate the behavior of 1.3.x, which just does the F_SETFL without the F_GETFL.
--Brian
