hang with mysql in execute
From: Chris Masters (rotis23_at_yahoo.com)
Date: 03/19/05
- Previous message: Michael A Chase tech: "Re: Oracle client and DBD::Oracle"
- Next in thread: Chris Masters: "Re: hang with mysql in execute"
- Maybe reply: Tony Adolph: "Re: hang with mysql in execute"
- Maybe reply: Jones Robert Civ TTMS Keesler: "RE: hang with mysql in execute"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 19 Mar 2005 09:37:05 -0800 (PST) To: dbi-users@perl.org
Hi All,
A firewall is terminating my connection with a mysql
database after a period of inactivity. I've used the
following code (with ref to cpan docs and connect) and
it still causes a hang.
###################################################
my $result = 0;
my $alarm = 0;
eval
{
#set alarm to timeout query hangs
my $h = Sys::SigAction::set_sig_handler( 'ALRM'
,sub { $alarm = 1; } );
alarm(2);
my $sth = $dbh->prepare("SELECT 1");
$sth->execute();
$result = 1;
alarm(0);
};
alarm(0);
if($@ || $alarm)
{
syslog('err',"execute error: $@");
$result = 0;
}
return $result;
###############################################
Am I using alarms wrongly with perl?
Would it be better to use a select(2) wrapper?
Any other ideas to prevent this hang?
Thanks for any help on this.
Chris
redhat 8.0
perl-5.8.0-88.3
perl-DBI-1.30-1
perl-DBD-MySQL-2.1017-3
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
- Previous message: Michael A Chase tech: "Re: Oracle client and DBD::Oracle"
- Next in thread: Chris Masters: "Re: hang with mysql in execute"
- Maybe reply: Tony Adolph: "Re: hang with mysql in execute"
- Maybe reply: Jones Robert Civ TTMS Keesler: "RE: hang with mysql in execute"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|