modify plugin name
This commit is contained in:
+16
-7
@@ -20,6 +20,7 @@ use Exception;
|
|||||||
use Kiri;
|
use Kiri;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
|
use Kiri\Context;
|
||||||
use Kiri\Exception\NotFindClassException;
|
use Kiri\Exception\NotFindClassException;
|
||||||
use Kiri\Server\Events\OnWorkerExit;
|
use Kiri\Server\Events\OnWorkerExit;
|
||||||
use Kiri\Server\Events\OnWorkerStop;
|
use Kiri\Server\Events\OnWorkerStop;
|
||||||
@@ -159,10 +160,7 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function slaveInstance(): PDO
|
public function slaveInstance(): PDO
|
||||||
{
|
{
|
||||||
if (empty($this->slaveConfig) || Db::transactionsActive()) {
|
if (empty($this->slaveConfig) || $this->slaveConfig['cds'] == $this->cds) {
|
||||||
return $this->masterInstance();
|
|
||||||
}
|
|
||||||
if ($this->slaveConfig['cds'] == $this->cds) {
|
|
||||||
return $this->masterInstance();
|
return $this->masterInstance();
|
||||||
}
|
}
|
||||||
return $this->connections()->get($this->slaveConfig);
|
return $this->connections()->get($this->slaveConfig);
|
||||||
@@ -205,7 +203,11 @@ class Connection extends Component
|
|||||||
public function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
$this->connections()->rollback($this->cds);
|
$this->connections()->rollback($this->cds);
|
||||||
$this->release();
|
$pdo = Context::getContext($this->cds);
|
||||||
|
Context::remove($this->cds);
|
||||||
|
if ($pdo instanceof PDO) {
|
||||||
|
$this->release($pdo, $this->cds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,7 +217,11 @@ class Connection extends Component
|
|||||||
public function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
$this->connections()->commit($this->cds);
|
$this->connections()->commit($this->cds);
|
||||||
$this->release();
|
$pdo = Context::getContext($this->cds);
|
||||||
|
Context::remove($this->cds);
|
||||||
|
if ($pdo instanceof PDO) {
|
||||||
|
$this->release($pdo, $this->cds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,9 +243,12 @@ class Connection extends Component
|
|||||||
* 回收链接
|
* 回收链接
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function release($pdo, $isMaster)
|
public function release(PDO $pdo, $isMaster)
|
||||||
{
|
{
|
||||||
$connections = $this->connections();
|
$connections = $this->connections();
|
||||||
|
if ($pdo->inTransaction()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$isMaster) {
|
if (!$isMaster) {
|
||||||
if (empty($this->slaveConfig) || !isset($this->slaveConfig['cds'])) {
|
if (empty($this->slaveConfig) || !isset($this->slaveConfig['cds'])) {
|
||||||
$this->slaveConfig['cds'] = $this->cds;
|
$this->slaveConfig['cds'] = $this->cds;
|
||||||
|
|||||||
Reference in New Issue
Block a user