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 * Set a list of converters
* *
@ -146,7 +179,11 @@ class SeedDMS_Preview_Previewer {
} }
*/ */
if($cmd) { if($cmd) {
exec($cmd); //exec($cmd);
try {
self::execWithTimeout($cmd);
} catch(Exception $e) {
}
} }
return true; return true;
} }

View File

@ -11,8 +11,8 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2015-02-13</date> <date>2015-08-08</date>
<time>20:29:39</time> <time>09:36:57</time>
<version> <version>
<release>1.1.4</release> <release>1.1.4</release>
<api>1.1.4</api> <api>1.1.4</api>
@ -23,7 +23,8 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <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> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">