Fix a mysql issue when connections are lost (#525)
This commit is contained in:
parent
43a21ddc9c
commit
dddc62a9fe
|
@ -123,10 +123,6 @@ MysqlConnection::MysqlConnection(trantor::EventLoop *loop,
|
|||
}
|
||||
channelPtr_ =
|
||||
std::unique_ptr<trantor::Channel>(new trantor::Channel(loop_, fd));
|
||||
channelPtr_->setCloseCallback([=]() {
|
||||
perror("sock close");
|
||||
handleClosed();
|
||||
});
|
||||
channelPtr_->setEventCallback([=]() { handleEvent(); });
|
||||
setChannel();
|
||||
});
|
||||
|
@ -549,9 +545,12 @@ void MysqlConnection::outputError()
|
|||
|
||||
callback_ = nullptr;
|
||||
isWorking_ = false;
|
||||
idleCb_();
|
||||
if (errorNo != CR_SERVER_GONE_ERROR && errorNo != CR_SERVER_LOST)
|
||||
{
|
||||
idleCb_();
|
||||
}
|
||||
}
|
||||
if (errorNo == CR_SERVER_GONE_ERROR)
|
||||
if (errorNo == CR_SERVER_GONE_ERROR || errorNo == CR_SERVER_LOST)
|
||||
{
|
||||
handleClosed();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue