Re: [Mason] Re: Well, I'm dumb...

2000-01-19 Thread Jonathan Swartz

Alex -- you've definitely cut it down a lot, but have you tried cutting out 
the Mason stuff and just making it a regular mod_perl handler that prints a 
few lines?  I'm fairly sure the problem is independent of Mason (although it 
may be related to the structure of handler.pl). Try it and see if you can 
still reproduce the problem. Every minimization step helps towards
pinpointing the bug.
Jon

At 12:00 PM 1/19/00 +0300, [EMAIL PROTECTED] wrote:

I've cut down handler.pl to bare minimum.

=== 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 Socket;
use Carp qw(cluck confess);

package HTML::Mason;
use HTML::Mason;
use strict;
{
  package HTML::Mason::Commands;
  use Apache::Registry;
  use Apache::Status;
}

my $parser = new HTML::Mason::Parser
  (
#   allow_globals = [qw($dbh)]
  );
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", "",
#   { RaiseError = 1, PrintError = 1, 
# AutoCommit = 1, }
#));
my $ah = new HTML::Mason::ApacheHandler (interp=$interp,
output_mode='batch');
chown ( 60001, 60001, $interp-files_written );
use Apache::Cookie;
use Apache::Session::File;
sub handler {
  my ($r) = @_;
  return -1 
if defined($r-content_type)  $r-content_type !~ m|^text/|io;
  my $cook = Apache::Cookie-new($r);
  my $cookie = $cook-get('SESSION_ID');
  my %session;
  tie %session, 'Apache::Session::File', $cookie; 
  $cook-set(-name = "SESSION_ID", -value = $session{_session_id}) 
  if ( !$cookie );
  
  my $res = $ah-handle_request($r);
  untie %session;
  return $res;
}

1;
...





Well, I'm dumb...

2000-01-18 Thread tarkhil


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 

Re: Well, I'm dumb...

2000-01-18 Thread Jeffrey W. Baker

[EMAIL PROTECTED] wrote:
 
 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.

Alexander,

You continue to post, now resorting to all capital letters, but you
still haven't answered the questions I asked of your original post.  At
least, if you have, I never saw them.

If you claim that you don't know much about Perl, why are you messing
around with changing the scope of a global glob (local
*HTML::Mason::blah)?  With all these globals, why would the session hash
ever get released?  Remember that globals never go away in mod_perl
unless you explicitly undefine them.

I honestly don't have the time to try to reproduce your problem, because
your code is doing some rather complex things.  Have you been able to
get something simpler working?

-jwb