From 1b607d9b4729033760ea7d8f1145b062801b1fe4 Mon Sep 17 00:00:00 2001 From: dominikkarall Date: Wed, 11 Apr 2018 19:01:32 +0000 Subject: [PATCH] 98_GOOGLECAST: fix crash, add log messages git-svn-id: https://svn.fhem.de/fhem/trunk@16589 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_GOOGLECAST.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/98_GOOGLECAST.pm b/fhem/FHEM/98_GOOGLECAST.pm index 932e8888b..939c731a6 100755 --- a/fhem/FHEM/98_GOOGLECAST.pm +++ b/fhem/FHEM/98_GOOGLECAST.pm @@ -170,8 +170,10 @@ sub GOOGLECAST_Define($$) { } elsif(int(@a) == 3) { Log3 $hash, 3, "GOOGLECAST: $a[2] initializing..."; $hash->{CCNAME} = $a[2]; + Log3 $hash, 5, "GOOGLECAST: $a[2] set readings offline"; GOOGLECAST_updateReading($hash, "presence", "offline"); GOOGLECAST_updateReading($hash, "state", "offline"); + Log3 $hash, 5, "GOOGLECAST: $a[2] start initDevice"; GOOGLECAST_initDevice($hash); } @@ -197,7 +199,9 @@ sub GOOGLECAST_initDevice { my ($hash) = @_; my $devName = $hash->{CCNAME}; + Log3 $hash, 5, "GOOGLECAST($hash->{NAME}): start findChromecasts BlockingCall"; BlockingCall("GOOGLECAST_findChromecasts", $hash->{NAME}, "GOOGLECAST_findChromecastsResult"); + Log3 $hash, 5, "GOOGLECAST($hash->{NAME}): finished findChromecasts BlockingCall"; return undef; } @@ -567,10 +571,15 @@ sub GOOGLECAST_addSocketToMainloop { eval { $sock = $hash->{helper}{ccdevice}->{socket_client}->get_socket(); - $hash->{helper}{currentsock} = $sock; + if ($sock->fileno() > 0) { + $hash->{helper}{currentsock} = $sock; + } }; - my $chash = GOOGLECAST_newChash($hash, $sock, {NAME => "GOOGLECAST-".$hash->{NAME}}); + if ($sock->fileno() > 0) { + my $chash = GOOGLECAST_newChash($hash, $sock, {NAME => "GOOGLECAST-".$hash->{NAME}}); + } + return undef; } @@ -611,6 +620,8 @@ sub GOOGLECAST_Read { my $name = $hash->{NAME}; $hash = $hash->{phash}; + return undef if (!defined($hash)); + eval { Log3 $hash, 5, "GOOGLECAST ($hash->{NAME}): run_once"; $hash->{helper}{ccdevice}->{socket_client}->run_once();