void InformationCore::TimeoutSockets() { if(!usepings) return; /* burlex: this is vulnerable to race conditions, adding a mutex to it. */ serverSocketLock.Acquire(); // check the ping time uint32 t = uint32(time(NULL)); set<LogonCommServerSocket*>::iterator itr, it2; LogonCommServerSocket * s; for(itr = m_serverSockets.begin(); itr != m_serverSockets.end();) { s = *itr; it2 = itr; ++itr; if(!s->removed && (t - s->last_ping) > 40) { // ping timeout s->removed = true; set<uint32>::iterator idItr = s->server_ids.begin(); for(; idItr != s->server_ids.end(); ++idItr) SetRealmOffline(*idItr, s); m_serverSockets.erase(it2); s->Disconnect(); continue;; } } serverSocketLock.Release(); }
void InformationCore::TimeoutSockets() { if(!usepings) return; uint32 now = uint32(time(NULL)); /* burlex: this is vulnerable to race conditions, adding a mutex to it. */ serverSocketLock.Acquire(); for(std::set< LogonCommServerSocket* >::iterator itr = m_serverSockets.begin(); itr != m_serverSockets.end();) { LogonCommServerSocket* s = *itr; ++itr; uint32 last_ping = s->last_ping.GetVal(); if(last_ping < now && ((now - last_ping) > 300)) { for(std::set< uint32 >::iterator RealmITR = s->server_ids.begin(); RealmITR != s->server_ids.end(); ++RealmITR) { uint32 RealmID = *RealmITR; SetRealmOffline(RealmID); } s->removed = true; m_serverSockets.erase(s); s->Disconnect(); } } serverSocketLock.Release(); }