summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-03-24 14:07:43 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-04-07 08:24:13 +0200
commitcdedda99e4b7f66f136d7db4788c2f033df2d442 (patch)
tree8a0650a3001c9a095c3bb104a206b697e8125eeb /lib/private
parent9b930cd01d2a536cfa21ba08a3be737cdfe4e54b (diff)
downloadnextcloud-server-cdedda99e4b7f66f136d7db4788c2f033df2d442.tar.gz
nextcloud-server-cdedda99e4b7f66f136d7db4788c2f033df2d442.zip
Make lock ttl configurable
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Server.php9
-rw-r--r--lib/private/lock/abstractlockingprovider.php2
-rw-r--r--lib/private/lock/dblockingprovider.php6
-rw-r--r--lib/private/lock/memcachelockingprovider.php6
4 files changed, 15 insertions, 8 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 581a2b44cea..2ce895c6f72 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -519,14 +519,17 @@ class Server extends ServerContainer implements IServerContainer {
);
});
$this->registerService('LockingProvider', function (Server $c) {
- if ($c->getConfig()->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
+ $ini = $c->getIniWrapper();
+ $config = $c->getConfig();
+ $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
+ if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
/** @var \OC\Memcache\Factory $memcacheFactory */
$memcacheFactory = $c->getMemCacheFactory();
$memcache = $memcacheFactory->createLocking('lock');
if (!($memcache instanceof \OC\Memcache\NullCache)) {
- return new MemcacheLockingProvider($memcache);
+ return new MemcacheLockingProvider($memcache, $ttl);
}
- return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory());
+ return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
}
return new NoopLockingProvider();
});
diff --git a/lib/private/lock/abstractlockingprovider.php b/lib/private/lock/abstractlockingprovider.php
index 7dee8c709a0..f96358778c1 100644
--- a/lib/private/lock/abstractlockingprovider.php
+++ b/lib/private/lock/abstractlockingprovider.php
@@ -28,7 +28,7 @@ use OCP\Lock\ILockingProvider;
* to release any left over locks at the end of the request
*/
abstract class AbstractLockingProvider implements ILockingProvider {
- const TTL = 3600; // how long until we clear stray locks in seconds
+ protected $ttl; // how long until we clear stray locks in seconds
protected $acquiredLocks = [
'shared' => [],
diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php
index c10cd8636ad..9e97df44d3f 100644
--- a/lib/private/lock/dblockingprovider.php
+++ b/lib/private/lock/dblockingprovider.php
@@ -93,11 +93,13 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param \OCP\IDBConnection $connection
* @param \OCP\ILogger $logger
* @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory
+ * @param int $ttl
*/
- public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory) {
+ public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory, $ttl = 3600) {
$this->connection = $connection;
$this->logger = $logger;
$this->timeFactory = $timeFactory;
+ $this->ttl = $ttl;
}
/**
@@ -117,7 +119,7 @@ class DBLockingProvider extends AbstractLockingProvider {
* @return int
*/
protected function getExpireTime() {
- return $this->timeFactory->getTime() + self::TTL;
+ return $this->timeFactory->getTime() + $this->ttl;
}
/**
diff --git a/lib/private/lock/memcachelockingprovider.php b/lib/private/lock/memcachelockingprovider.php
index 08c92950e49..536b29e2c28 100644
--- a/lib/private/lock/memcachelockingprovider.php
+++ b/lib/private/lock/memcachelockingprovider.php
@@ -33,14 +33,16 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
/**
* @param \OCP\IMemcache $memcache
+ * @param int $ttl
*/
- public function __construct(IMemcache $memcache) {
+ public function __construct(IMemcache $memcache, $ttl = 3600) {
$this->memcache = $memcache;
+ $this->ttl = $ttl;
}
private function setTTL($path) {
if ($this->memcache instanceof IMemcacheTTL) {
- $this->memcache->setTTL($path, self::TTL);
+ $this->memcache->setTTL($path, $this->ttl);
}
}