httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43534] New: - mod_perl and FastCGI fails on Windows
Date Tue, 02 Oct 2007 11:08:33 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43534>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43534

           Summary: mod_perl and FastCGI fails on Windows
           Product: Apache httpd-2
           Version: 2.2.6
          Platform: Other
        OS/Version: Windows 2000
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Other Modules
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: Tom.Donovan@acm.org


The changes in APR 1.2.10+ and Apache 2.2.6 caused mod_perl 2.0.3 to fail on
Windows.

mod_perl attempts to save stdin and stdout on entry and restore them on exit.

mod_perl uses POSIX-like int file descriptors - _fileno(stdin) and
_fileno(stdout) - for this.

These file descriptors are not updated by setting STD_INPUT_HANDLE and
STD_OUTPUT_HANDLE via SetStdHandle(). For example,
SetStdHandle(STD_INPUT_HANDLE, newhand) does not change the HANDLE associated
with _fileno(stdin). _fileno(stdin) still refers to the original Windows HANDLE
 - the pipe handle, regardless of whether it is open or has been closed.

This can be seen by comparing the return value from
GetStdHandle(STD_INPUT_HANDLE) to the value from _get_osfhandle(_fileno(stdin))
before and after mpm_winnt.c replaces the stdin handle.

mpm_winnt currently creates a HANDLE to "NUL" as a replacement stdout when
Apache is run as a Windows Service.  Because a console-device HANDLE is not
useable (always returns "invalid handle") when it is inherited by a detached
process, this is needed for command-line too.

Attached is a patch to mpm_winnt (2.2.x branch) which:

1. Creates the "NUL" stdout in the parent for both service and cmd-line
execution, rather than just for service. Only single-process mode (-X) retains
the original console-device stdout HANDLE.

2. Uses _dup2() in the child to replace the stdin file descriptor with the
stdout file descriptor (i.e. to set stdout to "NUL" except in single-process
mode).  Note that this has the side-effect of closing the regular Windows HANDLE
to the stdin pipe too, so it must be done after the child is done reading from
the parent.

3. Sets the Windows HANDLEs (but not the file descriptors) for stdout and stderr
to INVALID_HANDLE_VALUE at child_init for FastCGI modules. See APR bug 43329. 
This would allow current Windows FastCGI modules to work with APR 1.2.10+
without requiring APR_NO_FILE flag changes until a major Apache release, while
other non-Apache APR programs could still take advantage of the APR process
creation changes.

This patch works with mod_fastcgi, mod_fcgid, and mod_perl on Win2k and Vista
when built with either VC6 and VS8.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message