Skip to content

Commit fa98b7a

Browse files
committed
Deprecate Filesystem/LockHandler
1 parent c9e1ebb commit fa98b7a

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Store/SemaphoreStore.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,24 @@
2424
*/
2525
class SemaphoreStore implements StoreInterface
2626
{
27-
public static function isSupported()
27+
/**
28+
* Returns whether or not the store is supported.
29+
*
30+
* @param bool|null $blocking When not null, checked again the blocking mode.
31+
*
32+
* @return bool
33+
*/
34+
public static function isSupported($blocking = null)
2835
{
29-
return extension_loaded('sysvsem');
36+
if (!extension_loaded('sysvsem')) {
37+
return false;
38+
}
39+
40+
if ($blocking === false && \PHP_VERSION_ID < 50601) {
41+
return false;
42+
}
43+
44+
return true;
3045
}
3146

3247
public function __construct()

Tests/Store/BlockingStoreTestTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract protected function getStore();
3535
public function testBlockingLocks()
3636
{
3737
// Amount a microsecond used to order async actions
38-
$clockDelay = 50000;
38+
$clockDelay = 200000;
3939

4040
if (\PHP_VERSION_ID < 50600 || defined('HHVM_VERSION_ID')) {
4141
$this->markTestSkipped('The PHP engine does not keep resource in child forks');
@@ -49,7 +49,7 @@ public function testBlockingLocks()
4949

5050
if ($childPID1 = pcntl_fork()) {
5151
// give time to fork to start
52-
usleep(2 * $clockDelay);
52+
usleep(1 * $clockDelay);
5353

5454
try {
5555
// This call should failed given the lock should already by acquired by the child #1
@@ -69,8 +69,8 @@ public function testBlockingLocks()
6969
} else {
7070
try {
7171
$store->save($key);
72-
// Wait 3 ClockDelay to let parent process to finish
73-
usleep(3 * $clockDelay);
72+
// Wait 2 ClockDelay to let parent process to finish
73+
usleep(2 * $clockDelay);
7474
$store->delete($key);
7575
exit(0);
7676
} catch (\Exception $e) {

0 commit comments

Comments
 (0)