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

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

am 08.01.2010 15:15:23 von Jonathan Swartz

(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

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 27.01.2010 02:20:15 von Jonathan Swartz

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) ??

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
>

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 27.01.2010 03:47:17 von Fred Moyer

On Tue, Jan 26, 2010 at 5:20 PM, Jonathan Swartz 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=3Dapache-modperl&m=3D117507879929572&w=3 D2
>> http://marc.info/?l=3Dapache-modperl&m=3D119072925228529&w=3 D2
>> )
>>
>> 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:
>>
>> =A0use DBI;
>> =A0sub handler {
>> =A0 =A0 =A0my $dbh =3D DBI->connect( "DBI:mysql:$database", $user, $pass=
, {
>> RaiseError =3D> 1 } );
>> =A0 =A0 =A0system('echo "hello"');
>> =A0 =A0 =A0eval { $dbh->do("select 1") };
>> =A0 =A0 =A0print "dbh - " . ( $@ ? "error: $@\n" : "ok" ) . "\n";
>> =A0 =A0 =A0return 0;
>> =A0}
>>
>> This outputs:
>>
>> =A0dbh - error: DBD::mysql::db do failed: Lost connection to MySQL serve=
r
>> during query at...
>>
>> The DBI connection dies because mod_perl closes fd 1 (STDOUT). So the ne=
xt
>> 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:
>>
>> =A0sub handler {
>> =A0 =A0 =A0 open(my $fh, ">/dev/null");
>> =A0 =A0 =A0 print "fh - " . fileno($fh) . "\n";
>> =A0 =A0 =A0 ...
>>
>> Now this outputs:
>>
>> =A0fh - 1
>> =A0dbh - ok
>>
>> The initial open grabs fd 1, which means that DBI gets a different fd, a=
nd
>> 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 out=
put
>> to STDOUT, and you can see how this would cause all kinds of baffling bu=
gs.
>> In my case, it was originally a call to "sendmail" that intermittently s=
ent
>> a warning to STDOUT, and thus destroyed our first database connection. I=
t
>> 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
>>
>
>

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 05.02.2010 11:25:27 von Heiko Weber

--Apple-Mail-39--704481328
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii

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 =3D CGI->new();
print $q->header() . $q->start_html();

my $fp =3D 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:


PerlWarn On
PerlTaintCheck On
PerlModule Apache::DBI
PerlRequire /usr/local/etc/apache22/perl-startup.pl


use CGI::Carp;
$SIG{__DIE__} =3D sub { confess shift };
$SIG{__WARN__} =3D \&Carp::cluck;



SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
PerlSendHeader On




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 =
wrote:
>> This never got a response. Which surprises me, since I think it is a
>> legitimate and nasty bug.
>>=20
>> So is the silence because
>> 1) people don't think it's really a bug
>> 2) people glazed over while reading the description
>> 3) ??
>=20
> 4) Don't understand how widespread or common this issue is, or if you
> are the only one seeing it.
>=20
>>=20
>> Thanks :)
>> Jon
>>=20
>> On Jan 8, 2010, at 6:15 AM, Jonathan Swartz wrote:
>>=20
>>> (A continuation of:
>>> http://marc.info/?l=3Dapache-modperl&m=3D117507879929572&w=3 D2
>>> http://marc.info/?l=3Dapache-modperl&m=3D119072925228529&w=3 D2
>>> )
>>>=20
>>> 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).
>>>=20
>>> Here's the reproducible case I ultimately got it down to. Using =
mod_perl
>>> 2, with a dead-simple configuration and this handler:
>>>=20
>>> use DBI;
>>> sub handler {
>>> my $dbh =3D DBI->connect( "DBI:mysql:$database", $user, $pass, =
{
>>> RaiseError =3D> 1 } );
>>> system('echo "hello"');
>>> eval { $dbh->do("select 1") };
>>> print "dbh - " . ( $@ ? "error: $@\n" : "ok" ) . "\n";
>>> return 0;
>>> }
>>>=20
>>> This outputs:
>>>=20
>>> dbh - error: DBD::mysql::db do failed: Lost connection to MySQL =
server
>>> during query at...
>>>=20
>>> 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.
>>>=20
>>> We can confirm this by inserting this at the beginning of the =
handler:
>>>=20
>>> sub handler {
>>> open(my $fh, ">/dev/null");
>>> print "fh - " . fileno($fh) . "\n";
>>> ...
>>>=20
>>> Now this outputs:
>>>=20
>>> fh - 1
>>> dbh - ok
>>>=20
>>> The initial open grabs fd 1, which means that DBI gets a different =
fd, and
>>> the connection doesn't die.
>>>=20
>>> 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.
>>>=20
>>> 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.
>>>=20
>>> Thanks
>>> Jon
>>>=20
>>=20
>>=20

--Apple-Mail-39--704481328
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=us-ascii

-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">

separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: =
medium; font-style: normal; font-variant: normal; font-weight: normal; =
letter-spacing: normal; line-height: normal; orphans: 2; text-align: =
auto; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; ">
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">Dear List-Members,
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
"> medium;">
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">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:
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">[Fri Feb  5 =
11:07:09 2010] -e: Software caused connection abort at =
....
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">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:
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: =
medium;">
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">use CGI;
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">use =
IO::File;
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">my $q =3D =
CGI->new();
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">print $q->header() . =
$q->start_html();
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">my $fp =3D =
IO::File->new('< /somewhere/');
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">if ($fp) =
{
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">  binmode =
STDOUT;
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">  while (read($fp, $buffer, =
1024)) {
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">        print =
$buffer;      # << abort points to here =
!!!
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">    }
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
"> medium;">   =
 $fh->close();
}
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium; ">print =
$q->end_html();
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">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.
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">I use a =
perl-startup script for apache:
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: =
medium;">
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">---snip--snip---
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
"> medium;">#/usr/bin/perl
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal =
normal normal 12px/normal Helvetica; "> style=3D"font-size: medium;">
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 12px/normal Helvetica; "> class=3D"Apple-style-span" style=3D"font-size: medium;">use =
CGI();
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium;">CGI->compile(':all');
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">use =
DBI;
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: =
medium;">DBI->install_driver("mysql");
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0px; font: normal normal normal 12px/normal Helvetica; =
">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

 &nb=
