Okay. I'm poor programmer. I'm dumb. OKAY, I'M AN IDIOT. I agree.
But now, PLEASE, point me WHY Apache::Session does NEVER get destroyed
it the sample handler.
Have I told you that I'm poor programmer, don't know Perl at all and
overall dumb and cannot even type?
JUST POINT ME TO MY ERROR!
PLEASE NO clever ideas of reread of mail archive, for over an hour I'm
trying to get my error.
=== cut handler.pl ===
#!/usr/bin/perl
# $Id: handler.pl,v 1.3 2000/01/14 19:42:16 tarkhil Exp $
#
$ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/
or die "GATEWAY_INTERFACE not Perl!";
use Apache::Registry;
use Apache::Status;
use DBI;
use Socket;
use Carp qw(cluck confess);
use Apache::DBI ();
package HTML::Mason;
use HTML::Mason;
use strict;
{
package HTML::Mason::Commands;
use Apache::Registry;
use Apache::Status;
use DBI;
use Apache::DBI ();
use Apache::Session::DBI;
use Net::SNPP;
use Apache::AuthDBI;
use MIME::Head;
use Mail::Send;
use Mail::Mailer;
use Mail::Header;
use Image::Size 'html_imgsize';
use HTTP::Status;
use Net::POP3;
#use Apache::SizeLimit;
#$Apache::SizeLimit::MAX_PROCESS_SIZE = 1; # 1kB = 10MB
Apache::DBI-connect_on_init
("DBI:mysql:mail2pager",
"tarkhil", "cypurcad",
{ RaiseError = 1, PrintError = 1, AutoCommit = 1, }
);
}
my $parser = new HTML::Mason::Parser
(
allow_globals = [qw($dbh %session %pagers %mailserv @mssort)]
);
my $interp = new HTML::Mason::Interp
(parser=$parser,
data_dir = "/usr/local/www/tmp",
comp_root = "/usr/local/www");
$interp-set_global(dbh=DBI-connect
("DBI:mysql:mail2pager",
"tarkhil", "cypurcad",
{ RaiseError = 1, PrintError = 1,
AutoCommit = 1, }
));
$interp-set_global('%pagers'=
(
0 = "÷ÙÂÅÒÉÔÅ ÏÐÅÒÁÔÏÒÁ",
1 = "íÏÂÉÌ ôÅÌÅËÏÍ",
2 = "áÓÔÒÁÐÅÊÄÖ",
3 = "òÁÄÉÏÓËÁÎ",
4 = "ëÏÎÔÉÎÅÎÔÁÌØ",
5 = "÷ÅÓÓÏÌÉÎË",
6 = "òÁÄÉÏÐÅÊÄÖ",
7 = "÷ÅÓÓÏÔÅÌ",
8 = "íÕÌØÔÉ-ðÅÊÄÖ",
9 = "éÎÆÏÒÍ-üËÓËÏÍ",
10 = "áÌØÆÁËÏÍ",
1000 = "Mail2Phone Free (íôó)",
1001 = "íôó/BeeLine",
101 = "óôó-ðÅÊÄÖ",
102 = "÷ÅÓÓÏÌÉÎË (ðÓËÏ×)",
103 = "ëÁÌÕÖÓËÁÑ ÓÏÔÏ×ÁÑ",
104 = "áÌËÏÍ üÌÅËÔÒÏÎÉËÓ (HÏ×ÏËÕÚÎÅÃË)",
105 = "áÌËÏÍ üÌÅËÔÒÏÎÉËÓ (ëÅÍÅÒÏ×Ï)",
106 = "üËÓËÏÍ ðÅÔÅÒÂÕÒÇ",
107 = "íÔÅÌÅËÏÍ óÐÂ.",
11 = "òÏÚÁ íÉÒÁ",
12 = "÷ó ôÅÌÅËÏÍ",
13 = 'üëóðòåóó (óÐÂ)',
200 = 'óÅÒËÏÍ (èÁÂÁÒÏ×ÓË)',
));
$interp-set_global('%mailserv'=
(
'pop.mail.ru' = 'MAIL.RU',
'chat.ru' = 'CHAT.RU',
'mail.express.ru' = 'EXPRESS.RU',
'other' = '(ÄÒÕÇÏÍ)',
));
$interp-set_global('@mssort'=
(
'other', 'chat.ru', 'mail.express.ru', 'pop.mail.ru'
));
my $ah = new HTML::Mason::ApacheHandler (interp=$interp,
output_mode='batch');
chown ( 60001, 60001, $interp-files_written );
use Apache::Cookie;
sub handler {
my ($r) = @_;
# Handle only what we understand
return -1 if $r-method !~ /^(GET|POST|HEAD)$/;
return -1
if defined($r-content_type) $r-content_type !~ m|^text/|io;
my ($port, $addr) = Socket::sockaddr_in($r-connection-local_addr);
# WebDAV will do everything on itself
return -1 if $port == 8000;
local $SIG{ALRM} = sub {Carp::confess "Alarm ";};
alarm 20;
my $cook = Apache::Cookie-new($r);
my $cookie = $cook-get('SESSION_ID');
# Unless exists session_id, clean it!
my $dbh = DBI-connect
("DBI:mysql:mail2pager",
"tarkhil", "cypurcad",
{ RaiseError = 1, PrintError = 1,
AutoCommit = 1, }
);
my $sth = $dbh-prepare_cached(q{
select id from sessions
where id = ?
});
$sth-execute($cookie);
my $rses;
$rses = $sth-fetchall_arrayref();
if (scalar @$rses == 0) {
$cookie = undef;
}
my %session;
tie %session, 'Apache::Session::DBI', $cookie,
{ DataSource = 'dbi:mysql:mail2pager', UserName = 'tarkhil',
Password = 'cypurcad'};
# warn "\[$$\] Tied session $session{_session_id}\n";
$cook-set(-name = "SESSION_ID", -value = $session{_session_id})
if ( !$cookie );
local *HTML::Mason::Command::session = \%session;
my $res = $ah-handle_request($r);
# warn "\[$$\] Going to untie session $session{_session_id}\n";
alarm 2;
untie %session;
# warn "\[$$\] Session untied\n";
alarm 0;
return $res;
}
1;
=== cut handler.pl ===
=== from httpd.conf ===
PerlRequire