zmMemVerify attaches, so we need to zmMemInvalidate even if the shared data is no good

This commit is contained in:
Isaac Connor 2017-01-10 15:09:30 -05:00
parent a146d7bee1
commit 7ddd5359d0
1 changed files with 7 additions and 8 deletions

View File

@ -117,7 +117,7 @@ use bytes;
# ========================================================================== # ==========================================================================
use constant MAX_CONNECT_DELAY => 10; use constant MAX_CONNECT_DELAY => 10;
use constant MONITOR_RELOAD_INTERVAL => 30; use constant MONITOR_RELOAD_INTERVAL => 300;
use constant SELECT_TIMEOUT => 0.25; use constant SELECT_TIMEOUT => 0.25;
# ========================================================================== # ==========================================================================
@ -334,7 +334,7 @@ while( 1 )
] ]
); );
print( "$monitor->{Id}: S:$state, LE:$last_event\n" ); #print( "$monitor->{Id}: S:$state, LE:$last_event\n" );
#print( "$monitor->{Id}: mS:$monitor->{LastState}, mLE:$monitor->{LastEvent}\n" ); #print( "$monitor->{Id}: mS:$monitor->{LastState}, mLE:$monitor->{LastEvent}\n" );
if ( $state == STATE_ALARM if ( $state == STATE_ALARM
|| $state == STATE_ALERT || $state == STATE_ALERT
@ -429,10 +429,8 @@ while( 1 )
# If necessary reload monitors # If necessary reload monitors
if ( $needsReload || ((time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL )) if ( $needsReload || ((time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL ))
{ {
print "TIme to reload Monitors " . join(',',keys %monitors ). "\n";
foreach my $monitor ( values(%monitors) ) foreach my $monitor ( values(%monitors) )
{ {
print "imvalidating $$monitor{Id}\n";
# Free up any used memory handle # Free up any used memory handle
zmMemInvalidate( $monitor ); zmMemInvalidate( $monitor );
} }
@ -460,10 +458,11 @@ sub loadMonitors
or Fatal( "Can't execute: ".$sth->errstr() ); or Fatal( "Can't execute: ".$sth->errstr() );
while( my $monitor = $sth->fetchrow_hashref() ) while( my $monitor = $sth->fetchrow_hashref() )
{ {
next # Check shared memory ok
if ( !zmMemVerify( $monitor ) ) { if ( !zmMemVerify( $monitor ) ) {
; # Check shared memory ok zmMemInvalidate( $monitor );
} next;
}
if ( defined($monitors{$monitor->{Id}}->{LastState}) ) if ( defined($monitors{$monitor->{Id}}->{LastState}) )
{ {