Merge pull request #147 from pljones/central-server-logging
Add some logging to the central server
This commit is contained in:
commit
afe5de4c72
2 changed files with 24 additions and 6 deletions
|
@ -36,7 +36,8 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
|
||||||
bCentServPingServerInList ( bNCentServPingServerInList ),
|
bCentServPingServerInList ( bNCentServPingServerInList ),
|
||||||
pConnLessProtocol ( pNConLProt ),
|
pConnLessProtocol ( pNConLProt ),
|
||||||
eSvrRegStatus ( SRS_UNREGISTERED ),
|
eSvrRegStatus ( SRS_UNREGISTERED ),
|
||||||
iSvrRegRetries ( 0 )
|
iSvrRegRetries ( 0 ),
|
||||||
|
tsConsoleStream ( *( ( new ConsoleWriterFactory() )->get() ) )
|
||||||
{
|
{
|
||||||
// set the central server address
|
// set the central server address
|
||||||
SetCentralServerAddress ( sNCentServAddr );
|
SetCentralServerAddress ( sNCentServAddr );
|
||||||
|
@ -307,6 +308,8 @@ void CServerListManager::OnTimerPingServerInList()
|
||||||
|
|
||||||
void CServerListManager::OnTimerPollList()
|
void CServerListManager::OnTimerPollList()
|
||||||
{
|
{
|
||||||
|
CVector<CHostAddress> removals;
|
||||||
|
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
// Check all list entries except of the very first one (which is the central
|
// Check all list entries except of the very first one (which is the central
|
||||||
|
@ -319,6 +322,7 @@ void CServerListManager::OnTimerPollList()
|
||||||
if ( ServerList[iIdx].RegisterTime.elapsed() > ( SERVLIST_TIME_OUT_MINUTES * 60000 ) )
|
if ( ServerList[iIdx].RegisterTime.elapsed() > ( SERVLIST_TIME_OUT_MINUTES * 60000 ) )
|
||||||
{
|
{
|
||||||
// remove this list entry
|
// remove this list entry
|
||||||
|
removals.Add ( ServerList[iIdx].HostAddr );
|
||||||
ServerList.removeAt ( iIdx );
|
ServerList.removeAt ( iIdx );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -327,16 +331,26 @@ void CServerListManager::OnTimerPollList()
|
||||||
iIdx++;
|
iIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
locker.unlock();
|
||||||
|
foreach ( const CHostAddress HostAddr , removals )
|
||||||
|
{
|
||||||
|
tsConsoleStream << "Expired entry for "
|
||||||
|
<< HostAddr.toString() << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerListManager::CentralServerRegisterServer ( const CHostAddress& InetAddr,
|
void CServerListManager::CentralServerRegisterServer ( const CHostAddress& InetAddr,
|
||||||
const CHostAddress& LInetAddr,
|
const CHostAddress& LInetAddr,
|
||||||
const CServerCoreInfo& ServerInfo )
|
const CServerCoreInfo& ServerInfo )
|
||||||
{
|
{
|
||||||
QMutexLocker locker ( &Mutex );
|
|
||||||
|
|
||||||
if ( bIsCentralServer && bEnabled )
|
if ( bIsCentralServer && bEnabled )
|
||||||
{
|
{
|
||||||
|
tsConsoleStream << "Requested to register entry for "
|
||||||
|
<< InetAddr.toString() << " (" << LInetAddr.toString() << ")"
|
||||||
|
<< ": " << ServerInfo.strName << endl;
|
||||||
|
|
||||||
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
const int iCurServerListSize = ServerList.size();
|
const int iCurServerListSize = ServerList.size();
|
||||||
|
|
||||||
// define invalid index used as a flag
|
// define invalid index used as a flag
|
||||||
|
@ -394,10 +408,13 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In
|
||||||
|
|
||||||
void CServerListManager::CentralServerUnregisterServer ( const CHostAddress& InetAddr )
|
void CServerListManager::CentralServerUnregisterServer ( const CHostAddress& InetAddr )
|
||||||
{
|
{
|
||||||
QMutexLocker locker ( &Mutex );
|
|
||||||
|
|
||||||
if ( bIsCentralServer && bEnabled )
|
if ( bIsCentralServer && bEnabled )
|
||||||
{
|
{
|
||||||
|
tsConsoleStream << "Requested to unregister entry for "
|
||||||
|
<< InetAddr.toString() << endl;
|
||||||
|
|
||||||
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
const int iCurServerListSize = ServerList.size();
|
const int iCurServerListSize = ServerList.size();
|
||||||
|
|
||||||
// Find the server to unregister in the list. The very first list entry
|
// Find the server to unregister in the list. The very first list entry
|
||||||
|
@ -587,7 +604,6 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister )
|
||||||
void CServerListManager::SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus )
|
void CServerListManager::SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus )
|
||||||
{
|
{
|
||||||
// output regirstation result/update on the console
|
// output regirstation result/update on the console
|
||||||
QTextStream& tsConsoleStream = *( ( new ConsoleWriterFactory() )->get() );
|
|
||||||
tsConsoleStream << "Server Registration Status update: " << svrRegStatusToString ( eNSvrRegStatus ) << endl;
|
tsConsoleStream << "Server Registration Status update: " << svrRegStatusToString ( eNSvrRegStatus ) << endl;
|
||||||
|
|
||||||
// store the state and inform the GUI about the new status
|
// store the state and inform the GUI about the new status
|
||||||
|
|
|
@ -207,6 +207,8 @@ protected:
|
||||||
// count of registration retries
|
// count of registration retries
|
||||||
int iSvrRegRetries;
|
int iSvrRegRetries;
|
||||||
|
|
||||||
|
QTextStream& tsConsoleStream;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnTimerPollList();
|
void OnTimerPollList();
|
||||||
void OnTimerPingServerInList();
|
void OnTimerPingServerInList();
|
||||||
|
|
Loading…
Reference in a new issue