From eb1ff79ebf9d184067b91d9453384b8f3782d679 Mon Sep 17 00:00:00 2001 From: DeeSPe Date: Fri, 1 Dec 2017 11:40:09 +0000 Subject: [PATCH] 98_Hyperion: add AbortFn to BlockingCall git-svn-id: https://svn.fhem.de/fhem/trunk@15533 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_Hyperion.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/98_Hyperion.pm b/fhem/FHEM/98_Hyperion.pm index 327538a14..e3dffc259 100644 --- a/fhem/FHEM/98_Hyperion.pm +++ b/fhem/FHEM/98_Hyperion.pm @@ -402,7 +402,7 @@ sub Hyperion_GetConfigs($) } Log3 $name,4,"$name: lsCmd: $com"; $com = encode_base64($com); - $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$com","Hyperion_GetConfigs_finished"); + $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$com","Hyperion_GetConfigs_finished",20,"Hyperion_ExecCmd_aborted",$hash); return "Working in background..."; } @@ -509,6 +509,19 @@ sub Hyperion_Kill_finished($) return undef; } +sub Hyperion_ExecCmd_aborted($) +{ + my ($hash) = @_; + my $name = $hash->{NAME}; + delete $hash->{helper}{RUNNING_PID}; + delete $hash->{helper}{configFile} if ($hash->{helper}{configFile}); + delete $hash->{helper}{startCmd} if ($hash->{helper}{startCmd}); + my $er = "Hyperion_ExecCmd aborted due to timeout of 20 sec."; + Log3 $name,2,"$name: $er"; + readingsSingleUpdate($hash,"lastError",$er,1); + return undef; +} + sub Hyperion_Restart($) { my ($string) = @_; @@ -525,7 +538,7 @@ sub Hyperion_Restart($) else { my $cmd = $hash->{helper}{startCmd}; - $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$cmd","Hyperion_Restart_finished"); + $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$cmd","Hyperion_Restart_finished",20,"Hyperion_ExecCmd_aborted",$hash); } return undef; } @@ -626,7 +639,7 @@ sub Hyperion_Set($@) $com .= Hyperion_isLocal($ip)?"":"'"; Log3 $name,4,"$name: stopCmd: $com"; $com = encode_base64($com); - $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$com","Hyperion_Kill_finished"); + $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$com","Hyperion_Kill_finished",20,"Hyperion_ExecCmd_aborted",$hash); } elsif (($cmd eq "binary" && $value eq "restart") || $cmd eq "configFile") { @@ -654,7 +667,7 @@ sub Hyperion_Set($@) $com = encode_base64($com); $hash->{helper}{configFile} = $file; $hash->{helper}{startCmd} = encode_base64($start); - $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$com","Hyperion_Restart"); + $hash->{helper}{RUNNING_PID} = BlockingCall("Hyperion_ExecCmd","$name|$com","Hyperion_Restart",20,"Hyperion_ExecCmd_aborted",$hash); } return; }