Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a68696

Browse filesBrowse files
committed
Fix Expiring lock in PDO and ZooKeeper
1 parent 953ac3e commit 9a68696
Copy full SHA for 9a68696

File tree

2 files changed

+10
-10
lines changed
Filter options

2 files changed

+10
-10
lines changed

‎src/Symfony/Component/Lock/Store/PdoStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/PdoStore.php
+6-10Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
*/
3737
class PdoStore implements StoreInterface
3838
{
39+
use ExpiringStoreTrait;
40+
3941
private $conn;
4042
private $dsn;
4143
private $driver;
@@ -123,9 +125,7 @@ public function save(Key $key)
123125

124126
try {
125127
$stmt->execute();
126-
if ($key->isExpired()) {
127-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
128-
}
128+
$this->checkNotExpired($key);
129129

130130
return;
131131
} catch (DBALException $e) {
@@ -136,13 +136,11 @@ public function save(Key $key)
136136
$this->putOffExpiration($key, $this->initialTtl);
137137
}
138138

139-
if ($key->isExpired()) {
140-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
141-
}
142-
143139
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
144140
$this->prune();
145141
}
142+
143+
$this->checkNotExpired($key);
146144
}
147145

148146
/**
@@ -178,9 +176,7 @@ public function putOffExpiration(Key $key, $ttl)
178176
throw new LockConflictedException();
179177
}
180178

181-
if ($key->isExpired()) {
182-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
183-
}
179+
$this->checkNotExpired($key);
184180
}
185181

186182
/**

‎src/Symfony/Component/Lock/Store/ZookeeperStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/ZookeeperStore.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class ZookeeperStore implements StoreInterface
2727
{
28+
use ExpiringStoreTrait;
29+
2830
private $zookeeper;
2931

3032
public function __construct(\Zookeeper $zookeeper)
@@ -45,6 +47,8 @@ public function save(Key $key)
4547
$token = $this->getUniqueToken($key);
4648

4749
$this->createNewLock($resource, $token);
50+
51+
$this->checkNotExpired($key);
4852
}
4953

5054
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.