I belive I've deciphered the "RotateLogs doesn't work for access logs
on Windows" Apache 2.0.44 bug.  It's actually many bugs in conformance.

First, rbb's reorg of the WinNT pipe logic (apr/file_io/win32/pipe.c rev 1.46) 
causes server/log.c ap_open_piped_log() to create an async (nonblocking) 
pipe.  This was very cool for internal pipes.  However, console apps that are
unprepared for Overlapped IO (read: all of them) will die given an Overlapped 
pipe handle.  Even APR doesn't assume (and shouldn't) that a pipe handle
passed as stdin/stdout is an Async handle.  However, Async handles are
the only way to do timeouts.

Unix ap_file_pipe_create() always creates the pipes blocking.  In fixing the
bug, by creating blocking handles (that can't be timed out) for Win32, I also
discovered our nonblocking pipe logic was reversed for parent/child handles 
of the child stdin process. I've just committed all those fixes, so this aspect 
was patched as well.  If you look at the new apr_create_nt_pipe() API, it 
might be worth renaming and exporting it as apr_file_pipe_create_ex().
It's similar to apr_file_pipe_create() with the added blocking mode argument
(APR_FULL_BLOCK, APR_FULL_NONBLOCK, APR_READ_BLOCK and
APR_WRITE_BLOCK).  APR_PARENT/CHILD_BLOCK only makes sense
to a function like apr_procattr_io_set.  In fact, for safety, that creation call
should never create NONBLOCK child pipes, but that's another discussion.

So part one was fixed, now we create the access log's rotatelogs process
with a good stdin stream.  It survives to log an entry, but only until we call 
apr_proc_other_child_check within the WinNT MPM's *maintenence* loop.

It seems that apr_proc_other_child_check is only being used during teardown
of the Unix children.  It also seems that the 'correct' flag passed to the maint
function for your registered otherchild is APR_OC_REASON_RESTART when
the process is still running.

Now mod_log_config kills the child process on APR_OC_REASON_RESTART.
Because Win32 doesn't call the function in maintenance like unix, but in a one 
second health-check loop, we are blowing away our access logger process.

Finally, it looks like apr_proc_other_child_read is the function we *really* wanted
to use within the health check.  But it seems all of these apr_proc_other_child
functions are really misdocumented within APR.  Would someone step up and
spell out exactly what they are *supposed* to be doing within unix, and then we
can discuss how to make them portable to Win32?  It seems we have too much
bubblegum and bailing wire holding them together, and the fixes that I made to
do *exactly* what Unix was doing has killed the WinNT mpm.

Bill


Reply via email to