some long running operations, eg. merge-print, run into situation that DB closes our separate sqlfs connection, we try now to reconnect once

This commit is contained in:
Ralf Becker 2013-08-05 09:47:16 +00:00
parent 57634dc01f
commit e9bf6d69e1
2 changed files with 48 additions and 23 deletions

View File

@ -1570,6 +1570,15 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
*/
public static $case_sensitive_equal = '=';
/**
* Reconnect to database
*/
static public function reconnect()
{
unset(self::$pdo);
self::$pdo = self::_pdo();
}
/**
* Create pdo object / connection, as long as pdo is not generally used in eGW
*

View File

@ -873,13 +873,15 @@ class vfs_stream_wrapper implements iface_stream_wrapper
* @param boolean $check_symlink_components=true check if path contains symlinks in path components other then the last one
* @return array
*/
static function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH )
static function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true, $check_symlink_depth=self::MAX_SYMLINK_DEPTH, $try_reconnect=true )
{
if (!($url = self::resolve_url($path,!($flags & STREAM_URL_STAT_LINK), $check_symlink_components)))
{
if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path',$flags) can NOT resolve path!");
return false;
}
try {
if ($flags & STREAM_URL_STAT_LINK)
{
$stat = @lstat($url); // suppressed the stat failed warnings
@ -912,6 +914,20 @@ class vfs_stream_wrapper implements iface_stream_wrapper
}
}
}
}
catch (egw_exception_db $e) {
// some long running operations, eg. merge-print, run into situation that DB closes our separate sqlfs connection
// we try now to reconnect sqlfs_stream_wrapper once
// it's done here in vfs_stream_wrapper as situation can happen in sqlfs, links, stylite.links or stylite.versioning
if ($try_reconnect)
{
// reconnect to db
sqlfs_stream_wrapper::reconnect();
return url_stat($path, $flags, $try_create_home, $check_symlink_components, $check_symlink_depth, false);
}
// if numer of tries is exceeded, re-throw exception
throw $e;
}
// check if a failed url_stat was for a home dir, in that case silently create it
if (!$stat && $try_create_home && egw_vfs::dirname(parse_url($path,PHP_URL_PATH)) == '/home' &&
($id = $GLOBALS['egw']->accounts->name2id(basename($path))) &&