From: sleepy Date: Tue, 8 Sep 2020 05:24:59 +0000 (+1000) Subject: Исправлен баг в результате котогоро AsyncAGI могло зависнуть в случае если на канале... X-Git-Url: http://git.ultra-x.su/?a=commitdiff_plain;h=4d5b386cbf50596faee6386acd06fa90baf43f28;p=dev Исправлен баг в результате котогоро AsyncAGI могло зависнуть в случае если на канале вызов уже завершился и и AsyncAGI уже завершён --- diff --git a/astapilib/baseagi.php b/astapilib/baseagi.php index da7fbc5..732705f 100644 --- a/astapilib/baseagi.php +++ b/astapilib/baseagi.php @@ -54,6 +54,10 @@ trait callioAGI $line = array_shift($this->RxBuffer); if ($line === NULL) { + if (!$this->IsAlive()) + { + return ''; + } usleep(250000); } else @@ -66,8 +70,19 @@ trait callioAGI protected function TxData($cmd) { - $this->AmiInstance->SendAsyncAGICmd($this->GetRequest('agi_channel'), $cmd); - return TRUE; + if (!$this->IsAlive()) + { + return FALSE; + } + $result = $this->AmiInstance->SendAsyncAGICmd($this->GetRequest('agi_channel'), $cmd); + if ($result) + { + return TRUE; + } + else + { + return FALSE; + } } } @@ -119,12 +134,11 @@ trait baseAGI //обработка комманды protected function ProcessCmd($cmd) { - if (!$this->IsAlive()) + if ($this->TxData($cmd) === FALSE) { + $this->last_response = FALSE; return FALSE; } - - $this->TxData($cmd); $line = $this->RxData(); $parse_result = preg_match('/(\d+)(?:.)(.*)/', $line, $parsed_line); if ($parse_result === 1)