Fix Locks

- Wrong return of lock releasing with DBA provider
- It's not possible to maintain Semaphore locks, since they aren't accessible by other processes
Should solve https://github.com/friendica/friendica/issues/7298#issuecomment-521996540
This commit is contained in:
Philipp Holzer 2019-08-17 19:33:36 +02:00
parent e8561b480b
commit c803dcb6c5
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
4 changed files with 74 additions and 48 deletions

View file

@ -22,7 +22,7 @@ class SemaphoreLockTest extends LockTest
$configMock
->shouldReceive('get')
->with('system', 'temppath', NULL, false)
->andReturn('/tmp/');
->andReturn('/tmp');
$dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
@ -41,4 +41,32 @@ class SemaphoreLockTest extends LockTest
// Semaphore doesn't work with TTL
return true;
}
/**
* Test if semaphore locking works even for
*/
public function testMissingFileNotOverriding()
{
$file = get_temppath() . '/test.sem';
$this->assertTrue(file_exists($file));
$this->assertFalse($this->instance->releaseLock('test', false));
$this->assertTrue(file_exists($file));
}
/**
* Test overriding semaphore release with already set semaphore
* This test proves that semaphore locks cannot get released by other instances except themselves
*
* Check for Bug https://github.com/friendica/friendica/issues/7298#issuecomment-521996540
* @see https://github.com/friendica/friendica/issues/7298#issuecomment-521996540
*/
public function testMissingFileOverriding()
{
$file = get_temppath() . '/test.sem';
$this->assertTrue(file_exists($file));
$this->assertFalse($this->instance->releaseLock('test', true));
$this->assertTrue(file_exists($file));
}
}