2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-28 11:01:59 +00:00

PRESENCE/collectord: fix perl warning (Forum: #84243)

git-svn-id: https://svn.fhem.de/fhem/trunk@16171 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2018-02-13 21:37:47 +00:00
parent 3abd49a0c1
commit a2609b315c

View File

@ -72,12 +72,10 @@ my %handle;
my %socket_to_handle;
$SIG{__DIE__} = sub {
my ($msg) = @_;
Log 1, "PERL ERROR: $msg";
};
@ -85,7 +83,6 @@ $SIG{__WARN__} = sub {
my ($msg) = @_;
Log 1, "PERL WARN: $msg";
};
@ -145,16 +142,12 @@ if(not $opt_c)
print STDERR "no config file provided\n\n";
print_usage();
exit 1;
}
if(not -e "$opt_c" or not -r "$opt_c")
{
print STDERR "config-file $opt_c could not be loaded\n";
exit 1;
}
Log 0, "started with PID $$";
@ -186,8 +179,6 @@ Log 1, "created socket on ".$server->sockhost()." with port ".$server->sockport(
my $listener = IO::Select->new();
$listener->add($server);
my @new_handles;
my %child_handles;
my %child_config;
@ -228,7 +219,6 @@ while(1)
Log 2, "cleaning up status values (UUID: $uuid)";
delete $state{$uuid};
}
}
# process all status messages from all threads via status queue
@ -274,21 +264,17 @@ while(1)
}
}
}
}
#print Dumper(\%state);
}
# If a thread has something reported via Log Queue, print it out if verbose is activated
while($log_queue->pending)
{
Log 2, $log_queue->dequeue;
}
# If a INET socket has anything to report
if(@new_handles = $listener->can_read(1))
{
@ -503,7 +489,6 @@ sub daemonize
# the thread subroutine which performs a request for a specific room
sub doQuery($$$)
{
my ($do_config, $do_room, $do_address, $do_uuid) = @_;
my $return;
my $socket;
@ -642,7 +627,6 @@ sub doQuery($$$)
# if the socket has a message available
if(@client_handle = $selector->can_read(1))
{
# get all socket handles which has a message available
foreach my $local_client (@client_handle)
{
@ -715,11 +699,8 @@ sub doQuery($$$)
$log_queue->enqueue(threads->tid()."|exiting thread");
}
sub readConfig
{
my ($ini) = @_;
my $section;
@ -733,26 +714,30 @@ sub readConfig
%config = ();
open (INI, "$ini") or (print STDERR timestamp()."Can't open $ini: $!\n" and exit(1));
while (<INI>) {
chomp;
if (/^\s*?\[([^\]\n\r]+?)\]/) {
$section = $1;
while (<INI>)
{
chomp;
if (/^\s*?\[([^\]\n\r]+?)\]/)
{
$section = $1;
}
if (/^\s*(\w+?)=(.+?)\s*(#.*)?$/ and defined($section)) {
if (/^\s*(\w+?)=(.+?)\s*(#.*)?$/ and defined($section))
{
$keyword = $1;
$value = $2 ;
# put them into hash
$config{$section}{$keyword} = $value;
}
}
close (INI);
close (INI);
# validating config
foreach my $room (keys %config)
{
if(not exists($config{$room}{address}))
{
Log 0, "room $room has no value for address configured";
@ -765,7 +750,6 @@ sub readConfig
Log 0, "no valid address for room $room found: ".$config{$room}{address};
$errorcount++;
}
}
if(not exists($config{$room}{port}))
@ -832,10 +816,8 @@ sub readConfig
}
}
sub aggregateRooms
{
my ($hash) = @_;
my $previous = "absence";
@ -867,7 +849,6 @@ sub aggregateRooms
}
}
# if multiple rooms are present, try selection by highest RSSI
if(@rooms > 0)
{
@ -923,12 +904,11 @@ sub aggregateRooms
if(@rooms > 0)
{
my $rssi_data = join(";", map("rssi_".$_."='".$rssi_results{$_}."'", map {s/\s+/_/rg } keys %rssi_results));
my $ret = "present".
(defined($hroom) ? ";room='".$hroom."'" : "").
return "present".
";rooms='".join(",",sort @rooms)."'".
(defined($hroom) ? ";".$hash->{$hroom}{data} : (defined($hash->{$rooms[0]}{data}) ? ";".$hash->{$rooms[0]}{data} : "")).
(defined($rssi_data) ? ";".$rssi_data : "");
(defined($hroom) ? ";room='".$hroom."'" : "").
(%rssi_results ? ";".join(";", map { "rssi_".($_ =~ s/\s+/_/gr)."='".$rssi_results{$_}."'" } keys %rssi_results) : "").
(defined($hroom) ? ";".$hash->{$hroom}{data} : (defined($hash->{$rooms[0]}{data}) ? ";".$hash->{$rooms[0]}{data} : ""));
}
else
{