mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
better handling of timeout
This commit is contained in:
parent
fab21da3d8
commit
2cfc080382
|
@ -32,23 +32,24 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
);
|
);
|
||||||
$pipes = array();
|
$pipes = array();
|
||||||
|
|
||||||
$timeout += time();
|
$timeout += time();
|
||||||
$process = proc_open($cmd, $descriptorspec, $pipes);
|
$process = proc_open($cmd, $descriptorspec, $pipes);
|
||||||
if (!is_resource($process)) {
|
if (!is_resource($process)) {
|
||||||
throw new Exception("proc_open failed on: " . $cmd);
|
throw new Exception("proc_open failed on: " . $cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
$timeleft = $timeout - time();
|
||||||
|
$read = array($pipes[1]);
|
||||||
|
$write = NULL;
|
||||||
|
$exeptions = NULL;
|
||||||
do {
|
do {
|
||||||
$timeleft = $timeout - time();
|
|
||||||
$read = array($pipes[1]);
|
|
||||||
$write = NULL;
|
|
||||||
$exeptions = NULL;
|
|
||||||
stream_select($read, $write, $exeptions, $timeleft, 200000);
|
stream_select($read, $write, $exeptions, $timeleft, 200000);
|
||||||
|
|
||||||
if (!empty($read)) {
|
if (!empty($read)) {
|
||||||
$output .= fread($pipes[1], 8192);
|
$output .= fread($pipes[1], 8192);
|
||||||
}
|
}
|
||||||
|
$timeleft = $timeout - time();
|
||||||
} while (!feof($pipes[1]) && $timeleft > 0);
|
} while (!feof($pipes[1]) && $timeleft > 0);
|
||||||
|
|
||||||
if ($timeleft <= 0) {
|
if ($timeleft <= 0) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
);
|
);
|
||||||
$pipes = array();
|
$pipes = array();
|
||||||
|
|
||||||
$timeout += time();
|
$timeout += time();
|
||||||
$process = proc_open($cmd, $descriptorspec, $pipes);
|
$process = proc_open($cmd, $descriptorspec, $pipes);
|
||||||
if (!is_resource($process)) {
|
if (!is_resource($process)) {
|
||||||
throw new Exception("proc_open failed on: " . $cmd);
|
throw new Exception("proc_open failed on: " . $cmd);
|
||||||
|
@ -53,7 +53,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
|
|
||||||
if (!empty($read)) {
|
if (!empty($read)) {
|
||||||
$output .= fread($pipes[1], 8192);
|
$output .= fread($pipes[1], 8192);
|
||||||
}
|
}
|
||||||
$timeleft = $timeout - time();
|
$timeleft = $timeout - time();
|
||||||
} while (!feof($pipes[1]) && $timeleft > 0);
|
} while (!feof($pipes[1]) && $timeleft > 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user