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