aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-01-13 02:03:16 +0100
committerOleg Pudeyev <oleg@bsdpower.com>2011-02-12 22:05:54 -0500
commit2e47409e8093284a03c23bb9bd6c8e87f407cb35 (patch)
treea3236ced2f3d245ba1b6daad8b5de7c5c53b39f0
parent09b136272b9ec25824f1c72d0148bdfe43a43603 (diff)
downloadforums-2e47409e8093284a03c23bb9bd6c8e87f407cb35.tar
forums-2e47409e8093284a03c23bb9bd6c8e87f407cb35.tar.gz
forums-2e47409e8093284a03c23bb9bd6c8e87f407cb35.tar.bz2
forums-2e47409e8093284a03c23bb9bd6c8e87f407cb35.tar.xz
forums-2e47409e8093284a03c23bb9bd6c8e87f407cb35.zip
[feature/system-cron] Rename lock() to acquire and unlock() to release.
PHPBB3-9596
-rw-r--r--phpBB/cron.php4
-rw-r--r--phpBB/includes/lock/db.php10
-rw-r--r--tests/lock/db_test.php26
3 files changed, 20 insertions, 20 deletions
diff --git a/phpBB/cron.php b/phpBB/cron.php
index fb85e9fe18..e179b3e8d6 100644
--- a/phpBB/cron.php
+++ b/phpBB/cron.php
@@ -48,7 +48,7 @@ function do_cron($cron_lock, $run_tasks)
}
// Unloading cache and closing db after having done the dirty work.
- $cron_lock->unlock();
+ $cron_lock->release();
garbage_collection();
}
@@ -74,7 +74,7 @@ else
}
$cron_lock = new phpbb_lock_db('cron_lock', $config, $db);
-if ($cron_lock->lock())
+if ($cron_lock->acquire())
{
if ($config['use_system_cron'])
{
diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php
index 092f4f9789..f5f1b4c6f9 100644
--- a/phpBB/includes/lock/db.php
+++ b/phpBB/includes/lock/db.php
@@ -80,11 +80,11 @@ class phpbb_lock_db
* @return bool true if lock was acquired
* false otherwise
*/
- public function lock()
+ public function acquire()
{
if ($this->locked)
{
- return true;
+ return false;
}
if (!isset($this->config[$this->config_name]))
@@ -119,15 +119,15 @@ class phpbb_lock_db
/**
* Releases the lock.
*
- * The lock must have been previously obtained, that is, lock() call
+ * The lock must have been previously obtained, that is, acquire() call
* was issued and returned true.
*
* Note: Attempting to release a lock that is already released,
- * that is, calling unlock() multiple times, is harmless.
+ * that is, calling release() multiple times, is harmless.
*
* @return void
*/
- public function unlock()
+ public function release()
{
if ($this->locked)
{
diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php
index f60d7e3ee8..3b2e3ea3b2 100644
--- a/tests/lock/db_test.php
+++ b/tests/lock/db_test.php
@@ -32,52 +32,52 @@ class phpbb_lock_db_test extends phpbb_database_test_case
public function test_new_lock()
{
- $this->assertTrue($this->lock->lock());
+ $this->assertTrue($this->lock->acquire());
$this->assertTrue(isset($this->config['test_lock']), 'Lock was created');
$lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db);
- $this->assertFalse($lock2->lock());
+ $this->assertFalse($lock2->acquire());
- $this->lock->unlock();
+ $this->lock->release();
$this->assertEquals('0', $this->config['test_lock'], 'Lock was released');
}
public function test_expire_lock()
{
$lock = new phpbb_lock_db('foo_lock', $this->config, $this->db);
- $this->assertTrue($lock->lock());
+ $this->assertTrue($lock->acquire());
}
public function test_double_lock()
{
- $this->assertTrue($this->lock->lock());
+ $this->assertTrue($this->lock->acquire());
$this->assertTrue(isset($this->config['test_lock']), 'Lock was created');
$value = $this->config['test_lock'];
- $this->assertTrue($this->lock->lock());
- $this->assertEquals($value, $this->config['test_lock'], 'Second lock was ignored');
+ $this->assertFalse($this->lock->acquire());
+ $this->assertEquals($value, $this->config['test_lock'], 'Second lock failed');
- $this->lock->unlock();
+ $this->lock->release();
$this->assertEquals('0', $this->config['test_lock'], 'Lock was released');
}
public function test_double_unlock()
{
- $this->assertTrue($this->lock->lock());
+ $this->assertTrue($this->lock->acquire());
$this->assertFalse(empty($this->config['test_lock']), 'First lock is acquired');
- $this->lock->unlock();
+ $this->lock->release();
$this->assertEquals('0', $this->config['test_lock'], 'First lock is released');
$lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db);
- $this->assertTrue($lock2->lock());
+ $this->assertTrue($lock2->acquire());
$this->assertFalse(empty($this->config['test_lock']), 'Second lock is acquired');
- $this->lock->unlock();
+ $this->lock->release();
$this->assertFalse(empty($this->config['test_lock']), 'Double release of first lock is ignored');
- $lock2->unlock();
+ $lock2->release();
$this->assertEquals('0', $this->config['test_lock'], 'Second lock is released');
}
}