2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 08:11:44 +00:00

PRESENCE/collectord: fix missing state information, when executing "now" command and one room is not connected

git-svn-id: https://svn.fhem.de/fhem/trunk@11211 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2016-04-09 16:10:27 +00:00
parent ab60b4b2ee
commit 6c353f15a2

View File

@ -70,6 +70,22 @@ my %socket_to_handle;
my $uuid;
$SIG{__DIE__} = sub {
my ($msg) = @_;
Log 1, "PERL ERROR: $msg";
};
$SIG{__WARN__} = sub {
my ($msg) = @_;
Log 1, "PERL WARN: $msg";
};
Getopt::Long::Configure('bundling');
GetOptions(
"d" => \$opt_d, "daemon" => \$opt_d,
@ -253,7 +269,7 @@ while(1)
}
#print Dumper(%state);
#print Dumper(\%state);
}
@ -373,10 +389,10 @@ while(1)
{
Log 2, "signalling thread ".$handle{$uuid}{threads}{$room}->tid()." to send \"now\"-request for room $room for client ".$client->peerhost();
$queues{$handle{$uuid}{threads}{$room}->tid()}->enqueue("now");
$state{$uuid}{rooms}{$room} = "";
$state{$uuid}{rooms}{$room} = "" if(exists($state{$uuid}{rooms}{$room}));
}
$state{$uuid}{lastresult}{timestamp} = 0;
delete($state{$uuid}{lastresult}) if(exists($state{$uuid}{lastresult}));
$client->send("command accepted\n");
}
@ -556,7 +572,7 @@ sub doQuery($$$)
$log_queue->enqueue(threads->tid()."|$room socket to ".$values{address}.":".$values{port}." did not report anything in expected time, resetting socket (last contact: ".strftime("%Y-%m-%d %H:%M:%S", localtime($last_contact)).")");
$selector->remove($client_socket);
shutdown($client_socket, 2);
$client_socket->shutdown(2);
close($client_socket);
$client_socket = undef;
}
@ -574,7 +590,7 @@ sub doQuery($$$)
elsif($cmd eq "stop")
{
$log_queue->enqueue(threads->tid()."|$room terminating thread ".threads->tid()." for $address");
$client_socket->shutdown() if(defined($client_socket));
$client_socket->shutdown(2) if(defined($client_socket));
$selector->remove($client_socket) if(defined($selector));
close($client_socket) if(defined($client_socket));
$client_socket = undef;
@ -709,7 +725,7 @@ sub doQuery($$$)
$selector->remove($local_client);
shutdown($local_client, 2);
$local_client->shutdown(2);
close($local_client);
$client_socket = undef;
}