Bugfix for tracker#: 2985599

- Added better management of UDP broadcast thread when user toggles on/off network slots.
This commit is contained in:
Mark Vejvoda
2010-04-12 21:40:57 +00:00
parent 4e12d8dbcf
commit a5aba5cc66
3 changed files with 31 additions and 2 deletions

View File

@@ -1250,7 +1250,7 @@ void ServerSocket::stopBroadCastThread() {
break;
}
sleep(100);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -1272,6 +1272,16 @@ void ServerSocket::startBroadCastThread() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
bool ServerSocket::isBroadCastThreadRunning() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
bool isThreadRunning = (broadCastThread != NULL && broadCastThread->getRunningStatus() == true);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] isThreadRunning = %d\n",__FILE__,__FUNCTION__,__LINE__,isThreadRunning);
return isThreadRunning;
}
void ServerSocket::bind(int port)
{
//sockaddr structure
@@ -1302,7 +1312,14 @@ void ServerSocket::listen(int connectionQueueSize)
throwException(szBuf);
}
startBroadCastThread();
if(connectionQueueSize > 0) {
if(isBroadCastThreadRunning() == false) {
startBroadCastThread();
}
}
else {
stopBroadCastThread();
}
}