Beispiel #1
0
ClientListener::~ClientListener()
{
	LOG((CLOG_DEBUG1 "stop listening for clients"));

	// discard already connected clients
	for (NewClients::iterator index = m_newClients.begin();
								index != m_newClients.end(); ++index) {
		ClientProxyUnknown* client = *index;
		m_events->removeHandler(
							m_events->forClientProxyUnknown().success(), client);
		m_events->removeHandler(
							m_events->forClientProxyUnknown().failure(), client);
		m_events->removeHandler(
							m_events->forClientProxy().disconnected(), client);
		delete client;
	}

	// discard waiting clients
	ClientProxy* client = getNextClient();
	while (client != NULL) {
		delete client;
		client = getNextClient();
	}

	m_events->removeHandler(m_events->forIListenSocket().connecting(), m_listen);
	cleanupListenSocket();
	delete m_socketFactory;
}
Beispiel #2
0
CClientListener::~CClientListener()
{
    LOG((CLOG_DEBUG1 "stop listening for clients"));

    // discard already connected clients
    for (CNewClients::iterator index = m_newClients.begin();
            index != m_newClients.end(); ++index) {
        CClientProxyUnknown* client = *index;
        EVENTQUEUE->removeHandler(
            CClientProxyUnknown::getSuccessEvent(), client);
        EVENTQUEUE->removeHandler(
            CClientProxyUnknown::getFailureEvent(), client);
        EVENTQUEUE->removeHandler(
            CClientProxy::getDisconnectedEvent(), client);
        delete client;
    }

    // discard waiting clients
    CClientProxy* client = getNextClient();
    while (client != NULL) {
        delete client;
        client = getNextClient();
    }

    EVENTQUEUE->removeHandler(IListenSocket::getConnectingEvent(), m_listen);
    delete m_listen;
    delete m_socketFactory;
    delete m_streamFilterFactory;
}
void TimeSliceThread::run()
{
    int index = 0;

    while (! threadShouldExit())
    {
        int timeToWait = 500;

        {
            Time nextClientTime;

            {
                const ScopedLock sl2 (listLock);

                index = clients.size() > 0 ? ((index + 1) % clients.size()) : 0;

                TimeSliceClient* const firstClient = getNextClient (index);
                if (firstClient != nullptr)
                    nextClientTime = firstClient->nextCallTime;
            }

            const Time now (Time::getCurrentTime());

            if (nextClientTime > now)
            {
                timeToWait = (int) jmin ((int64) 500, (nextClientTime - now).inMilliseconds());
            }
            else
            {
                timeToWait = index == 0 ? 1 : 0;

                const ScopedLock sl (callbackLock);

                {
                    const ScopedLock sl2 (listLock);
                    clientBeingCalled = getNextClient (index);
                }

                if (clientBeingCalled != nullptr)
                {
                    const int msUntilNextCall = clientBeingCalled->useTimeSlice();

                    const ScopedLock sl2 (listLock);

                    if (msUntilNextCall >= 0)
                        clientBeingCalled->nextCallTime += RelativeTime::milliseconds (msUntilNextCall);
                    else
                        clients.removeValue (clientBeingCalled);

                    clientBeingCalled = nullptr;
                }
            }
        }

        if (timeToWait > 0)
            wait (timeToWait);
    }
}
/**
 * Check if any of the clients need servicing.
 * If so, service one client and return.
 * Else, just return.
 */
void
crServerServiceClients(void)
{
    RunQueue *q;

    q = getNextClient(GL_FALSE); /* don't block */
    while (q) 
    {
        ClientStatus stat = crServerServiceClient(q);
        if (stat == CLIENT_NEXT && cr_server.run_queue->next) {
            /* advance to next client */
            cr_server.run_queue = cr_server.run_queue->next;
        }
        q = getNextClient(GL_FALSE);
    }
}
Beispiel #5
0
/**
 * Check if any of the clients need servicing.
 * If so, service one client and return.
 * Else, just return.
 */
void
glStubServiceClients(void)
{
	RunQueue *q;

	q = getNextClient(GL_FALSE); /* don't block */
	if (q) {
		ClientStatus stat = glStubServiceClient(q);
		if (stat == CLIENT_NEXT && cr_server.run_queue->next) {
			/* advance to next client */
			cr_server.run_queue = cr_server.run_queue->next;
		}
	}
	else {
		/* no clients ready, do a receive and maybe we'll get a new
		 * client message
		 */
		crNetRecv();
	}
}