-Report error on DB problems in chnode
-Fix UDP listening select semantics to allow clean exit again -Alter lifespan of sitetab object in xcatd to avoid attempting to persist across forks (needed for PostgreSQL) -Allow for possible quotation marks in DBI return data that happen in certain interactions with PostgreSQL -Cleanup a few unfinished statements and unclosed tables, which might have adversely impacted DBI behavior git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@302 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
8836fd275d
commit
c8c7d356f0
@ -258,7 +258,7 @@ sub new
|
||||
my $tbexistq = $self->{dbh}->table_info('','',$self->{tabname},'TABLE');
|
||||
my $found = 0;
|
||||
while (my $data = $tbexistq->fetchrow_hashref) {
|
||||
if ($data->{'TABLE_NAME'} eq $self->{tabname}) {
|
||||
if ($data->{'TABLE_NAME'} =~ /^\"?$self->{tabname}\"?\z/) {
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
@ -697,6 +697,7 @@ sub setAttribs
|
||||
{
|
||||
return (undef, $sth->errstr);
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -728,6 +729,7 @@ sub setAttribs
|
||||
{
|
||||
return (undef, $sth->errstr);
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
#notify the interested parties
|
||||
@ -840,6 +842,7 @@ sub setAttribsWhere
|
||||
xCAT::NotifHandler->notify($action, $self->{tabname},
|
||||
\@notif_data, \%new_notif_data);
|
||||
}
|
||||
$sth->finish;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1142,7 +1145,7 @@ sub getAllAttribsWhere
|
||||
. $self->{tabname}
|
||||
. ' WHERE ('
|
||||
. $whereclause
|
||||
. ") and (disable is NULL or disable in ('0','no','NO','no'))");
|
||||
. ") and (\"disable\" is NULL or \"disable\" in ('0','no','NO','no'))");
|
||||
$query->execute();
|
||||
while (my $data = $query->fetchrow_hashref())
|
||||
{
|
||||
@ -1199,7 +1202,7 @@ sub getAllNodeAttribs
|
||||
my $query =
|
||||
$self->{dbh}->prepare('SELECT node FROM '
|
||||
. $self->{tabname}
|
||||
. " WHERE disable is NULL or disable in ('','0','no','NO','no')");
|
||||
. " WHERE \"disable\" is NULL or \"disable\" in ('','0','no','NO','no')");
|
||||
$query->execute();
|
||||
while (my $data = $query->fetchrow_hashref())
|
||||
{
|
||||
@ -1275,7 +1278,7 @@ sub getAllAttribs
|
||||
my $query =
|
||||
$self->{dbh}->prepare('SELECT * FROM '
|
||||
. $self->{tabname}
|
||||
. " WHERE disable is NULL or disable in ('','0','no','NO','no')");
|
||||
. " WHERE \"disable\" is NULL or \"disable\" in ('','0','no','NO','no')");
|
||||
$query->execute();
|
||||
while (my $data = $query->fetchrow_hashref())
|
||||
{
|
||||
@ -1434,7 +1437,7 @@ sub getAttribs
|
||||
|
||||
if ($keypairs{$_})
|
||||
{
|
||||
$statement .= $_ . " = ? and ";
|
||||
$statement .= "\"".$_ . "\" = ? and ";
|
||||
if (ref($keypairs{$_}))
|
||||
{ #correct for XML process mangling if occurred
|
||||
push @exeargs, $keypairs{$_}->[0];
|
||||
@ -1449,7 +1452,7 @@ sub getAttribs
|
||||
$statement .= "$_ is NULL and ";
|
||||
}
|
||||
}
|
||||
$statement .= "(disable is NULL or disable in ('0','no','NO','No','nO'))";
|
||||
$statement .= "(\"disable\" is NULL or \"disable\" in ('0','no','NO','No','nO'))";
|
||||
my $query = $self->{dbh}->prepare($statement);
|
||||
$query->execute(@exeargs);
|
||||
my $data;
|
||||
@ -1625,7 +1628,7 @@ sub open
|
||||
sub DESTROY
|
||||
{
|
||||
my $self = shift;
|
||||
if ($self->{dbh}) { $self->{dbh}->disconnect(); }
|
||||
if ($self->{dbh}) { $self->{dbh}->disconnect(); undef $self->{dbh};}
|
||||
undef $self->{nodelist}; #Could be circular
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,6 @@ sub chnode {
|
||||
my $args=shift;
|
||||
my $callback=shift;
|
||||
my $addmode=shift;
|
||||
print $addmode;
|
||||
if ($addmode) {
|
||||
my $idx=0;
|
||||
foreach my $arg (@$args) {
|
||||
@ -438,7 +437,11 @@ sub chnode {
|
||||
}
|
||||
}
|
||||
if (keys %uhsh) {
|
||||
$tabhdl->setNodeAttribs($node,\%uhsh);
|
||||
|
||||
my @rc = $tabhdl->setNodeAttribs($node,\%uhsh);
|
||||
if (not defined($rc[0])) {
|
||||
$callback->({error=>"DB error ".$rc[1]});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ my $plugins_dir=$::XCATROOT.'/lib/perl/xCAT_plugin';
|
||||
($tmp) = $sitetab->getAttribs({'key'=>'xcatconfdir'},'value');
|
||||
$xcatdir = (($tmp and $tmp->{value}) ? $tmp->{value} : "/etc/xcat");
|
||||
|
||||
$sitetab->close;
|
||||
my $progname;
|
||||
$SIG{PIPE} = sub { die "SIGPIPE $$progname encountered a broken pipe (probably Ctrl-C by client)" };
|
||||
sub daemonize {
|
||||
@ -242,7 +243,7 @@ if (xCAT::Utils->isLinux()) {
|
||||
until ($quit) {
|
||||
eval {
|
||||
while (1) {
|
||||
until ($select->can_read(5)) {} #Wait for data
|
||||
until ($select->can_read(5)) {if ($quit) { last; }} #Wait for data
|
||||
while ($select->can_read(0)) { #Pull all buffer data that can be pulled
|
||||
$part = $socket->recv($data,1500);
|
||||
($sport,$client) = sockaddr_in($part);
|
||||
@ -380,10 +381,12 @@ until ($quit) {
|
||||
} else {
|
||||
$peername=undef;
|
||||
}
|
||||
$sitetab=xCAT::Table->new('site');
|
||||
my ($tmp) = $sitetab->getAttribs({'key'=>'domain'},'value');
|
||||
if (defined $tmp->{value}) {
|
||||
$domain = $tmp->{value};
|
||||
}
|
||||
$sitetab->close;
|
||||
|
||||
if (xCAT::Utils->isLinux()) {
|
||||
$peerhost = gethostbyaddr($connection->peeraddr,AF_INET6);
|
||||
@ -487,6 +490,7 @@ sub plugin_command {
|
||||
}
|
||||
}
|
||||
}
|
||||
$hdlrtable->close;
|
||||
} else {
|
||||
unless (@nodes) {
|
||||
$handler_hash{$hdlspec} = 1;
|
||||
@ -762,6 +766,7 @@ sub validate {
|
||||
return 0;
|
||||
}
|
||||
my @policies = $policytable->getTable;
|
||||
$policytable->close;
|
||||
my $rule;
|
||||
foreach $rule (@policies) {
|
||||
if ($rule->{name} and $rule->{name} ne '*') {
|
||||
|
Loading…
Reference in New Issue
Block a user