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
return $result;
}
/**
* retrieve upgrade status (and log file of current process)
*/
......@@ -457,7 +458,7 @@ class FirmwareController extends ApiControllerBase
$result['log'] = $cmd_result;
if (trim($cmd_result) == 'Execute error') {
if ($cmd_result == null) {
$result['status'] = 'error';
} elseif (strpos($cmd_result, '***DONE***') !== false) {
$result['status'] = 'done';
......
......@@ -540,7 +540,9 @@ class SystemhealthController extends ApiControllerBase
if ($rrd_details['filename'] != "") {
$backend = new Backend();
$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) {
......
......@@ -77,6 +77,7 @@ class Backend
public function configdRun($event, $detach = false, $timeout = 120, $connect_timeout = 10)
{
$endOfStream = chr(0).chr(0).chr(0);
$errorOfStream = 'Execute error';
$poll_timeout = 2; // poll timeout interval
// wait until socket exist for a maximum of $connect_timeout
......@@ -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