Merge branch 'fix_mmap_leak' into work

This commit is contained in:
Isaac Connor 2017-01-10 14:22:58 -05:00
commit 4d84387807
1 changed files with 16 additions and 1 deletions

View File

@ -198,6 +198,7 @@ my %spawned_connections;
my %monitors; my %monitors;
my $monitor_reload_time = 0; my $monitor_reload_time = 0;
my $needsReload = 0;
$! = undef; $! = undef;
my $rin = ''; my $rin = '';
@ -313,6 +314,19 @@ while( 1 )
my @out_messages; my @out_messages;
foreach my $monitor ( values(%monitors) ) foreach my $monitor ( values(%monitors) )
{ {
my $memVerified = 1;
if ( !zmMemRead($monitor, "shared_data:valid") ) {
# Shared data is invalid, attempt to reconnect
zmMemInvalidate($monitor);
$memVerified = zmMemVerify($monitor);
}
if ( ! $memVerified ) {
# Our attempt to verify the memory handle failed. We should reload the monitors.
$needsReload = 1;
next;
}
my ( $state, $last_event ) my ( $state, $last_event )
= zmMemRead( $monitor, = zmMemRead( $monitor,
[ "shared_data:state", [ "shared_data:state",
@ -413,7 +427,7 @@ while( 1 )
} }
# If necessary reload monitors # If necessary reload monitors
if ( (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"; print "TIme to reload Monitors " . join(',',keys %monitors ). "\n";
foreach my $monitor ( values(%monitors) ) foreach my $monitor ( values(%monitors) )
@ -423,6 +437,7 @@ print "imvalidating $$monitor{Id}\n";
zmMemInvalidate( $monitor ); zmMemInvalidate( $monitor );
} }
loadMonitors(); loadMonitors();
$needsReload = 0;
} }
} }
Info( "Trigger daemon exiting\n" ); Info( "Trigger daemon exiting\n" );