diff --git a/orm_lib/src/mysql_impl/MysqlConnection.cc b/orm_lib/src/mysql_impl/MysqlConnection.cc index 6ee06db4..ac47e7dc 100644 --- a/orm_lib/src/mysql_impl/MysqlConnection.cc +++ b/orm_lib/src/mysql_impl/MysqlConnection.cc @@ -17,6 +17,7 @@ #include #include #include +#include #ifndef _WIN32 #include #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)