sp;      <Perl>
     =
           use =
CGI::Carp;
        $SIG{__DIE__} =3D =
sub { confess shift };
       =
 $SIG{__WARN__} =3D \&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


=
margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; "> style=3D"font-size: medium; ">
On Tue, Jan =
26, 2010 at 5:20 PM, Jonathan Swartz < href=3D"mailto:swartz@pobox.com">swartz@pobox.com> =
wrote:
This never got a response. Which =
surprises me, since I think it is a
type=3D"cite">legitimate and nasty bug.
type=3D"cite">
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.

type=3D"cite">
Thanks =
:)
type=3D"cite">Jon
type=3D"cite">
On Jan 8, 2010, =
at 6:15 AM, Jonathan Swartz wrote:
type=3D"cite">
type=3D"cite">(A continuation =
of:
type=3D"cite"> href=3D"http://marc.info/?l=3Dapache-modperl&m=3D1175078 79929572&w=
=3D2">http://marc.info/?l=3Dapache-modperl&m=3D117507879 929572&w=3D=
2

type=3D"cite"> href=3D"http://marc.info/?l=3Dapache-modperl&m=3D1190729 25228529&w=
=3D2">http://marc.info/?l=3Dapache-modperl&m=3D119072925 228529&w=3D=
2

type=3D"cite">)
type=3D"cite">
type=3D"cite">
type=3D"cite">
I've just spent many frustrating =
days debugging a situation that =
turned
type=3D"cite">out to be caused by mod_perl's closing of file descriptor =
1 (STDOUT).
type=3D"cite">
type=3D"cite">
type=3D"cite">
Here's the reproducible case I =
ultimately got it down to. Using =
mod_perl
type=3D"cite">
2, with a dead-simple =
configuration and this handler:
type=3D"cite">
type=3D"cite">
type=3D"cite">
 use =
