attempt to fix segfaults discovered during testing
This commit is contained in:
parent
24f3a1d6de
commit
7966422582
|
@ -728,7 +728,6 @@ void MainWindow::onClose(wxCloseEvent &event){
|
||||||
if(glCanvas) glCanvas->Destroy();
|
if(glCanvas) glCanvas->Destroy();
|
||||||
glCanvas = NULL;
|
glCanvas = NULL;
|
||||||
|
|
||||||
//delete this;
|
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,9 +248,6 @@ void MainMenu::setState(MenuState *newstate) {
|
||||||
|
|
||||||
//printf("In MainMenu::setState() #1\n");
|
//printf("In MainMenu::setState() #1\n");
|
||||||
|
|
||||||
//delete this->state;
|
|
||||||
//this->state = newstate;
|
|
||||||
|
|
||||||
if(oldstate != NULL && oldstate != newstate) {
|
if(oldstate != NULL && oldstate != newstate) {
|
||||||
MenuState *oldstatePtr = oldstate;
|
MenuState *oldstatePtr = oldstate;
|
||||||
delete oldstate;
|
delete oldstate;
|
||||||
|
|
|
@ -1784,6 +1784,8 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
||||||
MAX_LOOP_COUNT_BEFORE_SLEEP = Config::getInstance().getInt("NetworkServerLoopGameLoadingCap",intToStr(MAX_LOOP_COUNT_BEFORE_SLEEP).c_str());
|
MAX_LOOP_COUNT_BEFORE_SLEEP = Config::getInstance().getInt("NetworkServerLoopGameLoadingCap",intToStr(MAX_LOOP_COUNT_BEFORE_SLEEP).c_str());
|
||||||
int sleepMillis = Config::getInstance().getInt("NetworkServerLoopGameLoadingCapSleepMillis","10");
|
int sleepMillis = Config::getInstance().getInt("NetworkServerLoopGameLoadingCapSleepMillis","10");
|
||||||
|
|
||||||
|
int64 lastStatusUpdate = 0;
|
||||||
|
|
||||||
while(exitServer == false && allReady == false && logger.getCancelLoading() == false) {
|
while(exitServer == false && allReady == false && logger.getCancelLoading() == false) {
|
||||||
waitLoopIterationCount++;
|
waitLoopIterationCount++;
|
||||||
if(waitLoopIterationCount > 0 && waitLoopIterationCount % MAX_LOOP_COUNT_BEFORE_SLEEP == 0) {
|
if(waitLoopIterationCount > 0 && waitLoopIterationCount % MAX_LOOP_COUNT_BEFORE_SLEEP == 0) {
|
||||||
|
@ -1844,7 +1846,10 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(chrono.getMillis() % 100 == 0) {
|
//if(chrono.getMillis() % 100 == 0) {
|
||||||
|
if(chrono.getMillis() - lastStatusUpdate > 200) {
|
||||||
|
lastStatusUpdate = chrono.getMillis();
|
||||||
|
|
||||||
string waitForHosts = "";
|
string waitForHosts = "";
|
||||||
for(int i = 0; i < waitingForHosts.size(); i++) {
|
for(int i = 0; i < waitingForHosts.size(); i++) {
|
||||||
if(waitForHosts != "") {
|
if(waitForHosts != "") {
|
||||||
|
|
|
@ -445,7 +445,6 @@ void MainWindow::onClose(wxCloseEvent &event) {
|
||||||
if(glCanvas) glCanvas->Destroy();
|
if(glCanvas) glCanvas->Destroy();
|
||||||
glCanvas = NULL;
|
glCanvas = NULL;
|
||||||
|
|
||||||
//delete this;
|
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
|
||||||
void BaseThread::deleteSelfIfRequired() {
|
void BaseThread::deleteSelfIfRequired() {
|
||||||
if(getDeleteSelfOnExecutionDone() == true) {
|
if(getDeleteSelfOnExecutionDone() == true) {
|
||||||
if(isThreadDeleted(this->ptr) == false) {
|
if(isThreadDeleted(this->ptr) == false) {
|
||||||
delete this;
|
this->setDeleteAfterExecute(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,7 +495,7 @@ void SimpleTaskThread::execute() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(isThreadDeleted(ptr_cpy) == false) {
|
if(isThreadDeleted(ptr_cpy) == false) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
delete this;
|
this->setDeleteAfterExecute(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ void LogFileThread::execute() {
|
||||||
if(mustDeleteSelf == true) {
|
if(mustDeleteSelf == true) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is deleting self\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is deleting self\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(isThreadDeleted(ptr_cpy) == false) {
|
if(isThreadDeleted(ptr_cpy) == false) {
|
||||||
delete this;
|
this->setDeleteAfterExecute(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -855,7 +855,6 @@ void IRCThread::execute() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In IRCThread() calling delete ...\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In IRCThread() calling delete ...\n");
|
||||||
|
|
||||||
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
|
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
|
||||||
//delete this;
|
|
||||||
setDeleteAfterExecute(true);
|
setDeleteAfterExecute(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1214,7 +1214,6 @@ void FTPClientThread::execute() {
|
||||||
|
|
||||||
// Delete ourself when the thread is done (no other actions can happen after this
|
// Delete ourself when the thread is done (no other actions can happen after this
|
||||||
// such as the mutex which modifies the running status of this method
|
// such as the mutex which modifies the running status of this method
|
||||||
//delete this;
|
|
||||||
deleteSelfIfRequired();
|
deleteSelfIfRequired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ vector<Thread *> Thread::threadList;
|
||||||
auto_ptr<Mutex> Mutex::mutexMutexList(new Mutex(CODE_AT_LINE));
|
auto_ptr<Mutex> Mutex::mutexMutexList(new Mutex(CODE_AT_LINE));
|
||||||
vector<Mutex *> Mutex::mutexList;
|
vector<Mutex *> Mutex::mutexList;
|
||||||
|
|
||||||
class ThreadAutoCleanup : public BaseThread
|
class ThreadGarbageCollector : public BaseThread
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Mutex mutexPendingCleanupList;
|
Mutex mutexPendingCleanupList;
|
||||||
|
@ -48,10 +48,10 @@ protected:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
ThreadAutoCleanup() : BaseThread() {
|
ThreadGarbageCollector() : BaseThread() {
|
||||||
removeThreadFromList();
|
removeThreadFromList();
|
||||||
}
|
}
|
||||||
virtual ~ThreadAutoCleanup() {
|
virtual ~ThreadGarbageCollector() {
|
||||||
//printf("In ~ThreadAutoCleanup Line: %d\n",__LINE__);
|
//printf("In ~ThreadAutoCleanup Line: %d\n",__LINE__);
|
||||||
}
|
}
|
||||||
virtual void execute() {
|
virtual void execute() {
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto_ptr<ThreadAutoCleanup> cleanupThread;
|
static auto_ptr<ThreadGarbageCollector> cleanupThread;
|
||||||
// =====================================
|
// =====================================
|
||||||
// Threads
|
// Threads
|
||||||
// =====================================
|
// =====================================
|
||||||
|
@ -194,7 +194,7 @@ void Thread::queueAutoCleanThread() {
|
||||||
|
|
||||||
if(cleanupThread.get() == NULL) {
|
if(cleanupThread.get() == NULL) {
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
cleanupThread.reset(new ThreadAutoCleanup());
|
cleanupThread.reset(new ThreadGarbageCollector());
|
||||||
cleanupThread->start();
|
cleanupThread->start();
|
||||||
sleep(0);
|
sleep(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue