Commit 634b4a2f authored by Franco Fichtner's avatar Franco Fichtner

mvc: handle execution error more gracefully; closes #1413

parent 1df84c3e
...@@ -446,6 +446,7 @@ class FirmwareController extends ApiControllerBase ...@@ -446,6 +446,7 @@ class FirmwareController extends ApiControllerBase
return $result; return $result;
} }
/** /**
* retrieve upgrade status (and log file of current process) * retrieve upgrade status (and log file of current process)
*/ */
...@@ -457,7 +458,7 @@ class FirmwareController extends ApiControllerBase ...@@ -457,7 +458,7 @@ class FirmwareController extends ApiControllerBase
$result['log'] = $cmd_result; $result['log'] = $cmd_result;
if (trim($cmd_result) == 'Execute error') { if ($cmd_result == null) {
$result['status'] = 'error'; $result['status'] = 'error';
} elseif (strpos($cmd_result, '***DONE***') !== false) { } elseif (strpos($cmd_result, '***DONE***') !== false) {
$result['status'] = 'done'; $result['status'] = 'done';
......
...@@ -540,7 +540,9 @@ class SystemhealthController extends ApiControllerBase ...@@ -540,7 +540,9 @@ class SystemhealthController extends ApiControllerBase
if ($rrd_details['filename'] != "") { if ($rrd_details['filename'] != "") {
$backend = new Backend(); $backend = new Backend();
$response = $backend->configdpRun("systemhealth fetch ", array($rrd_details['filename'])); $response = $backend->configdpRun("systemhealth fetch ", array($rrd_details['filename']));
$xml = @simplexml_load_string($response); if ($response != null) {
$xml = @simplexml_load_string($response);
}
} }
if ($xml !== false) { if ($xml !== false) {
......
...@@ -77,6 +77,7 @@ class Backend ...@@ -77,6 +77,7 @@ class Backend
public function configdRun($event, $detach = false, $timeout = 120, $connect_timeout = 10) public function configdRun($event, $detach = false, $timeout = 120, $connect_timeout = 10)
{ {
$endOfStream = chr(0).chr(0).chr(0); $endOfStream = chr(0).chr(0).chr(0);
$errorOfStream = 'Execute error';
$poll_timeout = 2; // poll timeout interval $poll_timeout = 2; // poll timeout interval
// wait until socket exist for a maximum of $connect_timeout // wait until socket exist for a maximum of $connect_timeout
...@@ -122,7 +123,12 @@ class Backend ...@@ -122,7 +123,12 @@ class Backend
} }
} }
return str_replace($endOfStream, "", $resp); if (strlen($resp) >= strlen($errorOfStream) &&
substr($resp, 0, strlen($errorOfStream)) == $errorOfStream) {
return null;
}
return str_replace($endOfStream, '', $resp);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment