1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

Sql Keepalive in server zone

This commit is contained in:
Mordred 2017-11-20 23:24:50 +01:00
parent ccf51b909e
commit bd7c2e8b37
3 changed files with 10 additions and 2 deletions

View file

@ -210,7 +210,7 @@ boost::shared_ptr< T > Core::Db::DbWorkerPool< T >::getFreeConnection()
{
connection = m_connections[IDX_SYNCH][i++ % numCons];
if (connection->lockIfReady())
if( connection->lockIfReady() )
break;
}

View file

@ -44,7 +44,8 @@ Core::Db::DbWorkerPool< Core::Db::CharaDbConnection > g_charaDb;
Core::ServerZone::ServerZone( const std::string& configPath )
: m_configPath( configPath ),
m_bRunning( true )
m_bRunning( true ),
m_lastDBPingTime( 0 )
{
m_pConfig = XMLConfigPtr( new XMLConfig );
}
@ -272,6 +273,12 @@ void Core::ServerZone::mainLoop()
}
}
if( currTime - m_lastDBPingTime > 3 )
{
g_charaDb.keepAlive();
m_lastDBPingTime = currTime;
}
auto it = this->m_sessionMap.begin();
for( ; it != this->m_sessionMap.end(); )

View file

@ -51,6 +51,7 @@ namespace Core {
uint16_t m_port;
std::string m_ip;
uint32_t m_lastDBPingTime;
bool m_bRunning;