The I'm using the following code to attempt to open a file handle to an oracle database and to handle a failure of the attempt in a somewhat graceful manner:
BEGIN { my $need= '/local/src/local.perl/oracle/instantclient_10_2'; my $ld= $ENV{LD_LIBRARY_PATH}; if( ! $ld ) { $ENV{LD_LIBRARY_PATH}= $need; } elsif( $ld !~ m#(^|:)\Q$need\E(:|$)# ) { $ENV{LD_LIBRARY_PATH} .= ':' . $need; } else { $need= ""; } if( $need ) { exec 'env', $^X, $0, @ARGV; } } use DBI; use DBD::Oracle; use Sys::SigAction qw( set_sig_handler ); my $dbh; my $host = "some.where.else"; my $sid = "FAKE"; my $user = 'faker'; my $passwd = 'evenmorefaker'; my $thissrv = `hostname`; $start = time; $elapsed = time; while (1) { last if( ($elapsed - $start) > 14400 ); # stop after 4hrs of tryin +g sleep(2); eval { my $h = set_sig_handler( 'ALRM' ,sub { die "connect failed" ;} + ); alarm(2); #implement 2 second time out $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $ +passwd); alarm(0); }; #original signal handler restored here when $h goes out of scop +e alarm(0); if ( $@ ) { # The attempt to connect to db has failed chomp($@); # just for debugging print "FAILED:$@:$elapsed\n"; $elapsed = time; next; } # # reaching here shows database is now accessable # $elapsed = time; last; # exit the polling loop } #just for debuging print "Pretending to bring services up"
Now the code works ok but when it finishes its run it spits out:
root@somewhere# ./test.pl Pretending to bring services up Out of memory! Callback called exit. END failed--call queue aborted. root@somewhere #
The problem seems to stem from using Sys::SigAction. Any suggestions about why I'm getting 'Out of memory!' errors?
dhj...In reply to "Out of memory!" and Sys::SigAction by dhj74
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |