File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 24
24
*/
25
25
class SemaphoreStore implements StoreInterface
26
26
{
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 )
28
35
{
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 ;
30
45
}
31
46
32
47
public function __construct ()
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ abstract protected function getStore();
35
35
public function testBlockingLocks ()
36
36
{
37
37
// Amount a microsecond used to order async actions
38
- $ clockDelay = 50000 ;
38
+ $ clockDelay = 200000 ;
39
39
40
40
if (\PHP_VERSION_ID < 50600 || defined ('HHVM_VERSION_ID ' )) {
41
41
$ this ->markTestSkipped ('The PHP engine does not keep resource in child forks ' );
@@ -49,7 +49,7 @@ public function testBlockingLocks()
49
49
50
50
if ($ childPID1 = pcntl_fork ()) {
51
51
// give time to fork to start
52
- usleep (2 * $ clockDelay );
52
+ usleep (1 * $ clockDelay );
53
53
54
54
try {
55
55
// This call should failed given the lock should already by acquired by the child #1
@@ -69,8 +69,8 @@ public function testBlockingLocks()
69
69
} else {
70
70
try {
71
71
$ 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 );
74
74
$ store ->delete ($ key );
75
75
exit (0 );
76
76
} catch (\Exception $ e ) {
You can’t perform that action at this time.
0 commit comments