httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Robinson <>
Subject Re: [PATCH] lingering_close performance improvement
Date Wed, 12 Feb 1997 09:42:08 GMT
On Tue, 11 Feb 1997, Dean Gaudet wrote:

> You can open a single socketpair() before forking that all children use to
> send to the parent.  If the buffer isn't full (heh) then a write() of a
> "small size" is atomic. 
> Anyone know if POSIX promises that behaviour?  We actually already rely on
> it -- all our log code assumes that write() for a "small size" is atomic
> (and that the OS implements O_APPEND atomically as well, and that the
> underlying fs allows the atomicity to work... i.e. not NFS). 

When writing to a pipe or FIFO (N.B. _not_ a socket), write requests of 
PIPE_BUF or less are guaranteed to be atomic; i.e. will not be interleved 
with data from other processes doing writes on the same pipe. PIPE_BUF is 
usually defined in limits.h; the Solaris 2.5.1 file has PIPE_BUF of 5120 
and implies that the Posix required minimum value is 512.

Apache 0.6 - 0.8 relied on this behaviour for the DNS caching. Of course,
it has always been a 'feature' of the logging via a pipe that data
corruption was a possibility, but I don't think many people use that option.
When logging to disk, O_APPEND writes are guaranteed to be atomic by
most modern OSes.

For sockets implemented using Streams (SVR4), there is a maximum packet
size that the stream accepts; for writes larger than that, the data is
fragmented by write() before sending it downstream.


View raw message