Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

[mp2] mod_perl closes apache's stdin and/or stdout

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


dmitry at karasik

Sep 25, 2007, 7:06 AM

Post #1 of 16 (3236 views)
Permalink
[mp2] mod_perl closes apache's stdin and/or stdout

Hello,

In mixed environment of mod_perl and cgi, cgi scripts may choose to not use
mod_perl request interface, and read content of POST requests directly from
STDIN. mod_perl during the initialization process closes file descriptor 0,
and frees it for further reuse in other processes. Therefore, any cgi script
executing after mod_perl is initialized, and in the same process tree, will
have file descriptor 0 closed. The concrete example where this behavior leads
to impossibility of processing POST requests is reported earlier and is located
at

http://marc.info/?l=apache-modperl&m=119062450730646&w=2

The proposed patch fixes the issue, however, not being a perl guts expert, I
would urge someone with a deeper knowledge of perl to look at it first. Chances
are that there exists a mechanism in perl that allows non-destructive
duplication and overloading of perl IO handles.

Cheers,
Dmitry Karasik

--- modperl_io.c.orig 2007-09-25 15:36:02.000000000 +0200
+++ modperl_io.c 2007-09-25 15:35:51.000000000 +0200
@@ -129,6 +129,15 @@
Perl_croak(aTHX_ "Failed to dup STDIN: %" SVf, get_sv("!", TRUE));
}

+ /* In mixed environment of mod_perl and cgi scripts, cgi scripts may read content of
+ * POST requests off STDIN. do_close() calls actual close(0), freeing the descriptor 0
+ * for reuse, and creating havoc for anyone reading from file descriptor 0.
+ * This hack changes the IO type to IoTYPE_STD, because do_close() does not call
+ * underlying close() on IO handles of these types, but does free the associated
+ * resources. */
+ if ( IoIFP(io) && PerlIO_fileno(IoIFP(io)) == 0)
+ IoTYPE(io) = IoTYPE_STD;
+
/* similar to PerlIO::scalar, the PerlIO::Apache layer doesn't
* have file descriptors, so STDIN must be closed before it can
* be reopened */

2. Used Components and their Configuration:

*** mod_perl version 2.000003

*** using /usr/ports/www/mod_perl2/work/mod_perl-2.0.3/lib/Apache2/BuildConfig.pm

*** Makefile.PL options:
MP_APR_LIB => aprext
MP_APXS => /usr/local/sbin/apxs
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1


*** The httpd binary was not found


*** (apr|apu)-config linking info

-L/usr/local/lib -laprutil-1 -lexpat -liconv -L/usr/local/lib
-L/usr/local/lib -lapr-1 -lcrypt -lpthread


*** /usr/local/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=freebsd, osvers=6.2-release, archname=i386-freebsd-64int
uname='freebsd freebsd.org 6.2-release freebsd 6.2-release #0: sat oct 14 21:57:31 pdt 2006 kris [at] freebsd:usrsrcsysmagickernelpath i386 '
config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=undef uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
optimize='-O2 -fno-strict-aliasing -pipe ',
cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lm -lcrypt -lutil
perllibs=-lm -lcrypt -lutil
libc=, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_INT
USE_LARGE_FILES USE_PERLIO
Locally applied patches:
defined-or
Built under freebsd
Compiled at Oct 15 2006 05:04:59
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8
.

*** Packages of interest status:

Apache2 : -
Apache2::Request : -
CGI : 3.15
ExtUtils::MakeMaker: 6.30, undef
LWP : 5.805
mod_perl : -
mod_perl2 : 2.000003


This report was generated by t/REPORT on Tue Sep 25 13:39:09 2007 GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
modperl <at> perl.apache.org. To subscribe to the list send an empty
email to modperl-subscribe [at] perl




--
Sincerely,
Dmitry Karasik


fred at redhotpenguin

Sep 25, 2007, 10:52 AM

Post #2 of 16 (3137 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Dmitry Karasik wrote:
> Hello,
>
> In mixed environment of mod_perl and cgi, cgi scripts may choose to not use
> mod_perl request interface, and read content of POST requests directly from
> STDIN. mod_perl during the initialization process closes file descriptor 0,
> and frees it for further reuse in other processes. Therefore, any cgi script
> executing after mod_perl is initialized, and in the same process tree, will
> have file descriptor 0 closed. The concrete example where this behavior leads
> to impossibility of processing POST requests is reported earlier and is located
> at
>
> http://marc.info/?l=apache-modperl&m=119062450730646&w=2
>
> The proposed patch fixes the issue, however, not being a perl guts expert, I
> would urge someone with a deeper knowledge of perl to look at it first. Chances
> are that there exists a mechanism in perl that allows non-destructive
> duplication and overloading of perl IO handles.

I am not a perl guts expert either (gozer??), but looking through the
perl source it looks like this idiom is used in a few places. But we
really need a reproducible test case to verify that this is indeed a
problem.

I took a quick swing at putting one together but my mod_perl environment
is a bit screwed up right now. Can you see if it runs on your setup?
And hopefully passes with your change, and fails without? This test may
not work at all :) but if it does and this problem is reproducible then
that improves our chances of getting the fix accepted in some form.

