mirror of
https://github.com/glest/glest-source.git
synced 2025-08-23 08:22:50 +02:00
- bug fixes for new thread manager when in game lobby
This commit is contained in:
@@ -877,11 +877,12 @@ bool ServerInterface::signalClientReceiveCommands(ConnectionSlot *connectionSlot
|
||||
void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList,
|
||||
std::map<int,ConnectionSlotEvent> &eventList,
|
||||
std::map<int,bool> & mapSlotSignalledList) {
|
||||
//printf("====================================In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
const bool newThreadManager = Config::getInstance().getBool("EnableNewThreadManager","false");
|
||||
if(newThreadManager == true) {
|
||||
masterController.clearSlaves(true);
|
||||
std::vector<SlaveThreadControllerInterface *> slaveThreadList;
|
||||
for(unsigned int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
|
||||
ConnectionSlot* connectionSlot = slots[i];
|
||||
|
||||
@@ -893,9 +894,6 @@ void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool>
|
||||
socketTriggered = socketTriggeredList[clientSocket];
|
||||
}
|
||||
}
|
||||
ConnectionSlotEvent &event = eventList[i];
|
||||
if(connectionSlot != NULL) {
|
||||
if(socketTriggered == true || connectionSlot->isConnected() == false) {
|
||||
ConnectionSlotEvent &event = eventList[i];
|
||||
event.eventType = eReceiveSocketData;
|
||||
event.networkMessage = NULL;
|
||||
@@ -904,11 +902,15 @@ void ServerInterface::signalClientsToRecieveData(std::map<PLATFORM_SOCKET,bool>
|
||||
event.triggerId = i;
|
||||
event.eventId = getNextEventId();
|
||||
|
||||
if(connectionSlot != NULL) {
|
||||
if(socketTriggered == true || connectionSlot->isConnected() == false) {
|
||||
if(connectionSlot->getWorkerThread() != NULL) {
|
||||
slaveThreadList.push_back(connectionSlot->getWorkerThread());
|
||||
mapSlotSignalledList[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
masterController.setSlaves(slaveThreadList);
|
||||
masterController.signalSlaves(&eventList);
|
||||
}
|
||||
@@ -937,9 +939,13 @@ void ServerInterface::checkForCompletedClients(std::map<int,bool> & mapSlotSigna
|
||||
|
||||
const bool newThreadManager = Config::getInstance().getBool("EnableNewThreadManager","false");
|
||||
if(newThreadManager == true) {
|
||||
bool slavesCompleted = masterController.waitTillSlavesTrigger(1000 * MAX_SLOT_THREAD_WAIT_TIME);
|
||||
|
||||
for(unsigned int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
bool slavesCompleted = masterController.waitTillSlavesTrigger(1000 * MAX_SLOT_THREAD_WAIT_TIME);
|
||||
masterController.clearSlaves(true);
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
|
||||
|
||||
ConnectionSlot* connectionSlot = slots[i];
|
||||
@@ -965,7 +971,7 @@ void ServerInterface::checkForCompletedClients(std::map<int,bool> & mapSlotSigna
|
||||
}
|
||||
}
|
||||
}
|
||||
masterController.clearSlaves(true);
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
else {
|
||||
time_t waitForThreadElapsed = time(NULL);
|
||||
@@ -1030,6 +1036,7 @@ void ServerInterface::checkForLaggingClients(std::map<int,bool> &mapSlotSignalle
|
||||
std::map<PLATFORM_SOCKET,bool> &socketTriggeredList,
|
||||
std::vector <string> &errorMsgList) {
|
||||
bool lastGlobalLagCheckTimeUpdate = false;
|
||||
if(gameHasBeenInitiated == true) {
|
||||
time_t waitForClientsElapsed = time(NULL);
|
||||
time_t waitForThreadElapsed = time(NULL);
|
||||
std::map<int,bool> slotsCompleted;
|
||||
@@ -1144,7 +1151,7 @@ void ServerInterface::checkForLaggingClients(std::map<int,bool> &mapSlotSignalle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(lastGlobalLagCheckTimeUpdate == true) {
|
||||
lastGlobalLagCheckTime = time(NULL);
|
||||
}
|
||||
@@ -1386,18 +1393,21 @@ void ServerInterface::update() {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
// Step #3 check clients for any lagging scenarios and try to deal with them
|
||||
checkForLaggingClients(mapSlotSignalledList, eventList, socketTriggeredList,errorMsgList);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ============ Step #4\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
// Step #4 dispatch network commands to the pending list so that they are done in proper order
|
||||
executeNetworkCommandsFromClients();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ============ Step #5\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
// Step #5 dispatch pending chat messages
|
||||
dispatchPendingChatMessages(errorMsgList);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
@@ -1483,6 +1493,7 @@ void ServerInterface::update() {
|
||||
}
|
||||
}
|
||||
|
||||
//printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
}
|
||||
|
||||
|
@@ -484,6 +484,7 @@ void MasterSlaveThreadController::triggerMaster(int waitMilliseconds) {
|
||||
|
||||
MutexSafeWrapper safeMutex(mutex);
|
||||
if(debugMasterSlaveThreadController) printf("In [%s::%s Line: %d] semVal = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,slaveTriggerCounter);
|
||||
//printf("In [%s::%s Line: %d] semVal = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,slaveTriggerCounter);
|
||||
|
||||
slaveTriggerCounter--;
|
||||
int newCount = slaveTriggerCounter;
|
||||
@@ -492,6 +493,8 @@ void MasterSlaveThreadController::triggerMaster(int waitMilliseconds) {
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
//printf("In [%s::%s Line: %d] semVal = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,slaveTriggerCounter);
|
||||
|
||||
if(newCount <= triggerBaseCount) {
|
||||
slaveTriggerSem->signal();
|
||||
}
|
||||
|
Reference in New Issue
Block a user