From 712cb4fb4d7e6aaa00fa900c875141bb97ab455c Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 30 Sep 2009 17:42:21 +0000 Subject: [PATCH] -In the event of a bug caught by the DB worker, propogate it up to the client rather than having the client mysteriously hang git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4267 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 9c6200d97..453e174f9 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -89,9 +89,16 @@ sub dbc_submit { print $clisock $data; $data=""; my $lastline=""; - while ($lastline ne "ENDOFFREEZEQFVyo4Cj6Q0j\n") { #index($lastline,"ENDOFFREEZEQFVyo4Cj6Q0j") < 0) { + while ($lastline ne "ENDOFFREEZEQFVyo4Cj6Q0j\n" and $lastline ne "*XCATBUGDETECTED*76e9b54341\n") { #index($lastline,"ENDOFFREEZEQFVyo4Cj6Q0j") < 0) { $lastline = <$clisock>; - $data .= $lastline; + $data .= $lastline; + } + if ($lastline eq "*XCATBUGDETECTED*76e9b54341\n") { #if it was an error + #in the midst of the operation, die like it used to die + my $err; + $data =~ /\*XCATBUGDETECTED\*:(.*):\*XCATBUGDETECTED\*/s; + $err = $1; + die $err; } my @returndata = @{thaw($data)}; if (wantarray) { @@ -143,12 +150,25 @@ sub init_dbworker { $clientset->add($dbconn); } } else { - handle_dbc_conn($currcon,$clientset); + eval { + handle_dbc_conn($currcon,$clientset); + }; + if ($@) { + my $err=$@; + xCAT::MsgUtils->message("S","xcatd: possible BUG encountered by xCAT DB worker ".$err); + if ($currcon) { + eval { #avoid hang by allowin client to die too + print $currcon "*XCATBUGDETECTED*:$err:*XCATBUGDETECTED*\n"; + print $currcon "*XCATBUGDETECTED*76e9b54341\n"; + }; + } + } } } }; - if ($@) { - xCAT::MsgUtils->message("S","xcatd: possible BUG encountered by xCAT DB worker ".$@); + if ($@) { #this should never be reached, but leave it intact just in case + my $err=$@; + xCAT::MsgUtils->message("S","xcatd: possible BUG encountered by xCAT DB worker ".$err); } } close($dbworkersocket);