fixed a problem for notification

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5648 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2010-04-01 20:02:08 +00:00
parent 4d00cf0656
commit 2b1673a9d0
3 changed files with 20 additions and 3 deletions

View File

@ -8,8 +8,8 @@ BEGIN
use lib "$::XCATROOT/lib/perl";
use File::Basename qw(fileparse);
require xCAT::Utils;
require Data::Dumper;
use xCAT::Utils;
use Data::Dumper;
#%notif is a cache that holds the info from the "notification" table.
#the format of it is:
@ -20,6 +20,7 @@ require Data::Dumper;
# }
my %notif;
my $masterpid;
my $dbworkerid;
1;
@ -40,6 +41,7 @@ my $masterpid;
table and store it into %notif variable.
Arguments:
pid -- the process id of the caller.
pid1 -- the process id of the dbworker.
Returns:
none
=cut
@ -50,6 +52,8 @@ sub setup
if ($masterpid =~ /xCAT::NotifHandler/) {
$masterpid=shift;
}
$dbworkerid=shift;
refreshNotification();
$SIG{USR1}=\&handleNotifSignal;
@ -66,6 +70,7 @@ sub setup
=cut
#-------------------------------------------------------------------------------
sub handleNotifSignal {
#print "handleNotifSignal pid=$$\n";
refreshNotification();
$SIG{USR1}=\&handleNotifSignal;
}
@ -83,6 +88,9 @@ sub sendNotifSignal {
if ($masterpid) {
kill('USR1', $masterpid);
}
if ($dbworkerid) {
kill('USR1', $dbworkerid);
}
}
@ -100,6 +108,7 @@ sub sendNotifSignal {
#-------------------------------------------------------------------------------
sub refreshNotification
{
#print "refreshNotification get called\n";
#flush the cache
%notif=();
my $table=xCAT::Table->new("notification", -create =>0);
@ -161,6 +170,7 @@ sub refreshNotification
}#end if (@row_array)
} #end if ($table)
#print Dumper(%notif);
return 1;
}
@ -213,6 +223,9 @@ sub dumpNotificationCache {
=cut
#-------------------------------------------------------------------------------
sub needToNotify {
#print "needToNotify pid=$$, notify=" . Dumper(%notif) . "\n";
if (!%notif) {
# print "notif not defined\n";
refreshNotification();

View File

@ -172,6 +172,10 @@ sub init_dbworker {
my $currcon;
my $clientset = new IO::Select;
$clientset->add($dbworkersocket);
#setup signal in NotifHandler so that the cache can be updated
xCAT::NotifHandler::setup($$, 0);
while (not $exitdbthread) {
eval {
my @ready_socks = $clientset->can_read;

View File

@ -599,7 +599,7 @@ unless ($listener) {
closelog();
#setup signal in NotifHandler so that the cache can be updated
xCAT::NotifHandler::setup($$);
xCAT::NotifHandler::setup($$, $dbmaster);
#start the monitoring process
xCAT_monitoring::monitorctrl::start($$);