Esempio n. 1
0
void InformationCore::TimeoutSockets()
{
	if(!usepings)
		return;

	/* burlex: this is vulnerable to race conditions, adding a mutex to it. */
	serverSocketLock.Acquire();

	uint32 t = time(NULL);
	// check the ping time
	set<LogonCommServerSocket*>::iterator itr, it2;
	LogonCommServerSocket * s;
	for(itr = m_serverSockets.begin(); itr != m_serverSockets.end();)
	{
		s = *itr;
		it2 = itr;
		++itr;

		if(s->last_ping < t && ((t - s->last_ping) > 60))
		{
			// ping timeout
			printf("Closing socket due to ping timeout.\n");
			s->removed = true;
			set<uint32>::iterator itr = s->server_ids.begin();
			for(; itr != s->server_ids.end(); ++itr)
				RemoveRealm(*itr);
			m_serverSockets.erase(it2);

			s->Disconnect();
		}
	}

	serverSocketLock.Release();
}
Esempio n. 2
0
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();
}
Esempio n. 3
0
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();
}
Esempio n. 4
0
void InformationCore::CheckServers()
{
	serverSocketLock.Acquire();

	set<LogonCommServerSocket*>::iterator itr, it2;
	LogonCommServerSocket * s;
	for(itr = m_serverSockets.begin(); itr != m_serverSockets.end();)
	{
		s = *itr;
		it2 = itr;
		++itr;

		if(!IsServerAllowed(s->GetRemoteAddress().s_addr))
		{
			DEBUG_LOG("LogonServer","Disconnecting socket: %s due to it no longer being on an allowed IP.\n", s->GetIP());
			s->Disconnect();
		}
	}

	serverSocketLock.Release();
}