httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Chekan <>
Subject Re: Console _commit() fails on Win
Date Wed, 16 Nov 2005 07:34:51 GMT
On 11/13/05, William A. Rowe, Jr. <> wrote:
> Vadim Chekan wrote:


> > I think we can remove safely _commit() call.
> >
> > Note: I have Win XP Pro(sp2) & Visual Studio 2005.
> Yes, that's possibly true in VS2005, but not in MSVC 5 or 6, so it stays.
> Note that httpd.exe really isn't 'meant' to be a console app.  But we can do
> more to mop up any error emits.  You presume _IOCOMMIT is set, but that isn't
> neccessarily so.
> Perhaps we should slowly start backing it out from VS2005 first, then VS2003
> and earlier as someone can confirm it's not needed.
> The only way to validate your proposed patch is to go forward from NT 4.0 (we
> can safely assume a baseline of SP6), NT 5.0 and NT 5.1, using the MSVCRT as
> well as the new clibs.
> So please provide the exact, complete assert message you receive (hate it when
> that trivial detail is not reported) and we can look at a way to safely ignore
> it for now.
> Bill

Sorry for not being clear enough.
When I wrote "console" I meant file handler #2 (stderr)
This issue appears not just when you run httpd.exe as a console
application but it cause httpd.exe fail as a service (daemon) if it is
compiled in Visual Stuidio 2005 in Debug mode.

You were right supposing that it's only VS-2005 issue. I checked
sources of VS's crt and found that in 2005 version in
commit.c:_commit() they introduced an assert:
_ASSERTE(("Invalid file descriptor. File possibly closed by a
different thread",0));
This assert is triggered because _commit in VS2005(and VS6 and VS2003) calls:
if ( !FlushFileBuffers((HANDLE)_get_osfhandle(filedes)) ) {
   retval = GetLastError();

As I mentioned in my first mail, MSDN states that FlushFileBuffers()
returns Invalid Handle if called on console output (default file
handlers #1, #2).

So the code in mpm/winnt/nt_eventlog.c:mpm_nt_eventlog_stderr_open():
_commit(2 /* stderr */);
is wrong on *any* of VS6, VS2003, VS2005. VS 2005 is the only one
which complains about it and as result of failed assert (in Debug mode
only) terminates.

Also reviwing VC6-2005's crt sources shows that fflush() calls
_commit() for FILE* that have appropriate flags set so there is no
need (at least in VC*) to call _commit() after fflush()

What I'm not sure is about other compilers for Win32 (if Apache
supports any). It might be valid (required code for them). Does C
specify fflush() behaviour related to OS cache?

Vadim Chekan.

View raw message