spacing, remove dead code. If Monitor Function becomes None, skip it

This commit is contained in:
Isaac Connor 2021-12-10 15:36:47 -05:00
parent aa320cb28f
commit ed360348ef
1 changed files with 12 additions and 18 deletions

View File

@ -166,13 +166,9 @@ while (!$zm_terminate) {
foreach my $connection ( values(%spawned_connections) ) { foreach my $connection ( values(%spawned_connections) ) {
if ( vec($rout, $connection->fileno(), 1) ) { if ( vec($rout, $connection->fileno(), 1) ) {
Debug('Got input from spawned connection ' Debug('Got input from spawned connection '
.$connection->name() .$connection->name().' ('.$connection->fileno().')');
.' ('
.$connection->fileno()
.')'
);
my $messages = $connection->getMessages(); my $messages = $connection->getMessages();
if ( defined($messages) ) { if (defined($messages)) {
foreach my $message ( @$messages ) { foreach my $message ( @$messages ) {
handleMessage($connection, $message); handleMessage($connection, $message);
} }
@ -199,34 +195,32 @@ while (!$zm_terminate) {
# Check polled connections # Check polled connections
foreach my $connection ( @in_poll_connections ) { foreach my $connection ( @in_poll_connections ) {
my $messages = $connection->getMessages(); my $messages = $connection->getMessages();
if ( defined($messages) ) { if (defined($messages)) {
foreach my $message ( @$messages ) { foreach my $message (@$messages) handleMessage($connection, $message);
handleMessage($connection, $message);
}
} }
} }
# Check for alarms that might have happened # Check for alarms that might have happened
my @out_messages; my @out_messages;
foreach my $monitor ( values %monitors ) { foreach my $monitor ( values %monitors ) {
if ($$monitor{Function} eq 'None') {
$monitor_reload_time = 0;
next;
}
if ( ! zmMemVerify($monitor) ) { if (!zmMemVerify($monitor)) {
# Our attempt to verify the memory handle failed. We should reload the monitors. # Our attempt to verify the memory handle failed. We should reload the monitors.
# Don't need to zmMemInvalidate because the monitor reload will do it. # Don't need to zmMemInvalidate because the monitor reload will do it.
push @needsReload, $monitor; push @needsReload, $monitor;
next; next;
} }
my ( $state, $last_event ) = zmMemRead( $monitor, my ($state, $last_event) = zmMemRead($monitor, [
[
'shared_data:state', 'shared_data:state',
'shared_data:last_event' 'shared_data:last_event'
] ]);
);
#print( "$monitor->{Id}: S:$state, LE:$last_event" ); if ($state == STATE_ALARM or $state == STATE_ALERT) {
#print( "$monitor->{Id}: mS:$monitor->{LastState}, mLE:$monitor->{LastEvent}" );
if ( $state == STATE_ALARM or $state == STATE_ALERT ) {
# In alarm state # In alarm state
if ( !defined($monitor->{LastEvent}) if ( !defined($monitor->{LastEvent})
or ($last_event != $monitor->{LastEvent}) or ($last_event != $monitor->{LastEvent})