mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 04:31:32 +00:00
timeout for external command can be passed to previewer
This commit is contained in:
parent
af4e6d46fb
commit
8bcca6a16a
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user