|
|
sybperl-l Archive
Up Prev Next
From: "Lenga, Yair " <yair dot lenga at citi dot com>
Subject: RE: Automatically managing inactiveDestroy property.
Date: Apr 10 2008 2:02PM
Michael,
Thanks for taking the time to look into this. Attached is a mini-version
of one of my programs - hopefully, it will demonstrate the problem.
The code make an RPC call, capture the output (using a child process),
and then record the result in the database.
I've found that without the inactiveDestory, the child 'exit' will
invalidate the DBH connection to Sybase.
Many Thanks
Yair
sub host_check {
my ($dbh, $account, $hostid, $target, $cmd) = @_ ;
warn "Trying $hostid ($target)\n" ;
my($remote) = new IO::Socket::INET(PeerAddr => $target, Timeout =>
15) ;
if ( !$remote ) {
my $code = 0+$! ;
my $desc = $! ;
warn "Network Error: $account on $hostid ($target): $!
($code)\n" ;
print "M - Failed to launch on $hostid\n" ;
my $retry =
$code == ECONNREFUSED ? 5*60 : # Machine refuse connection
10*60 ;
record_host_error($dbh, $hostid, $retry, "E" . 0+$! . "/" . $!)
;
print "M - Host $hostid Network Error: $code ($desc), retry in
$retry\n" ;
next ;
} ;
warn "Connected to $hostid '$target'\n" ;
my $child = new IO::Handle ;
my $pid = open($child, "-|") ;
die "Error forking helper: $!" unless defined($pid) ;
unless ( $pid ) {
# Child Helper
$dbh->{InactiveDestroy} = 1 ;
alarm(15) ;
print $remote $cmd ;
if ( <$remote> ) {
print $_ ;
alarm(60) ;
print while ( <$remote> ) ;
} ;
exit ;
} ;
# Parent Here
close $remote ;
my $run_stat = 'NA' ;
my $line_count = 0 ;
while ( <$child> ) {
chomp ;
if ( m{^//X\s+(\d+)$} ) {
$run_stat = $1 ;
} else {
warn "$_" ;
} ;
$line_count++ ;
} ;
close $child ;
# Check the return code (6/7/8/9 indicate OK )
if ( $run_stat >= 5 && $run_stat <= 9 ) {
warn "Launch OK: Feedback: $line_count lines,
status=$run_stat\n" ;
$dbh->do(...) # Record Error in DB
record_launch_ok($dbh, $hostid, $account) ;
print "M - Host $hostid PASS\n" ;
return 1 ;
# High error code indicate problem with license - no retry!
-----Original Message-----
From: owner-sybperl-l@peppler.org [mailto:owner-sybperl-l@peppler.org]
On Behalf Of michael.x.peppler@jpmchase.com
Sent: Thursday, April 10, 2008 9:18 AM
To: sybperl-l@peppler.org
Subject: Re: Automatically managing inactiveDestroy property.
Quick response (I'll respond more completely from home tonight):
DBD::Sybase should support accessing the db handle from both the parent
and the child as that's supported by OpenClient (although I haven't
tried it with DBD::Sybase - I *have* done it with Sybase::CTlib).
Anyway - the PID idea seems reasonable at first glance, but I need to
think about it a bit to see if there might be any downsides...
Michael
"Lenga, Yair "
Sent by: owner-sybperl-l@peppler.org
10.04.2008 14:38
To
cc
Subject
Automatically managing inactiveDestroy property.
|