diff --git a/perl-xCAT/xCAT/NotifHandler.pm b/perl-xCAT/xCAT/NotifHandler.pm index 9a2208b1b..c23db6325 100644 --- a/perl-xCAT/xCAT/NotifHandler.pm +++ b/perl-xCAT/xCAT/NotifHandler.pm @@ -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(); diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index a8d577b3d..e957aa476 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -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; diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index fe5f0a97c..e86726834 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -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($$);