Index: ModPerl-Registry/t/conf/extra.conf.in
===================================================================
--- ModPerl-Registry/t/conf/extra.conf.in (revision 543707)
+++ ModPerl-Registry/t/conf/extra.conf.in (working copy)
@@ -182,6 +182,17 @@
PerlResponseHandler ModPerl::Registry
</Location>

+### test for mixed mod_perl/cgi environment ###
+<Location /stdin_override/mod_perl>
+ SetHandler perl-script
+ PerlResponseHandler ModPerl::Registry
+ PerlOptions +ParseHeaders
+</Location>
+
+<Location /stdin_override/cgi>
+ SetHandler cgi-script
+</Location>
+
### deflate tests ###
<IfModule mod_alias.c>
Alias /registry_bb_deflate/ @ServerRoot@/cgi-bin/

Index: ModPerl-Registry/t/cgi-bin/stdin.pl
===================================================================
--- ModPerl-Registry/t/cgi-bin/stdin.pl (revision 0)
+++ ModPerl-Registry/t/cgi-bin/stdin.pl (revision 0)
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use CGI qw/:standard/;
+
+print <<END;
+Content-type: text/html
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <body>
+ <form method="post"><input type="submit" name="submit" value="Submit">
+ </form>
+END
+
+if (param()) {
+ my $submit = param('submit');
+ if ($submit) {
+ print "<p>submitted</p>";
+ }
+}
+
+print <<END;
+ </body>
+</html>
+END
+

Index: ModPerl-Registry/t/stdin.t
===================================================================
--- ModPerl-Registry/t/stdin.t (revision 0)
+++ ModPerl-Registry/t/stdin.t (revision 0)
@@ -0,0 +1,24 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest qw(POST);
+
+plan tests => 2, need [qw(CGI)],
+ need_min_module_version CGI => 3.08;
+
+{
+ my $url = "/stdin_override/mod_perl";
+ my $res = POST $url;
+
+ ok t_cmp($res->content,
+ qr{submitted},
+ "form submission ok under mod_perl");
+
+ $url = "/stdin_override/cgi";
+ $res = POST $url;
+ ok t_cmp($res->content,
+ qr{submitted},
+ "stdin reset, form submission ok under cgi");
+}

>
> Cheers,
> Dmitry Karasik
>
> --- modperl_io.c.orig 2007-09-25 15:36:02.000000000 +0200
> +++ modperl_io.c 2007-09-25 15:35:51.000000000 +0200
> @@ -129,6 +129,15 @@
> Perl_croak(aTHX_ "Failed to dup STDIN: %" SVf, get_sv("!", TRUE));
> }
>
> + /* In mixed environment of mod_perl and cgi scripts, cgi scripts may read content of
> + * POST requests off STDIN. do_close() calls actual close(0), freeing the descriptor 0
> + * for reuse, and creating havoc for anyone reading from file descriptor 0.
> + * This hack changes the IO type to IoTYPE_STD, because do_close() does not call
> + * underlying close() on IO handles of these types, but does free the associated
> + * resources. */
> + if ( IoIFP(io) && PerlIO_fileno(IoIFP(io)) == 0)
> + IoTYPE(io) = IoTYPE_STD;
> +
> /* similar to PerlIO::scalar, the PerlIO::Apache layer doesn't
> * have file descriptors, so STDIN must be closed before it can
> * be reopened */
>
> 2. Used Components and their Configuration:
>
> *** mod_perl version 2.000003
>
> *** using /usr/ports/www/mod_perl2/work/mod_perl-2.0.3/lib/Apache2/BuildConfig.pm
>
> *** Makefile.PL options:
> MP_APR_LIB => aprext
> MP_APXS => /usr/local/sbin/apxs
> MP_COMPAT_1X => 1
> MP_GENERATE_XS => 1
> MP_LIBNAME => mod_perl
> MP_USE_DSO => 1
>
>
> *** The httpd binary was not found
>
>
> *** (apr|apu)-config linking info
>
> -L/usr/local/lib -laprutil-1 -lexpat -liconv -L/usr/local/lib
> -L/usr/local/lib -lapr-1 -lcrypt -lpthread
>
>
> *** /usr/local/bin/perl -V
> Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
> Platform:
> osname=freebsd, osvers=6.2-release, archname=i386-freebsd-64int
> uname='freebsd freebsd.org 6.2-release freebsd 6.2-release #0: sat oct 14 21:57:31 pdt 2006 kris [at] freebsd:usrsrcsysmagickernelpath i386 '
> config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -Ud_dosuid -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint'
> hint=recommended, useposix=true, d_sigaction=define
> usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
> useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
> use64bitint=define use64bitall=undef uselongdouble=undef
> usemymalloc=y, bincompat5005=undef
> Compiler:
> cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
> optimize='-O2 -fno-strict-aliasing -pipe ',
> cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
> ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', gccosandvers=''
> intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
> ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
> alignbytes=4, prototype=define
> Linker and Libraries:
> ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
> libpth=/usr/lib /usr/local/lib
> libs=-lm -lcrypt -lutil
> perllibs=-lm -lcrypt -lutil
> libc=, so=so, useshrplib=true, libperl=libperl.so
> gnulibc_version=''
> Dynamic Linking:
> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
> cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'
>
>
> Characteristics of this binary (from libperl):
> Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_INT
> USE_LARGE_FILES USE_PERLIO
> Locally applied patches:
> defined-or
> Built under freebsd
> Compiled at Oct 15 2006 05:04:59
> %ENV:
> PERL_LWP_USE_HTTP_10="1"
> @INC:
> /usr/local/lib/perl5/5.8.8/BSDPAN
> /usr/local/lib/perl5/site_perl/5.8.8/mach
> /usr/local/lib/perl5/site_perl/5.8.8
> /usr/local/lib/perl5/site_perl
> /usr/local/lib/perl5/5.8.8/mach
> /usr/local/lib/perl5/5.8.8
> .
>
> *** Packages of interest status:
>
> Apache2 : -
> Apache2::Request : -
> CGI : 3.15
> ExtUtils::MakeMaker: 6.30, undef
> LWP : 5.805
> mod_perl : -
> mod_perl2 : 2.000003
>
>
> This report was generated by t/REPORT on Tue Sep 25 13:39:09 2007 GMT.
>
> -------------8<---------- End Bug Report --------------8<----------
>
> Note: Complete the rest of the details and post this bug report to
> modperl <at> perl.apache.org. To subscribe to the list send an empty
> email to modperl-subscribe [at] perl
>
>
>
>


