Merge branch 'seeddms-5.0.x' into develop

This commit is contained in:
Uwe Steinmann 2015-08-08 09:40:15 +02:00
commit a20c6f23e2
2 changed files with 42 additions and 4 deletions

View File

@ -68,6 +68,39 @@ class SeedDMS_Preview_Previewer {
);
}
static function execWithTimeout($cmd, $timeout=2) { /* {{{ */
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$pipes = array();
$timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd);
}
$output = '';
do {
$timeleft = $timeout - time();
$read = array($pipes[1]);
stream_select($read, $write = NULL, $exeptions = NULL, $timeleft, NULL);
if (!empty($read)) {
$output .= fread($pipes[1], 8192);
}
} while (!feof($pipes[1]) && $timeleft > 0);
if ($timeleft <= 0) {
proc_terminate($process);
throw new Exception("command timeout on: " . $cmd);
} else {
return $output;
}
} /* }}} */
/**
* Set a list of converters
*
@ -146,7 +179,11 @@ class SeedDMS_Preview_Previewer {
}
*/
if($cmd) {
exec($cmd);
//exec($cmd);
try {
self::execWithTimeout($cmd);
} catch(Exception $e) {
}
}
return true;
}

View File

@ -11,8 +11,8 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2015-02-13</date>
<time>20:29:39</time>
<date>2015-08-08</date>
<time>09:36:57</time>
<version>
<release>1.1.4</release>
<api>1.1.4</api>
@ -23,7 +23,8 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
Converters to create preview images are no longer fixed. Those which has been hardcoded before remain the predefined converters, but they can also be changed.
- Converters to create preview images are no longer fixed. Those which has been hardcoded before remain the predefined converters, but they can also be changed.
- command for creating the preview will be called with a given timeout
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">