[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ccrtp-devel] Bug in SingleRTPSessionPool::run ?
From: |
Guillaume FRAYSSE |
Subject: |
[Ccrtp-devel] Bug in SingleRTPSessionPool::run ? |
Date: |
Wed, 09 Nov 2005 14:52:34 +0100 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) |
Hello
We've been using ccRTP 1.3.1 here for some time now. As we found it
very CPU intensive to use a thread per session we made some
tests with the SingleRTPSessionPool thread model and found out that it
wasn't working.
Maybe we did something wrong, but after making the following change to
the SingleRTPSessionPool::run method things run much better:
Here's the method after our modifications, I added //GF comments near our
modifications.
Any comments appreciated,
Best Regards,
Guillaume
-------------------------
void
SingleRTPSessionPool::run()
{
#ifndef WIN32
SOCKET so;
while ( isActive() ) {
PoolIterator i = sessionList.begin();
while ( i != sessionList.end() ) {
controlReceptionService(**i);
controlTransmissionService(**i);
i++;
}
timeval timeout = getPoolTimeout();
//GF Reinitialize the fd set
FD_ZERO(&recvSocketSet);
for (PoolIterator j = sessionList.begin(); j !=
sessionList.end (); j++)
{
SOCKET s = getDataRecvSocket(**j);
FD_SET(s,&recvSocketSet);
}
//GF - end
int n = select(highestSocket,&recvSocketSet,NULL,NULL,
&timeout);
i = sessionList.begin();
while ( (i != sessionList.end()) ) {
so = getDataRecvSocket(**i);
if ( FD_ISSET(so,&recvSocketSet) && (n-- > 0)
) {
takeInDataPacket(**i);
}
dispatchDataPacket(**i);
i++;
}
//GF we added that to allow the kernel scheduler to
give other tasks some time as if we have lots of
active sessions the thread cann take all the CPU if we
don't pause at all. We haven't found the best way to
do that yet.
usleep (10);
}
#endif // ndef WIN32
}