Skip to content

Commit

Permalink
修复重连后auth db不正确问题
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored Aug 1, 2024
1 parent 542f10c commit 4e910d4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,12 @@ public function connect()
Timer::del($this->_reconnectTimer);
$this->_reconnectTimer = null;
}

if ($this->_db) {
if ($this->_db && ($this->_queue[0][0][0] ?? '') !== 'SELECT' && ($this->_queue[0][0][0] ?? '') !== 'AUTH' && ($this->_queue[1][0][0] ?? '') !== 'SELECT') {
$this->_queue = \array_merge([[['SELECT', $this->_db], time(), null]], $this->_queue);
}

if ($this->_auth) {
if ($this->_auth && ($this->_queue[0][0][0] ?? '') !== 'AUTH') {
$this->_queue = \array_merge([[['AUTH', $this->_auth], time(), null]], $this->_queue);
}

Expand Down Expand Up @@ -541,6 +541,8 @@ public function select($db, $cb = null)
if ($need_suspend) {
[$suspension, $cb] = $this->suspenstion();
}
$cb = $cb ?: function () {
};
$this->_queue[] = [['SELECT', $db], time(), $cb, $format];
$this->process();
if ($need_suspend) {
Expand All @@ -566,6 +568,8 @@ public function auth($auth, $cb = null)
if ($need_suspend) {
[$suspension, $cb] = $this->suspenstion();
}
$cb = $cb ?: function () {
};
$this->_queue[] = [['AUTH', $auth], time(), $cb, $format];
$this->process();
if ($need_suspend) {
Expand Down

0 comments on commit 4e910d4

Please sign in to comment.