mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 07:52:51 +02:00
- bugfixes for connection slot disconnect handling
This commit is contained in:
@@ -89,6 +89,23 @@ void ConnectionSlotThread::setTaskCompleted(int eventId) {
|
|||||||
//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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionSlotThread::purgeAllEvents() {
|
||||||
|
MutexSafeWrapper safeMutex(&triggerIdMutex);
|
||||||
|
eventList.clear();
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionSlotThread::setAllEventsCompleted() {
|
||||||
|
MutexSafeWrapper safeMutex(&triggerIdMutex);
|
||||||
|
for(int i = 0; i < eventList.size(); ++i) {
|
||||||
|
ConnectionSlotEvent &slotEvent = eventList[i];
|
||||||
|
if(slotEvent.eventCompleted == false) {
|
||||||
|
slotEvent.eventCompleted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectionSlotThread::purgeCompletedEvents() {
|
void ConnectionSlotThread::purgeCompletedEvents() {
|
||||||
MutexSafeWrapper safeMutex(&triggerIdMutex);
|
MutexSafeWrapper safeMutex(&triggerIdMutex);
|
||||||
//event->eventCompleted = true;
|
//event->eventCompleted = true;
|
||||||
@@ -158,22 +175,28 @@ void ConnectionSlotThread::execute() {
|
|||||||
MutexSafeWrapper safeMutex(&triggerIdMutex);
|
MutexSafeWrapper safeMutex(&triggerIdMutex);
|
||||||
int eventCount = eventList.size();
|
int eventCount = eventList.size();
|
||||||
if(eventCount > 0) {
|
if(eventCount > 0) {
|
||||||
ConnectionSlotEvent *event = NULL;
|
ConnectionSlotEvent eventCopy;
|
||||||
|
eventCopy.eventId = -1;
|
||||||
|
|
||||||
for(int i = 0; i < eventList.size(); ++i) {
|
for(int i = 0; i < eventList.size(); ++i) {
|
||||||
ConnectionSlotEvent &slotEvent = eventList[i];
|
ConnectionSlotEvent &slotEvent = eventList[i];
|
||||||
if(slotEvent.eventCompleted == false) {
|
if(slotEvent.eventCompleted == false) {
|
||||||
event = &slotEvent;
|
eventCopy = slotEvent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
if(event != NULL) {
|
if(getQuitStatus() == true) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(eventCopy.eventId > 0) {
|
||||||
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
|
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
|
||||||
this->slotInterface->slotUpdateTask(event);
|
this->slotInterface->slotUpdateTask(&eventCopy);
|
||||||
setTaskCompleted(event->eventId);
|
setTaskCompleted(eventCopy.eventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -298,6 +321,12 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
|||||||
this->gotLagCountWarning = false;
|
this->gotLagCountWarning = false;
|
||||||
this->versionString = "";
|
this->versionString = "";
|
||||||
|
|
||||||
|
//if(this->slotThreadWorker == NULL) {
|
||||||
|
// this->slotThreadWorker = new ConnectionSlotThread(this->serverInterface,playerIndex);
|
||||||
|
// this->slotThreadWorker->setUniqueID(__FILE__);
|
||||||
|
// this->slotThreadWorker->start();
|
||||||
|
//}
|
||||||
|
|
||||||
serverInterface->updateListen();
|
serverInterface->updateListen();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex);
|
||||||
}
|
}
|
||||||
@@ -734,12 +763,11 @@ void ConnectionSlot::validateConnection() {
|
|||||||
void ConnectionSlot::close() {
|
void ConnectionSlot::close() {
|
||||||
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__);
|
||||||
|
|
||||||
if(BaseThread::shutdownAndWait(slotThreadWorker) == true) {
|
if(this->slotThreadWorker != NULL) {
|
||||||
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__);
|
||||||
delete slotThreadWorker;
|
this->slotThreadWorker->setAllEventsCompleted();
|
||||||
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__);
|
||||||
}
|
}
|
||||||
slotThreadWorker = NULL;
|
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
@@ -770,9 +798,10 @@ Mutex * ConnectionSlot::getServerSynchAccessor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionSlot::signalUpdate(ConnectionSlotEvent *event) {
|
void ConnectionSlot::signalUpdate(ConnectionSlotEvent *event) {
|
||||||
assert(slotThreadWorker != NULL);
|
//assert(slotThreadWorker != NULL);
|
||||||
|
if(slotThreadWorker != NULL) {
|
||||||
slotThreadWorker->signalUpdate(event);
|
slotThreadWorker->signalUpdate(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnectionSlot::updateCompleted(ConnectionSlotEvent *event) {
|
bool ConnectionSlot::updateCompleted(ConnectionSlotEvent *event) {
|
||||||
|
@@ -92,6 +92,8 @@ public:
|
|||||||
int getSlotIndex() const {return slotIndex; }
|
int getSlotIndex() const {return slotIndex; }
|
||||||
|
|
||||||
void purgeCompletedEvents();
|
void purgeCompletedEvents();
|
||||||
|
void purgeAllEvents();
|
||||||
|
void setAllEventsCompleted();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
Reference in New Issue
Block a user