develooper Front page | perl.dbi.users | Postings from December 2008

Re: Protecting a mod perl 1.3 site from slow MySql processes

Thread Previous | Thread Next
From:
April Papajohn
Date:
December 2, 2008 13:30
Subject:
Re: Protecting a mod perl 1.3 site from slow MySql processes
On Tue, Dec 2, 2008 at 2:19 PM, Hendrik Schumacher <hs@activeframe.de> wrote:
> alarm() definitely works in mod_perl.

Then I wonder why my test code is successfully interrupting the
DBI->connect method from the command line, but not when running in
modperl 1.3  (the versions of perl are the same).

sub handler {

   ...


    eval {


	my $h = set_sig_handler('ALRM',sub {die "DBD took longer than
$MYSQL_ALARM_LIMIT seconds to do its MySQL work\n"});

       	alarm($MYSQL_ALARM_LIMIT);
	
	my $dbh = DBI->connect($datasource,'','', {PrintError => 0});
	
	if (!$dbh) {
	    warn $DBI::errstr;
	} else {
	
	    my $data = rand();
	
	
	    my $sh2 = $dbh->prepare("select * from test where data = $data ");
	
	    $sh2->execute;
		
	    my @result = $sh2->fetchrow_array;

	    warn "Result fetched: @result\n";

	
	}
	
    };
    alarm(0);

...

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About