Subject: | mod_perl - Pipe-Error |
In mod_perl under Apache2, when you doesn't define a reciepient, a DBI-
connection would be closed (maybe any connection to DB?).
Put the attached mod_perl Handler into an Apache2, and you will get a
"closed connection" for the first request. Restart the Apache to repeat
it.
This seems to be a bug in mod_perl. I report it here only for sake of
completeness.
----------------
PERL: 5.8.5
APACHE: 2.0.55
MOD_PERL: 2.0.2
OS: FreeBSD 5.3-RELEASE-p5 i386
Subject: | MyApache2Handler.pm |
package MyApache2Handler;
use strict;
use warnings;
use DBI();
use CGI();
sub _q {
my ($class, $db, $q) = @_;
my $sth = $db->prepare("SELECT $q");
if(!$sth->execute()) {
die $@ . ' ' . $db->errstr();
}
return $sth->fetchrow_array();
}
sub handler {
my $db = DBI->connect("DBI:mysql:database=database_name;host=my.host", 'username', 'pwd');
my $cgi = new CGI();
print $cgi->header(-type => 'text/html');
eval {
print "Q1: " . __PACKAGE__->_q($db, 1);
local *SENDMAIL;
open(SENDMAIL, "|/usr/lib/sendmail -t -oi -oem");
print "Opened!";
my $to_line = '';# Turn it on, to resolve the bug: "\nTo: whatever@net.net";
print SENDMAIL "Content-Disposition: inline
Content-Length: 14
Content-Transfer-Encoding: binary
Content-Type: text/plain
MIME-Version: 1.0
X-Mailer: MIME::Lite 3.01 (F2.73; T1.17; A1.62; B3.01; Q3.01)
Date: Fri, 16 Nov 2007 10:47:57 UT
Subject: MySubject
From: Me$to_line
The Pipe-Test.";
print "Print!";
#>> Here's the Problem:
close(SENDMAIL);
#<<
print "Q2: " . __PACKAGE__->_q($db, 2);
};
print "<h1>Error</h1>$@";
return '';
}
1;