DBI;
type=3D"cite"> sub handler =
{
type=3D"cite">     my $dbh =3D DBI->connect( =
"DBI:mysql:$database", $user, $pass, =
{
type=3D"cite">RaiseError =3D> 1 } =
);
type=3D"cite">     system('echo =
"hello"');
type=3D"cite">
     eval { =
$dbh->do("select 1") };
type=3D"cite">
     print "dbh - =
" . ( $@ ? "error: $@\n" : "ok" ) . =
"\n";
type=3D"cite">     return =
0;
type=3D"cite"> }
type=3D"cite">
type=3D"cite">
type=3D"cite">
This =
outputs:
type=3D"cite">
type=3D"cite">
type=3D"cite">
 dbh - error: =
DBD::mysql::db do failed: Lost connection to MySQL =
server
type=3D"cite">during query =
at...
type=3D"cite">
type=3D"cite">
The DBI connection dies because =
mod_perl closes fd 1 (STDOUT). So the =
next
type=3D"cite">open - in this case the remote mysql connection created by =
DBI - gets fd 1.
type=3D"cite">
The child process created by =
system() writes innocently to STDOUT, =
which
type=3D"cite">goes to our mysql socket, causing =
havoc.
type=3D"cite">
type=3D"cite">
We can confirm this by inserting =
this at the beginning of the =
handler:
type=3D"cite">
type=3D"cite">
type=3D"cite">
 sub handler =
{
type=3D"cite">      open(my $fh, =
">/dev/null");
type=3D"cite">
      print "fh - =
" . fileno($fh) . "\n";
type=3D"cite">
      =
....
type=3D"cite">
type=3D"cite">
Now this =
outputs:
type=3D"cite">
type=3D"cite">
type=3D"cite">
 fh - =
1
type=3D"cite"> dbh - ok
type=3D"cite">
type=3D"cite">
type=3D"cite">
The initial open grabs fd 1, =
which means that DBI gets a different fd, =
and
type=3D"cite">the connection doesn't =
die.
type=3D"cite">
type=3D"cite">
Now this example is contrived, =
but replace 'echo "hello"' with =
any
type=3D"cite">innocuous system() or backtick call that accidentally =
sends a bit of output
type=3D"cite">
to STDOUT, and you can see how =
this would cause all kinds of baffling =
bugs.
type=3D"cite">In my case, it was originally a call to "sendmail" that =
intermittently sent
type=3D"cite">
a warning to STDOUT, and thus =
destroyed our first database connection. =
It
type=3D"cite">worked fine in mod_perl 1, but started breaking when we =
upgraded to mod_perl
type=3D"cite">
type=3D"cite">2.
type=3D"cite">
type=3D"cite">
type=3D"cite">
Is there really no way to fix =
this in mod_perl, perhaps by =
automatically
type=3D"cite">
opening a /dev/null handle as I =
did above? Other future developers =
will
type=3D"cite">surely endure the same hours of frustration I did if it is =
left alone.
type=3D"cite">
type=3D"cite">
type=3D"cite">
type=3D"cite">Thanks
type=3D"cite">
type=3D"cite">Jon
type=3D"cite">
type=3D"cite">
type=3D"cite">
type=3D"cite">
n>
=

--Apple-Mail-39--704481328--

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 05.02.2010 15:49:11 von aw

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.

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 05.02.2010 19:16:03 von Heiko Weber

Hi Andr=E9,

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=E9 Warnier:

>=20
> 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:
> ...
>=20
>> 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.
>=20
> 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.
>=20
> It is quite frequent and nothing to worry about in principle.
>=20
> 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.

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 16.02.2010 23:26:11 von 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.

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 18.02.2010 09:21:55 von Heiko Weber

--Apple-Mail-2-411306681
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=iso-8859-1

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.=20

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=E9,
>>=20
>> 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.
>>=20
>> Heiko
>> =20
> 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.
>=20
> Apache reopens STDERR to its log file, but STDOUT and STDIN remain =
closed.
>=20
> 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.
>=20
> Please check "Advanced Programing in the UNIX environment", chapter =
13: "Daemon processes" by W. Richard Stevens.
>=20
> Regards.
>=20
> Salvador.

--=20
Wecos <> Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5
heiko@wecos.de <> 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.
____________________________________________________________ ___


--Apple-Mail-2-411306681
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=iso-8859-1

-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">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:

class=3D"Apple-interchange-newline">
On =
02/05/2010 12:16 PM, Heiko Weber wrote:
Hi =
Andr=E9,
type=3D"cite">
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.
type=3D"cite">
type=3D"cite">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.

=

color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; =
font-style: normal; font-variant: normal; font-weight: normal; =
letter-spacing: normal; line-height: normal; orphans: 2; text-align: =
auto; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; ">
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; ">-- 
Wecos <> Heiko Weber Computer =
Systeme
D-21644 Sauensiek <> Immenweg 5
href=3D"mailto:heiko@wecos.de">heiko@wecos.de <>  href=3D"http://www.wecos.de/">http://www.wecos.de
Tel. +49 (4169) =
91000 <> Fax +49 (4169) =
919033
____________________________________________________________ ___<=
br>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.
____________________________________________________________ ___ r>



=

--Apple-Mail-2-411306681--

RE: [mp2] mod_perl closes apache"s stdin and/or stdout

am 18.02.2010 17:24:23 von eric.berg

--_000_B0011508DF5C184ABEC7A8978D7AB5E80ADADB5CA5NYKPCMMGMB0 3I_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm starting to use Gearman to get around this whole problem. We use a l=
ot of external processes for many things, so this issue wtih Apache2 real=
ly bit me hard in the bee-hind. I've gone to great lengths to work aroun=
d 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@wecos.de]
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 STDER=
R. 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 brows=
ers. 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 int=
o a database table, to schedule a background job with cron to check and c=
omplete 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 repe=
at 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/pro=
cess do something, and later (maybe when working on the next client reque=
st) STDOUT is closed. This makes it hard to create a sample program to re=
peat 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=E9,

I know what you mean, and I can't agree with you - the server response ti=
me is really low - most pages are finished loading in less 1-2 seconds, a=
nd the overall load of the server is at a low level. I believe there is a=
n issue, maybe something what Jon is talking about, I also using some "sy=
stem()" 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 v=
ery frequent, maybe 3-4 per minute.

Heiko

Of course STDOUT, STDIN, and STDERR get closed, not by mod_perl but by ap=
ache. Every UNIX process when demonized must close them to detach from i=
ts 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 ser=
ver connects them to the client socket, but in mod_perl you are in the de=
amon 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@wecos.de <> http://www.wecos.de ecos.de/>

_______________________________________________

This e-mail may contain information that is confidential, privileged or o=
therwise 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 receive=
d it in error. Unless specifically indicated, this e-mail is not an offer=
=20to buy or sell or a solicitation to buy or sell any securities, invest=
ment products or other financial product or service, an official confirma=
tion of any transaction, or an official statement of Barclays. Any views =
or opinions presented are solely those of the author and do not necessari=
ly represent those of Barclays. This e-mail is subject to terms available=
=20at the following link: www.barcap.com/emaildisclaimer. By messaging wi=
th Barclays you consent to the foregoing. Barclays Capital is the invest=
ment banking division of Barclays Bank PLC, a company registered in Engla=
nd (number 1026167) with its registered office at 1 Churchill Place, Lond=
on, E14 5HP. This email may relate to or be sent from other members of t=
he Barclays Group.
_______________________________________________

--_000_B0011508DF5C184ABEC7A8978D7AB5E80ADADB5CA5NYKPCMMGMB0 3I_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



1">

style=3D"WORD-WRAP: break-word; webkit-nbsp-mode: space; webkit-line-brea=
k: after-white-space">

Arial=20
color=3D#0000ff size=3D2>I'm starting to use Gearman to get around this w=
hole=20
problem.  We use a lot of external processes for many things, so thi=
s issue=20
wtih Apache2 really bit me hard in the bee-hind.  I've gone to great=
=20
lengths to work around it, but so far the job queue approach seems to be =
the=20
most elegant and least problematic approach.  Of course, the recomme=
ndation=20
came from the gentle folks on this list originally.

Arial=20
color=3D#0000ff size=3D2>
 

Arial=20
color=3D#0000ff size=3D2>Eric


style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px so=
lid; MARGIN-RIGHT: 0px">
=20
>
=20

=20 From: Heiko Weber [mailto:heiko@w=
ecos.de]=20
=20
Sent: Thursday, February 18, 2010 3:22 AM
To: Sa=
lvador=20
=20 Ortiz Garcia
Cc: mod_perl list
Subject: Re: [mp2]=
=20mod_perl=20
=20 closes apache's stdin and/or stdout


=20
Salvador,
=20


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

=20


=20
Well, I could replace all system() calls and just store the task=
=20jobs=20
=20 into a database table, to schedule a background job with cron to chec=
k and=20
=20 complete this tasks, but then I lost the immediately feedback to the =

=20 user/browser ... AND this is a lot of work for me -  unless I ca=
n exactly=20
=20 repeat the issue I am not sure if it is worth to try it.

=20


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

=20


=20
Heiko

=20


=20

=20
Am 16.02.2010 um 23:26 schrieb Salvador Ortiz Garcia:
=20 class=3DApple-interchange-newline>
=20

=20
On 02/05/2010 12:16 PM, Heiko Weber wrote:

=20
Hi Andr=E9,

=20


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


=20
Heiko

=20
  
Of course ST=
DOUT,=20
=20 STDIN, and STDERR get closed, not by mod_perl but by apache. Every =
UNIX=20
=20  process when demonized must close them to detach from its con=
troling=20
=20 terminal.

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

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

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

Regards.

Salvador.
>

=20
=20 style=3D"WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: n=
one; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPA=
CING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; webkit-bo=
rder-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit=
-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-=
text-stroke-width: 0px"> =20 class=3DApple-style-span=20
=20 style=3D"WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: non=
e; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACI=
NG: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; webkit-bord=
er-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-t=
ext-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-te=
xt-stroke-width: 0px">
=20 =20 style=3D"WORD-WRAP: break-word; webkit-nbsp-mode: space; webkit-line-=
break: after-white-space">
=20

=20
-- 
Wecos &l=
t;>=20
=20 Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5=

=20 href=3D"mailto:heiko@wecos.de">heiko@wecos.de <>  =20 href=3D"http://www.wecos.de/">http://www.wecos.de
V>


style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> style=3D"FONT-SIZE: 11pt"> face=3D"Times New Roman">_______________________________________________<=
?xml:namespace=20
prefix =3D o ns =3D "urn:schemas-microsoft-com:office:office"=20
/>


style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> style=3D"FONT-SIZE: 11pt"> face=3D"Times New Roman"> 


style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> style=3D"FONT-SIZE: 11pt">This e-mail may =
contain=20
information that is confidential, privileged or otherwise protected from =

disclosure. If you are not an intended recipient of this e-mail, do not=20
duplicate or redistribute it by any means. Please delete it and any attac=
hments=20
and notify the sender that you have received it in error. Unless specific=
ally=20
indicated, this e-mail is not an offer to buy or sell or a solicitation t=
o buy=20
or sell any securities, investment products or other financial product or=
=20
service, an official confirmation of any transaction, or an official stat=
ement=20
of Barclays. Any views or opinions presented are solely those of the auth=
or and=20
do not necessarily represent those of Barclays. This e-mail is subject to=
=20terms=20
available at the following link:
style=3D"FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial; mso-ansi-langu=
age: EN-GB; mso-fareast-language: EN-GB"> href=3D"http://www.barcap.com/emaildisclaimer">www.barcap.co m/emaildiscla=
imer.=20
By =
messaging=20
with Barclays you consent to the foregoing. style=3D"mso-spacerun: yes"> 
Barclays Capital is the investm=
ent=20
banking division of Barclays Bank PLC, a company registered in space=20
prefix =3D st1 ns =3D "urn:schemas-microsoft-com:office:smarttags" /> :place=20
w:st=3D"on">England<=
/st1:place>=20
(number 1026167) with its registered office at w:st=3D"on">1 Churchill Place, City=20
w:st=3D"on">London, E14=20
5HP
.&nbs=
p;=20
This email may relate to or be sent from other members of the Barc=
lays=20
Group.
AN>


style=3D"MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"> style=3D"FONT-SIZE: 11pt"> face=3D"Times New Roman">_______________________________________________<=
/FONT>




--_000_B0011508DF5C184ABEC7A8978D7AB5E80ADADB5CA5NYKPCMMGMB0 3I_--

Re: [mp2] mod_perl closes apache"s stdin and/or stdout

am 18.02.2010 21:36:25 von Heiko Weber

--Apple-Mail-14-455376385
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=iso-8859-1

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@barclayscapital.com:

> 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.
> =20
> Eric
>=20
> From: Heiko Weber [mailto:heiko@wecos.de]=20
> 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
>=20
> Salvador,
>=20
> 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.=20
>=20
> 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.
>=20
> 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.
>=20
> Heiko
>=20
> Am 16.02.2010 um 23:26 schrieb Salvador Ortiz Garcia:
>=20
>> On 02/05/2010 12:16 PM, Heiko Weber wrote:
>>> Hi Andr=E9,
>>>=20
>>> 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.
>>>=20
>>> Heiko
>>> =20
>> 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.
>>=20
>> Apache reopens STDERR to its log file, but STDOUT and STDIN remain =
closed.
>>=20
>> 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.
>>=20
>> Please check "Advanced Programing in the UNIX environment", chapter =
13: "Daemon processes" by W. Richard Stevens.
>>=20
>> Regards.
>>=20
>> Salvador.
>=20
> --=20
> Wecos <> Heiko Weber Computer Systeme
> D-21644 Sauensiek <> Immenweg 5
> heiko@wecos.de <> http://www.wecos.de
> _______________________________________________
> =20
> 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.
> _______________________________________________

--=20
Wecos <> Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg 5
heiko@wecos.de <> 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.
____________________________________________________________ ___


--Apple-Mail-14-455376385
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=iso-8859-1

-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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 href=3D"mailto:eric.berg@barclayscapital.com">eric.berg@barc layscapital.co=
m
:

type=3D"cite">
webkit-line-break: after-white-space">
face=3D"Arial" color=3D"#0000ff" size=3D"2">I'm starting to use Gearman =
to get around this whole=20
problem.  We use a lot of external processes for many things, so =
this issue=20
wtih Apache2 really bit me hard in the bee-hind.  I've gone to =
great=20
lengths to work around it, but so far the job queue approach seems to be =
the=20
most elegant and least problematic approach.  Of course, the =
recommendation=20
came from the gentle folks on this list originally.

face=3D"Arial" color=3D"#0000ff" size=3D"2"> 

face=3D"Arial" color=3D"#0000ff" size=3D"2">Eric


BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
align=3D"left">


From: Heiko Weber =
[mailto:heiko@wecos.de]=20

Sent: Thursday, February 18, 2010 3:22 AM
To: =
Salvador=20
Ortiz Garcia
Cc: mod_perl list
Subject: Re: [mp2] =
mod_perl=20
closes apache's stdin and/or stdout


Salvador,


to avoid such issues my "external" tasks don't use STDOUT, STDIN =
or=20
STDERR. They take their parameters from control files and write their =
results=20
back to a status file. This tasks don't send any output back to the =
browsers.=20
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=20
into a database table, to schedule a background job with cron to check =
and=20
complete this tasks, but then I lost the immediately feedback to the=20=

user/browser ... AND this is a lot of work for me -  unless I can =
exactly=20
repeat the issue I am not sure if it is worth to try it.



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



Heiko




Am 16.02.2010 um 23:26 schrieb Salvador Ortiz Garcia:

class=3D"Apple-interchange-newline">

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

Hi Andr=E9,



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



Heiko

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

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

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

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

Regards.

Salvador.

=

font: normal normal normal medium/normal Helvetica; text-transform: =
none; text-indent: 0px; white-space: normal; letter-spacing: normal; =
border-collapse: separate; orphans: 2; widows: 2; "> class=3D"Apple-style-span" style=3D"word-spacing: 0px; font: normal =
normal normal 12px/normal Helvetica; text-transform: none; text-indent: =
0px; white-space: normal; letter-spacing: normal; border-collapse: =
separate; orphans: 2; widows: 2; ">
webkit-line-break: after-white-space">

-- 
Wecos =
<>=20
Heiko Weber Computer Systeme
D-21644 Sauensiek <> Immenweg =
5
=
<>  href=3D"http://www.wecos.de/">http://www.wecos.de
pan>

margin-right: 0in; margin-bottom: 0pt; margin-left: 0in; "> style=3D"FONT-SIZE: 11pt"> Roman">_______________________________________________ span>
margin-bottom: 0pt; margin-left: 0in; "> 11pt"> Roman"> 
margin-right: 0in; margin-bottom: 0pt; margin-left: 0in; "> style=3D"FONT-SIZE: 11pt">This e-mail may =
contain=20
information that is confidential, privileged or otherwise protected from=20=

disclosure. If you are not an intended recipient of this e-mail, do not=20=

duplicate or redistribute it by any means. Please delete it and any =
attachments=20
and notify the sender that you have received it in error. Unless =
specifically=20
indicated, this e-mail is not an offer to buy or sell or a solicitation =
to buy=20
or sell any securities, investment products or other financial product =
or=20
service, an official confirmation of any transaction, or an official =
statement=20
of Barclays. Any views or opinions presented are solely those of the =
author and=20
do not necessarily represent those of Barclays. This e-mail is subject =
to terms=20
available at the following link:
style=3D"FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial; =
mso-ansi-language: EN-GB; mso-fareast-language: EN-GB"> href=3D"http://www.barcap.com/emaildisclaimer">www.barcap.co m/emaildisclai=
mer
.=20
By =
messaging=20
with Barclays you consent to the foregoing. yes">  Barclays Capital is the investment=20
banking division of Barclays Bank PLC, a company registered in =
w:st=3D"on">England=20
(number 1026167) with its registered office at w:st=3D"on">1 Churchill Place, =
London, E14=20=

5HP
. yes"> =20
This email may relate to or be sent from other members of the =
Barclays=20
Group. normal">

0pt; margin-left: 0in; "> style=3D"FONT-SIZE: 11pt"> Roman">_______________________________________________ >




color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; =
font-style: normal; font-variant: normal; font-weight: normal; =
letter-spacing: normal; line-height: normal; orphans: 2; text-align: =
auto; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "> style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; ">
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal =
12px/normal Helvetica; ">-- 
Wecos <> Heiko Weber Computer =
Systeme
D-21644 Sauensiek <> Immenweg 5
href=3D"mailto:heiko@wecos.de">heiko@wecos.de <>  href=3D"http://www.wecos.de/">http://www.wecos.de
Tel. +49 (4169) =
91000 <> Fax +49 (4169) =
919033
____________________________________________________________ ___<=
br>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.
____________________________________________________________ ___ r>



=

--Apple-Mail-14-455376385--