timeout for external command can be passed to previewer

This commit is contained in:
Uwe Steinmann 2016-02-15 10:38:27 +01:00
parent af4e6d46fb
commit 8bcca6a16a

View File

@ -37,7 +37,13 @@ class SeedDMS_Preview_Previewer {
*/
protected $width;
function __construct($previewDir, $width=40) {
/**
* @var integer $timeout maximum time for execution of external commands
* @access protected
*/
protected $timeout;
function __construct($previewDir, $width=40, $timeout=5) {
if(!is_dir($previewDir)) {
if (!SeedDMS_Core_File::makeDir($previewDir)) {
$this->previewDir = '';
@ -48,9 +54,10 @@ class SeedDMS_Preview_Previewer {
$this->previewDir = $previewDir;
}
$this->width = intval($width);
$this->timeout = intval($timeout);
}
static function execWithTimeout($cmd, $timeout=2) { /* {{{ */
static function execWithTimeout($cmd, $timeout=5) { /* {{{ */
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
@ -155,7 +162,7 @@ class SeedDMS_Preview_Previewer {
if($cmd) {
//exec($cmd);
try {
self::execWithTimeout($cmd);
self::execWithTimeout($cmd, $this->timeout);
} catch(Exception $e) {
}
}
@ -216,7 +223,7 @@ class SeedDMS_Preview_Previewer {
if($cmd) {
//exec($cmd);
try {
self::execWithTimeout($cmd);
self::execWithTimeout($cmd, $this->timeout);
} catch(Exception $e) {
}
}