Skip to content

Commit 3042a5a

Browse files
authored
Merge pull request #25550 from nextcloud/reconnectwrapper-wait-timeout
[20] change reconect wrapper to only check connection after inactivity
2 parents b3ac30c + b51f32e commit 3042a5a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/private/DB/ReconnectWrapper.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,22 @@
3131
class ReconnectWrapper extends \Doctrine\DBAL\Connection {
3232
public const CHECK_CONNECTION_INTERVAL = 60;
3333

34-
private $lastConnectionCheck = null;
34+
private $lastQuery = null;
3535

3636
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) {
3737
parent::__construct($params, $driver, $config, $eventManager);
38-
$this->lastConnectionCheck = time();
38+
$this->lastQuery = time();
3939
}
4040

4141
public function connect() {
4242
$now = time();
4343
$checkTime = $now - self::CHECK_CONNECTION_INTERVAL;
4444

45-
if ($this->lastConnectionCheck > $checkTime || $this->isTransactionActive()) {
45+
if ($this->lastQuery > $checkTime || $this->isTransactionActive()) {
46+
$this->lastQuery = $now;
4647
return parent::connect();
4748
} else {
48-
$this->lastConnectionCheck = $now;
49+
$this->lastQuery = $now;
4950
if (!$this->ping()) {
5051
$this->close();
5152
}

0 commit comments

Comments
 (0)