Skip to content

Commit 7152f3d

Browse files
authored
Update BaseRedis.php
1 parent 144994d commit 7152f3d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/BaseRedis.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function brpoplpush($srcKey, $dstKey, $timeout)
118118
} catch (\RedisException $e) {
119119
$end = time();
120120
if ($end - $start < $timeout) {
121+
$this->pool->close(null);
121122
throw $e;
122123
}
123124
$data = false;
@@ -138,9 +139,14 @@ public function multi($mode = \Redis::MULTI)
138139
if (! $this->multiOnGoing) {
139140
$this->connection = $this->pool->getConnection();
140141

142+
try {
143+
$this->connection->multi($mode);
144+
} catch (\RedisException $e) {
145+
$this->pool->close(null);
146+
throw $e;
147+
}
148+
141149
$this->multiOnGoing = true;
142-
143-
$this->connection->multi($mode);
144150
}
145151

146152
return $this;
@@ -152,8 +158,14 @@ public function exec()
152158
return;
153159
}
154160

155-
$result = $this->connection->exec();
156-
161+
try {
162+
$result = $this->connection->exec();
163+
} catch (\RedisException $e) {
164+
$this->multiOnGoing = false;
165+
$this->pool->close(null);
166+
throw $e;
167+
}
168+
157169
$this->multiOnGoing = false;
158170

159171
$this->pool->close($this->connection);

0 commit comments

Comments
 (0)