torsten.foertsch at gmx

Sep 25, 2007, 12:49 PM

Post #3 of 16 (3137 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

On Tuesday 25 September 2007 19:52, Fred Moyer wrote:
> I took a quick swing at putting one together but my mod_perl environment
> is a bit screwed up right now. šCan you see if it runs on your setup?

With a few tweaks the test runs in my environment (trunk+2.2.6-worker). But it
succeeds in both cases.

I was really surprised to see this mail because my usual setup is a mix of
mod_perl and mod_cgi/mod_cgid. The original post at
http://marc.info/?l=apache-modperl&m=119062450730646&w=2 suggests that it may
be some coincidence with keep-alive. So I even tried it via telnet:

$ telnet localhost 8529
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /stdin_override/mod_perl HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 9

submit=1

HTTP/1.1 200 OK
Date: Tue, 25 Sep 2007 19:41:36 GMT
Server: Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d
mod_perl/2.0.4-dev Perl/v5.8.8
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain

26
MOD_PERL: mod_perl/2.0.4-dev
submitted
0

POST /stdin_override/cgi HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 9

submit=1

HTTP/1.1 200 OK
Date: Tue, 25 Sep 2007 19:41:39 GMT
Server: Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d
mod_perl/2.0.4-dev Perl/v5.8.8
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain

14
MOD_PERL:
submitted
0

Connection closed by foreign host.


What did I wrong?

Torsten
Attachments: x (2.10 KB)


dmitry at karasik

Sep 26, 2007, 12:30 AM

Post #4 of 16 (3115 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

> I took a quick swing at putting one together but my mod_perl environment
> is a bit screwed up right now. Can you see if it runs on your setup?

I don't know. I've run "perl ModPerl-Registry/t/cgi-bin/stdin.pl" and it
(unsurprisingly) fails with a "Can't connect to localhost:8529", and
I can't find in the docs what is the correct test invocation.

The problem might not be always observable in real live setup because
mod_perl and cgi can be in different process trees, but it will always
emerge when the very first request server by apache is handled using
mod_perl, and the second by cgi.

My test setup contains this request in a file:

POST /cgi-bin/modperl.cgi HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
Keep-Alive: 300

submit=Submit

POST /cgi-bin/cgi.cgi HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
Keep-Alive: 0
Connection: close

submit=Submit

and it runs as

httpd -X &
nc localhost 80 < request
killall httpd

and the error is always reproducible. I don't know if the test suite can stop
and start apache at will, but if yes, the test must do that before executing
that stdin.t.

--
Sincerely,
Dmitry Karasik


dmitry at karasik

Sep 26, 2007, 12:31 AM

Post #5 of 16 (3112 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

> What did I wrong?

Try the same input but with apache freshly started, it must be the very first
apache request, then the error is fully reproducible.

--
Sincerely,
Dmitry Karasik


gozer at ectoplasm

Sep 29, 2007, 11:49 PM

Post #6 of 16 (3088 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Dmitry Karasik wrote:
>> What did I wrong?

Not running a perlio Perl ?

> Try the same input but with apache freshly started, it must be the very first
> apache request, then the error is fully reproducible.

------------------------------------------------------------------------
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/
Attachments: signature.asc (0.24 KB)


swp5jhu02 at sneakemail

Dec 17, 2007, 1:31 AM

Post #7 of 16 (2893 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Hi,

Dmitry Karasik dmitry-at-karasik.eu.org wrote:
> mod_perl during the initialization process closes file descriptor 0,
> and frees it for further reuse in other processes. Therefore, any cgi script
> executing after mod_perl is initialized, and in the same process tree, will
> have file descriptor 0 closed. The concrete example where this behavior leads
> to impossibility of processing POST requests is reported earlier and is located
> at
>
> http://marc.info/?l=apache-modperl&m=119062450730646&w=2

Dmitry's patch from Sep 25, 2007
http://www.gossamer-threads.com/lists/modperl/modperl/94912 has still
not been applied to SVN. May I humbly ask that this patch is applied?

On the dev list
http://marc.info/?l=apache-modperl-dev&m=119125026607247&w=2 it seems
that whether or not this really is a bug is drawn into question. I can
confirm that it, really, really is a bug!

