From 2cfc080382efbc1b529142c87c77c25dd857b0a5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 1 Mar 2017 16:18:27 +0100 Subject: [PATCH] better handling of timeout --- SeedDMS_Lucene/Lucene/IndexedDocument.php | 15 ++++++++------- SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/SeedDMS_Lucene/Lucene/IndexedDocument.php b/SeedDMS_Lucene/Lucene/IndexedDocument.php index 027536dae..54dbb2676 100644 --- a/SeedDMS_Lucene/Lucene/IndexedDocument.php +++ b/SeedDMS_Lucene/Lucene/IndexedDocument.php @@ -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) { diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php b/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php index d7c178b0f..5d2914074 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php @@ -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);