apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Darroch <chr...@pearsoncmg.com>
Subject Re: opening named pipes
Date Tue, 18 Dec 2012 22:39:32 GMT
Graham Leggett wrote:

> The trouble is that to use this, every app that wants to use pipes
> needs to use a special call to do so, which isn't ideal.

   Agreed.  I had hoped to treat the pipe like a file, too, but
ran into the issue that this server likes to open/close its logs
repeatedly, so you get EOFs over the pipe, which tends to close most
readers that treat it like a file (e.g., cat).  After much suffering
I concluded I just wanted rotatelogs to read the darn thing directly.
See http://marc.info/?l=apache-httpd-dev&m=135586929409332&w=2 for details.

   I can certainly see problems with this APR patch -- for example,
I should have supported more than O_NONBLOCK, akin to the way
pipenonblock() in file_io/unix/pipe.c supports things like O_NDELAY too.

   FWIW, the trunk version of apr_file_open() also seems to be missing
these other non-blocking OS filehandle flags in its APR_FOPEN_NONBLOCK
support, if I'm not mistaken.

   The basic problem would be solved if there was a way to get
all the actions of pipenonblock() applied right inside apr_file_open(),
before the filehandle is actually opened.  That way the apr_file_t
flags (is_pipe, blocking, timeout, etc.) would be set properly along
with the appropriate OS filehandle flags.

   Any kind of way to do this would be enough, I think, to support
using rotatelogs against a non-stdin file or pipe ... and that was
really my underlying goal here.

> In our case we wanted the named pipes to be interchangeable with files,
> and created an application that summarised log file data on the fly
> before writing it to the named pipe (for example, 100 hits to "/foo"
> became "100: /foo").

   Some aspects of our setup are relatively unusual, I suspect, but
our server is a well-known one which is documented to support writing
its logs out to FIFOs (with the caveat that it likes to close them!)
Attaching rotatelogs to those is really all I wanted to do, but it
was a bumpier road than I expected.


GPG Key ID: 088335A9
GPG Key Fingerprint: 86CD 3297 7493 75BC F820  6715 F54F E648 0883 35A9

View raw message