I'm now getting emails from others experiencing the same problem,
querying for a solution. Dmitry's patch fixes our problem. I'm now
forwarding links to the patch to other users. Wouldn't it be easier to
have this or another patch applied or another that also fixes the problem???

The patch didn't apply completely cleanly here against HEAD, but this
one does ( also at http://demo.capmon.dk/~pvm/modperl_io.patch ) :

~/mod_perl-2.0/src/modules/perl> svn diff
Index: modperl_io.c
===================================================================
--- modperl_io.c (revision 604795)
+++ modperl_io.c (working copy)
@@ -116,6 +116,7 @@
/* if STDIN is open, dup it, to be restored at the end of response */
if (handle && SvTYPE(handle) == SVt_PVGV &&
IoTYPE(GvIO(handle)) != IoTYPE_CLOSED) {
+ IO * io = GvIO(handle);
handle_save = gv_fetchpv(Perl_form(aTHX_
"Apache2::RequestIO::_GEN_%ld",
(long)PL_gensym++),
@@ -128,6 +129,17 @@
Perl_croak(aTHX_ "Failed to dup STDIN: %" SVf, get_sv("!",
TRUE));
}

+ /* In mixed environment of mod_perl and cgi scripts, cgi
+ * scripts may read content of POST requests off
+ * STDIN. do_close() calls actual close(0), freeing the
+ * descriptor 0 for reuse, and creating havoc for anyone
+ * reading from file descriptor 0. This hack changes the IO
+ * type to IoTYPE_STD, because do_close() does not call
+ * underlying close() on IO handles of these types, but does
+ * free the associated resources. */
+ if ( IoIFP(io) && PerlIO_fileno(IoIFP(io)) == 0)
+ IoTYPE(io) = IoTYPE_STD;
+
/* similar to PerlIO::scalar, the PerlIO::Apache layer doesn't
* have file descriptors, so STDIN must be closed before it can
* be reopened */

Thanks,

Peter
--
Peter Valdemar Mørch
http://www.morch.com


fred at redhotpenguin

Dec 17, 2007, 6:25 PM

Post #8 of 16 (2887 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Peter Valdemar Mørch wrote:
> Hi,
>
> Dmitry Karasik dmitry-at-karasik.eu.org wrote:
>> mod_perl during the initialization process closes file descriptor 0,
>> and frees it for further reuse in other processes. Therefore, any cgi
>> script
>> executing after mod_perl is initialized, and in the same process tree,
>> will
>> have file descriptor 0 closed. The concrete example where this
>> behavior leads
>> to impossibility of processing POST requests is reported earlier and
>> is located
>> at
>>
>> http://marc.info/?l=apache-modperl&m=119062450730646&w=2
>
> Dmitry's patch from Sep 25, 2007
> http://www.gossamer-threads.com/lists/modperl/modperl/94912 has still
> not been applied to SVN. May I humbly ask that this patch is applied?

I remember that Toersten and I put together a unit test for this but I
don't think there was any change in behavior with this patch, so I'm not
sure if anyone was able to demonstrate that it changed the behavior.

If you have the tuits and could track down that unit test, show that it
exercises the problem in question, we probably wouldn't need much else
to apply this patch. I'd try to do this but am overextended on my tuits
right now.

>
> On the dev list
> http://marc.info/?l=apache-modperl-dev&m=119125026607247&w=2 it seems
> that whether or not this really is a bug is drawn into question. I can
> confirm that it, really, really is a bug!
>
> I'm now getting emails from others experiencing the same problem,
> querying for a solution. Dmitry's patch fixes our problem. I'm now
> forwarding links to the patch to other users. Wouldn't it be easier to
> have this or another patch applied or another that also fixes the
> problem???
>
> The patch didn't apply completely cleanly here against HEAD, but this
> one does ( also at http://demo.capmon.dk/~pvm/modperl_io.patch ) :
>
> ~/mod_perl-2.0/src/modules/perl> svn diff
> Index: modperl_io.c
> ===================================================================
> --- modperl_io.c (revision 604795)
> +++ modperl_io.c (working copy)
> @@ -116,6 +116,7 @@
> /* if STDIN is open, dup it, to be restored at the end of response */
> if (handle && SvTYPE(handle) == SVt_PVGV &&
> IoTYPE(GvIO(handle)) != IoTYPE_CLOSED) {
> + IO * io = GvIO(handle);
> handle_save = gv_fetchpv(Perl_form(aTHX_
> "Apache2::RequestIO::_GEN_%ld",
> (long)PL_gensym++),
> @@ -128,6 +129,17 @@
> Perl_croak(aTHX_ "Failed to dup STDIN: %" SVf, get_sv("!",
> TRUE));
> }
>
> + /* In mixed environment of mod_perl and cgi scripts, cgi
> + * scripts may read content of POST requests off
> + * STDIN. do_close() calls actual close(0), freeing the
> + * descriptor 0 for reuse, and creating havoc for anyone
> + * reading from file descriptor 0. This hack changes the IO
> + * type to IoTYPE_STD, because do_close() does not call
> + * underlying close() on IO handles of these types, but does
> + * free the associated resources. */
> + if ( IoIFP(io) && PerlIO_fileno(IoIFP(io)) == 0)
> + IoTYPE(io) = IoTYPE_STD;
> +
> /* similar to PerlIO::scalar, the PerlIO::Apache layer doesn't
> * have file descriptors, so STDIN must be closed before it can
> * be reopened */
>
> Thanks,
>
> Peter


gozer at ectoplasm

Dec 17, 2007, 10:56 PM

Post #9 of 16 (2892 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Fred Moyer wrote:
> Peter Valdemar Mørch wrote:
>> Hi,
>>
>> Dmitry Karasik dmitry-at-karasik.eu.org wrote:
>>> mod_perl during the initialization process closes file descriptor 0,
>>> and frees it for further reuse in other processes. Therefore, any cgi
>>> script
>>> executing after mod_perl is initialized, and in the same process tree,
>>> will
>>> have file descriptor 0 closed. The concrete example where this
>>> behavior leads
>>> to impossibility of processing POST requests is reported earlier and
>>> is located
>>> at
>>>
>>> http://marc.info/?l=apache-modperl&m=119062450730646&w=2
>> Dmitry's patch from Sep 25, 2007
>> http://www.gossamer-threads.com/lists/modperl/modperl/94912 has still
>> not been applied to SVN. May I humbly ask that this patch is applied?
>
> I remember that Toersten and I put together a unit test for this but I
> don't think there was any change in behavior with this patch, so I'm not
> sure if anyone was able to demonstrate that it changed the behavior.

It certainly breaks t/modperl/io_nested_with_closed_stds
[error] [client 127.0.0.1] Filehandle STDOUT reopened as STDIN only for input at t/response/TestModperl/io_nested_with_closed_stds.pm line 49.\n

> If you have the tuits and could track down that unit test, show that it
> exercises the problem in question, we probably wouldn't need much else
> to apply this patch. I'd try to do this but am overextended on my tuits
> right now.

Yup, without a test case that correctly demonstrates the bug, and a patch
that doesn't break existing tests, not very likely to get applied.

--
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/
Attachments: signature.asc (0.24 KB)


heiko at wecos

Feb 5, 2010, 2:25 AM

Post #10 of 16 (2120 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Dear List-Members,

with interest I found the below thread. Starting in Oct. or Nov. last year I am getting a lot of messages in apaches error_log like:

[Fri Feb 5 11:07:09 2010] -e: Software caused connection abort at ...

And it always happen in a print to STDOUT. I notice that it also happen with smaller scripts (running under mod_perl) with no database connection, i.e. scripts which do the following:

use CGI;
use IO::File;

my $q = CGI->new();
print $q->header() . $q->start_html();

my $fp = IO::File->new('< /somewhere/');
if ($fp) {
binmode STDOUT;
while (read($fp, $buffer, 1024)) {
print $buffer; # << abort points to here !!!
}
$fh->close();
}
print $q->end_html();

So I am really wondering whats going on here. The above file works for years now, has not been touched and the content of the opened files isn't empty. The server is a FreeBSD 7.0, apache apache-2.2.14, prefork MPM, mod_perl2-2.0.4 everything from a current freebsd ports.

I use a perl-startup script for apache:

---snip--snip---
#/usr/bin/perl

use CGI();
CGI->compile(':all');
use DBI;
DBI->install_driver("mysql");
use Carp;
---snap---snap---

which is loaded within httpd.conf with:

<IfModule mod_perl.c>
PerlWarn On
PerlTaintCheck On
PerlModule Apache::DBI
PerlRequire /usr/local/etc/apache22/perl-startup.pl

<Perl>
use CGI::Carp;
$SIG{__DIE__} = sub { confess shift };
$SIG{__WARN__} = \&Carp::cluck;
</Perl>

<Files *.pl>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
PerlSendHeader On
</Files>

</IfModule>

I would appreciate any help or ideas to get rid of the aborts.

Heiko



> On Tue, Jan 26, 2010 at 5:20 PM, Jonathan Swartz <swartz [at] pobox> wrote:
>> This never got a response. Which surprises me, since I think it is a
>> legitimate and nasty bug.
>>
>> So is the silence because
>> 1) people don't think it's really a bug
>> 2) people glazed over while reading the description
>> 3) ??
>
> 4) Don't understand how widespread or common this issue is, or if you
> are the only one seeing it.
>
>>
>> Thanks :)
>> Jon
>>
>> On Jan 8, 2010, at 6:15 AM, Jonathan Swartz wrote:
>>
>>> (A continuation of:
>>> http://marc.info/?l=apache-modperl&m=117507879929572&w=2
>>> http://marc.info/?l=apache-modperl&m=119072925228529&w=2
>>> )
>>>
>>> I've just spent many frustrating days debugging a situation that turned
>>> out to be caused by mod_perl's closing of file descriptor 1 (STDOUT).
>>>
>>> Here's the reproducible case I ultimately got it down to. Using mod_perl
>>> 2, with a dead-simple configuration and this handler:
>>>
>>> use DBI;
>>> sub handler {
>>> my $dbh = DBI->connect( "DBI:mysql:$database", $user, $pass, {
>>> RaiseError => 1 } );
>>> system('echo "hello"');
>>> eval { $dbh->do("select 1") };
>>> print "dbh - " . ( $@ ? "error: $@\n" : "ok" ) . "\n";
>>> return 0;
>>> }
>>>
>>> This outputs:
>>>
>>> dbh - error: DBD::mysql::db do failed: Lost connection to MySQL server
>>> during query at...
>>>
>>> The DBI connection dies because mod_perl closes fd 1 (STDOUT). So the next
>>> open - in this case the remote mysql connection created by DBI - gets fd 1.
>>> The child process created by system() writes innocently to STDOUT, which
>>> goes to our mysql socket, causing havoc.
>>>
>>> We can confirm this by inserting this at the beginning of the handler:
>>>
>>> sub handler {
>>> open(my $fh, ">/dev/null");
>>> print "fh - " . fileno($fh) . "\n";
>>> ...
>>>
>>> Now this outputs:
>>>
>>> fh - 1
>>> dbh - ok
>>>
>>> The initial open grabs fd 1, which means that DBI gets a different fd, and
>>> the connection doesn't die.
>>>
>>> Now this example is contrived, but replace 'echo "hello"' with any
>>> innocuous system() or backtick call that accidentally sends a bit of output
>>> to STDOUT, and you can see how this would cause all kinds of baffling bugs.
>>> In my case, it was originally a call to "sendmail" that intermittently sent
>>> a warning to STDOUT, and thus destroyed our first database connection. It
>>> worked fine in mod_perl 1, but started breaking when we upgraded to mod_perl
>>> 2.
>>>
>>> Is there really no way to fix this in mod_perl, perhaps by automatically
>>> opening a /dev/null handle as I did above? Other future developers will
>>> surely endure the same hours of frustration I did if it is left alone.
>>>
>>> Thanks
>>> Jon
>>>
>>
>>


aw at ice-sa

Feb 5, 2010, 6:49 AM

Post #11 of 16 (2123 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Heiko Weber wrote:
> Dear List-Members,
>
> with interest I found the below thread. Starting in Oct. or Nov. last year I am getting a lot of messages in apaches error_log like:
>
> [Fri Feb 5 11:07:09 2010] -e: Software caused connection abort at ...
>
> And it always happen in a print to STDOUT. I notice that it also happen with smaller scripts (running under mod_perl) with no database connection, i.e. scripts which do the following:
>
...

>
> So I am really wondering whats going on here. The above file works for years now, has not been touched and the content of the opened files isn't empty. The server is a FreeBSD 7.0, apache apache-2.2.14, prefork MPM, mod_perl2-2.0.4 everything from a current freebsd ports.
>

This seems to be happening when your server-side module is trying to
send data back to the browser who requested it.
The most common explanation is that, by the time your module tries to
send the answer, the browser connection does not exist anymore, because
the browser (or something in-between the server and browser) closed it.
This happens for example when the user clicks on a link which triggers
your module, then changes his mind and clicks somewhere else (or closes
the window or the browser) before your module has finished sending the
response.
In other words, he hung up on you.

It is quite frequent and nothing to worry about in principle.

Where it would get more worrying, is that it could indicate that your
application is taking too long to send back a result to the user, and
that he's losing patience.
If a user clicks on a link and expects an answer, he will usually wait
only 10-20 seconds maximum before starting to worry. He may then just
click again on the same link, which would have the same effect.


heiko at wecos

Feb 5, 2010, 10:16 AM

Post #12 of 16 (2125 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Hi André,

I know what you mean, and I can't agree with you - the server response time is really low - most pages are finished loading in less 1-2 seconds, and the overall load of the server is at a low level. I believe there is an issue, maybe something what Jon is talking about, I also using some "system()" call's to execute sendmail or sudo tasks, so maybe STDOUT really gets closed - I have no idea. I only see the abort messages in errorlog very frequent, maybe 3-4 per minute.

Heiko

Am 05.02.2010 um 15:49 schrieb André Warnier:

>
> Heiko Weber wrote:
>> Dear List-Members,
>> with interest I found the below thread. Starting in Oct. or Nov. last year I am getting a lot of messages in apaches error_log like:
>> [Fri Feb 5 11:07:09 2010] -e: Software caused connection abort at ...
>> And it always happen in a print to STDOUT. I notice that it also happen with smaller scripts (running under mod_perl) with no database connection, i.e. scripts which do the following:
> ...
>
>> So I am really wondering whats going on here. The above file works for years now, has not been touched and the content of the opened files isn't empty. The server is a FreeBSD 7.0, apache apache-2.2.14, prefork MPM, mod_perl2-2.0.4 everything from a current freebsd ports.
>
> This seems to be happening when your server-side module is trying to send data back to the browser who requested it.
> The most common explanation is that, by the time your module tries to send the answer, the browser connection does not exist anymore, because the browser (or something in-between the server and browser) closed it.
> This happens for example when the user clicks on a link which triggers your module, then changes his mind and clicks somewhere else (or closes the window or the browser) before your module has finished sending the response.
> In other words, he hung up on you.
>
> It is quite frequent and nothing to worry about in principle.
>
> Where it would get more worrying, is that it could indicate that your application is taking too long to send back a result to the user, and that he's losing patience.
> If a user clicks on a link and expects an answer, he will usually wait only 10-20 seconds maximum before starting to worry. He may then just click again on the same link, which would have the same effect.


sog at msg

Feb 16, 2010, 2:26 PM

Post #13 of 16 (2030 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

On 02/05/2010 12:16 PM, Heiko Weber wrote:
> Hi André,
>
> I know what you mean, and I can't agree with you - the server response time is really low - most pages are finished loading in less 1-2 seconds, and the overall load of the server is at a low level. I believe there is an issue, maybe something what Jon is talking about, I also using some "system()" call's to execute sendmail or sudo tasks, so maybe STDOUT really gets closed - I have no idea. I only see the abort messages in errorlog very frequent, maybe 3-4 per minute.
>
> Heiko
>
Of course STDOUT, STDIN, and STDERR get closed, not by mod_perl but by
apache. Every UNIX process when demonized must close them to detach
from its controling terminal.

Apache reopens STDERR to its log file, but STDOUT and STDIN remain closed.

Maybe de confusion arises from the fact that when executing a CGI the
server connects them to the client socket, but in mod_perl you are in
the deamon process space.

Please check "Advanced Programing in the UNIX environment", chapter 13:
"Daemon processes" by W. Richard Stevens.

Regards.

Salvador.


heiko at wecos

Feb 18, 2010, 12:21 AM

Post #14 of 16 (2030 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Salvador,

to avoid such issues my "external" tasks don't use STDOUT, STDIN or STDERR. They take their parameters from control files and write their results back to a status file. This tasks don't send any output back to the browsers. As I said, usually some "sudo's to change some system settings.

Well, I could replace all system() calls and just store the task jobs into a database table, to schedule a background job with cron to check and complete this tasks, but then I lost the immediately feedback to the user/browser ... AND this is a lot of work for me - unless I can exactly repeat the issue I am not sure if it is worth to try it.

Currently it feels to me like a "leakage", sometimes a httpd/mod_perl/process do something, and later (maybe when working on the next client request) STDOUT is closed. This makes it hard to create a sample program to repeat it. Within a single script I can do almost everything: call system(), open DBI connections, write to STDOUT, ... everything seems to be fine.

Heiko

Am 16.02.2010 um 23:26 schrieb Salvador Ortiz Garcia:

> On 02/05/2010 12:16 PM, Heiko Weber wrote:
>> Hi André,
>>
>> I know what you mean, and I can't agree with you - the server response time is really low - most pages are finished loading in less 1-2 seconds, and the overall load of the server is at a low level. I believe there is an issue, maybe something what Jon is talking about, I also using some "system()" call's to execute sendmail or sudo tasks, so maybe STDOUT really gets closed - I have no idea. I only see the abort messages in errorlog very frequent, maybe 3-4 per minute.
>>
>> Heiko
>>
> Of course STDOUT, STDIN, and STDERR get closed, not by mod_perl but by apache. Every UNIX process when demonized must close them to detach from its controling terminal.
>
> Apache reopens STDERR to its log file, but STDOUT and STDIN remain closed.
>
> Maybe de confusion arises from the fact that when executing a CGI the server connects them to the client socket, but in mod_perl you are in the deamon process space.
>
> Please check "Advanced Programing in the UNIX environment", chapter 13: "Daemon processes" by W. Richard Stevens.
>
> Regards.
>
> Salvador.

--
Wecos <> Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5
heiko [at] wecos <> http://www.wecos.de
Tel. +49 (4169) 91000 <> Fax +49 (4169) 919033
_______________________________________________________________
This email may contain confidential and privileged material for
the sole use of the intended recipient. Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient please contact the sender and delete all copies.
_______________________________________________________________
Diese E-Mail kann digital signiert sein. Falls Ihr E-Mail-Programm
nicht ueber die notwendigen Prueffunktionen verfuegt, ignorieren
Sie bitte die angehaengte Signatur-Datei.
_______________________________________________________________
This email may be digitally signed. If your email software does
not support the necessary validation feature, please disregard the
attached signature file.
_______________________________________________________________


eric.berg at barclayscapital

Feb 18, 2010, 8:24 AM

Post #15 of 16 (2028 views)
Permalink
RE: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

I'm starting to use Gearman to get around this whole problem. We use a lot of external processes for many things, so this issue wtih Apache2 really bit me hard in the bee-hind. I've gone to great lengths to work around it, but so far the job queue approach seems to be the most elegant and least problematic approach. Of course, the recommendation came from the gentle folks on this list originally.

Eric

________________________________
From: Heiko Weber [mailto:heiko [at] wecos]
Sent: Thursday, February 18, 2010 3:22 AM
To: Salvador Ortiz Garcia
Cc: mod_perl list
Subject: Re: [mp2] mod_perl closes apache's stdin and/or stdout

Salvador,

to avoid such issues my "external" tasks don't use STDOUT, STDIN or STDERR. They take their parameters from control files and write their results back to a status file. This tasks don't send any output back to the browsers. As I said, usually some "sudo's to change some system settings.

Well, I could replace all system() calls and just store the task jobs into a database table, to schedule a background job with cron to check and complete this tasks, but then I lost the immediately feedback to the user/browser ... AND this is a lot of work for me - unless I can exactly repeat the issue I am not sure if it is worth to try it.

Currently it feels to me like a "leakage", sometimes a httpd/mod_perl/process do something, and later (maybe when working on the next client request) STDOUT is closed. This makes it hard to create a sample program to repeat it. Within a single script I can do almost everything: call system(), open DBI connections, write to STDOUT, ... everything seems to be fine.

Heiko

Am 16.02.2010 um 23:26 schrieb Salvador Ortiz Garcia:

On 02/05/2010 12:16 PM, Heiko Weber wrote:
Hi André,

I know what you mean, and I can't agree with you - the server response time is really low - most pages are finished loading in less 1-2 seconds, and the overall load of the server is at a low level. I believe there is an issue, maybe something what Jon is talking about, I also using some "system()" call's to execute sendmail or sudo tasks, so maybe STDOUT really gets closed - I have no idea. I only see the abort messages in errorlog very frequent, maybe 3-4 per minute.

Heiko

Of course STDOUT, STDIN, and STDERR get closed, not by mod_perl but by apache. Every UNIX process when demonized must close them to detach from its controling terminal.

Apache reopens STDERR to its log file, but STDOUT and STDIN remain closed.

Maybe de confusion arises from the fact that when executing a CGI the server connects them to the client socket, but in mod_perl you are in the deamon process space.

Please check "Advanced Programing in the UNIX environment", chapter 13: "Daemon processes" by W. Richard Stevens.

Regards.

Salvador.

--
Wecos <> Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5
heiko [at] wecos<mailto:heiko [at] wecos> <> http://www.wecos.de<http://www.wecos.de/>

_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing. Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________


heiko at wecos

Feb 18, 2010, 12:36 PM

Post #16 of 16 (2026 views)
Permalink
Re: [mp2] mod_perl closes apache's stdin and/or stdout [In reply to]

Wow, thanks Eric ! That seems to be very nice, I'll give it a try and will report later here if avoiding system() calls reduce the number of aborted connections.

Heiko

Am 18.02.2010 um 17:24 schrieb eric.berg [at] barclayscapital:

> I'm starting to use Gearman to get around this whole problem. We use a lot of external processes for many things, so this issue wtih Apache2 really bit me hard in the bee-hind. I've gone to great lengths to work around it, but so far the job queue approach seems to be the most elegant and least problematic approach. Of course, the recommendation came from the gentle folks on this list originally.
>
> Eric
>
> From: Heiko Weber [mailto:heiko [at] wecos]
> Sent: Thursday, February 18, 2010 3:22 AM
> To: Salvador Ortiz Garcia
> Cc: mod_perl list
> Subject: Re: [mp2] mod_perl closes apache's stdin and/or stdout
>
> Salvador,
>
> to avoid such issues my "external" tasks don't use STDOUT, STDIN or STDERR. They take their parameters from control files and write their results back to a status file. This tasks don't send any output back to the browsers. As I said, usually some "sudo's to change some system settings.
>
> Well, I could replace all system() calls and just store the task jobs into a database table, to schedule a background job with cron to check and complete this tasks, but then I lost the immediately feedback to the user/browser ... AND this is a lot of work for me - unless I can exactly repeat the issue I am not sure if it is worth to try it.
>
> Currently it feels to me like a "leakage", sometimes a httpd/mod_perl/process do something, and later (maybe when working on the next client request) STDOUT is closed. This makes it hard to create a sample program to repeat it. Within a single script I can do almost everything: call system(), open DBI connections, write to STDOUT, ... everything seems to be fine.
>
> Heiko
>
> Am 16.02.2010 um 23:26 schrieb Salvador Ortiz Garcia:
>
>> On 02/05/2010 12:16 PM, Heiko Weber wrote:
>>> Hi André,
>>>
>>> I know what you mean, and I can't agree with you - the server response time is really low - most pages are finished loading in less 1-2 seconds, and the overall load of the server is at a low level. I believe there is an issue, maybe something what Jon is talking about, I also using some "system()" call's to execute sendmail or sudo tasks, so maybe STDOUT really gets closed - I have no idea. I only see the abort messages in errorlog very frequent, maybe 3-4 per minute.
>>>
>>> Heiko
>>>
>> Of course STDOUT, STDIN, and STDERR get closed, not by mod_perl but by apache. Every UNIX process when demonized must close them to detach from its controling terminal.
>>
>> Apache reopens STDERR to its log file, but STDOUT and STDIN remain closed.
>>
>> Maybe de confusion arises from the fact that when executing a CGI the server connects them to the client socket, but in mod_perl you are in the deamon process space.
>>
>> Please check "Advanced Programing in the UNIX environment", chapter 13: "Daemon processes" by W. Richard Stevens.
>>
>> Regards.
>>
>> Salvador.
>
> --
> Wecos <> Heiko Weber Computer Systeme
> D-21644 Sauensiek <> Immenweg 5
> heiko [at] wecos <> http://www.wecos.de
> _______________________________________________
>
> This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing. Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent from other members of the Barclays Group.
> _______________________________________________

--
Wecos <> Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5
heiko [at] wecos <> http://www.wecos.de
Tel. +49 (4169) 91000 <> Fax +49 (4169) 919033
_______________________________________________________________
This email may contain confidential and privileged material for
the sole use of the intended recipient. Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient please contact the sender and delete all copies.
_______________________________________________________________
Diese E-Mail kann digital signiert sein. Falls Ihr E-Mail-Programm
nicht ueber die notwendigen Prueffunktionen verfuegt, ignorieren
Sie bitte die angehaengte Signatur-Datei.
_______________________________________________________________
This email may be digitally signed. If your email software does
not support the necessary validation feature, please disregard the
attached signature file.
_______________________________________________________________

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.