Fix a connection bug of mariadb clients (#438)

This commit is contained in:
An Tao 2020-05-17 21:08:12 +08:00 committed by GitHub
parent cddd17eb55
commit 26dca0a910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -17,6 +17,7 @@
#include <algorithm>
#include <drogon/utils/Utilities.h>
#include <drogon/utils/string_view.h>
#include <errmsg.h>
#ifndef _WIN32
#include <poll.h>
#endif
@ -442,9 +443,10 @@ void MysqlConnection::execSqlInLoop(
void MysqlConnection::outputError()
{
channelPtr_->disableAll();
LOG_ERROR << "Error(" << mysql_errno(mysqlPtr_.get()) << ") ["
<< mysql_sqlstate(mysqlPtr_.get()) << "] \""
<< mysql_error(mysqlPtr_.get()) << "\"";
auto errorNo = mysql_errno(mysqlPtr_.get());
LOG_ERROR << "Error(" << errorNo << ") [" << mysql_sqlstate(mysqlPtr_.get())
<< "] \"" << mysql_error(mysqlPtr_.get()) << "\"";
if (isWorking_)
{
try
@ -462,6 +464,10 @@ void MysqlConnection::outputError()
isWorking_ = false;
idleCb_();
}
if (errorNo == CR_SERVER_GONE_ERROR)
{
handleClosed();
}
}
void MysqlConnection::getResult(MYSQL_RES *res)