- bugfix for segfault in menu when exiting too fast
This commit is contained in:
parent
7399d10247
commit
623623d33f
|
@ -856,6 +856,16 @@ void MenuStateCustomGame::cleanup() {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"In [%s::%s %d] Error cannot shutdown publishToMasterserverThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
||||||
|
|
||||||
|
publishToMasterserverThread->setOverrideShutdownTask(shutdownTaskStatic);
|
||||||
|
//publishToMasterserverThread->cleanup();
|
||||||
|
}
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -865,6 +875,16 @@ void MenuStateCustomGame::cleanup() {
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"In [%s::%s %d] Error cannot shutdown publishToMasterserverThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
||||||
|
|
||||||
|
publishToMasterserverThread->setOverrideShutdownTask(shutdownTaskStatic);
|
||||||
|
//publishToMasterserverThread->cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
|
@ -897,15 +917,6 @@ void MenuStateCustomGame::returnToParentMenu() {
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
lastNetworkPing = time(NULL);
|
lastNetworkPing = time(NULL);
|
||||||
ParentMenuState parentMenuState = this->parentMenuState;
|
ParentMenuState parentMenuState = this->parentMenuState;
|
||||||
/*
|
|
||||||
if(publishToMasterserverThread != NULL &&
|
|
||||||
publishToMasterserverThread->canShutdown() == true &&
|
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
|
||||||
publishToMasterserverThread->setThreadOwnerValid(false);
|
|
||||||
delete publishToMasterserverThread;
|
|
||||||
publishToMasterserverThread = NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -2567,10 +2578,18 @@ void MenuStateCustomGame::publishToMasterserver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::setupTask(BaseThread *callingThread) {
|
void MenuStateCustomGame::setupTask(BaseThread *callingThread) {
|
||||||
|
MenuStateCustomGame::setupTaskStatic(callingThread);
|
||||||
|
}
|
||||||
|
void MenuStateCustomGame::shutdownTask(BaseThread *callingThread) {
|
||||||
|
MenuStateCustomGame::shutdownTaskStatic(callingThread);
|
||||||
|
}
|
||||||
|
void MenuStateCustomGame::setupTaskStatic(BaseThread *callingThread) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
CURL *handle = SystemFlags::initHTTP();
|
CURL *handle = SystemFlags::initHTTP();
|
||||||
callingThread->setGenericData<CURL>(handle);
|
callingThread->setGenericData<CURL>(handle);
|
||||||
}
|
}
|
||||||
void MenuStateCustomGame::shutdownTask(BaseThread *callingThread) {
|
void MenuStateCustomGame::shutdownTaskStatic(BaseThread *callingThread) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
CURL *handle = callingThread->getGenericData<CURL>();
|
CURL *handle = callingThread->getGenericData<CURL>();
|
||||||
SystemFlags::cleanupHTTP(&handle);
|
SystemFlags::cleanupHTTP(&handle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,8 @@ public:
|
||||||
virtual void simpleTask(BaseThread *callingThread);
|
virtual void simpleTask(BaseThread *callingThread);
|
||||||
virtual void setupTask(BaseThread *callingThread);
|
virtual void setupTask(BaseThread *callingThread);
|
||||||
virtual void shutdownTask(BaseThread *callingThread);
|
virtual void shutdownTask(BaseThread *callingThread);
|
||||||
|
static void setupTaskStatic(BaseThread *callingThread);
|
||||||
|
static void shutdownTaskStatic(BaseThread *callingThread);
|
||||||
|
|
||||||
virtual bool isInSpecialKeyCaptureEvent();
|
virtual bool isInSpecialKeyCaptureEvent();
|
||||||
virtual bool isMasterserverMode() const;
|
virtual bool isMasterserverMode() const;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class SimpleTaskThread
|
// class SimpleTaskThread
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
typedef void taskFunctionCallback(BaseThread *callingThread);
|
||||||
//
|
//
|
||||||
// This interface describes the methods a callback object must implement
|
// This interface describes the methods a callback object must implement
|
||||||
//
|
//
|
||||||
|
@ -70,8 +70,8 @@ class SimpleTaskCallbackInterface {
|
||||||
public:
|
public:
|
||||||
virtual void simpleTask(BaseThread *callingThread) = 0;
|
virtual void simpleTask(BaseThread *callingThread) = 0;
|
||||||
|
|
||||||
virtual void setupTask(BaseThread *callingThread) {}
|
virtual void setupTask(BaseThread *callingThread) { }
|
||||||
virtual void shutdownTask(BaseThread *callingThread) {}
|
virtual void shutdownTask(BaseThread *callingThread) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleTaskThread : public BaseThread
|
class SimpleTaskThread : public BaseThread
|
||||||
|
@ -89,6 +89,8 @@ protected:
|
||||||
Mutex mutexLastExecuteTimestamp;
|
Mutex mutexLastExecuteTimestamp;
|
||||||
time_t lastExecuteTimestamp;
|
time_t lastExecuteTimestamp;
|
||||||
|
|
||||||
|
taskFunctionCallback *overrideShutdownTask;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleTaskThread(SimpleTaskCallbackInterface *simpleTaskInterface,
|
SimpleTaskThread(SimpleTaskCallbackInterface *simpleTaskInterface,
|
||||||
unsigned int executionCount=0,
|
unsigned int executionCount=0,
|
||||||
|
@ -103,6 +105,10 @@ public:
|
||||||
bool getTaskSignalled();
|
bool getTaskSignalled();
|
||||||
|
|
||||||
bool isThreadExecutionLagging();
|
bool isThreadExecutionLagging();
|
||||||
|
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
void setOverrideShutdownTask(taskFunctionCallback *ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -296,6 +296,8 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
||||||
this->executionCount = executionCount;
|
this->executionCount = executionCount;
|
||||||
this->millisecsBetweenExecutions = millisecsBetweenExecutions;
|
this->millisecsBetweenExecutions = millisecsBetweenExecutions;
|
||||||
this->needTaskSignal = needTaskSignal;
|
this->needTaskSignal = needTaskSignal;
|
||||||
|
this->overrideShutdownTask = NULL;
|
||||||
|
|
||||||
setTaskSignalled(false);
|
setTaskSignalled(false);
|
||||||
|
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
|
@ -308,10 +310,7 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
||||||
|
|
||||||
SimpleTaskThread::~SimpleTaskThread() {
|
SimpleTaskThread::~SimpleTaskThread() {
|
||||||
try {
|
try {
|
||||||
if(this->simpleTaskInterface != NULL) {
|
cleanup();
|
||||||
this->simpleTaskInterface->shutdownTask(this);
|
|
||||||
this->simpleTaskInterface = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
@ -322,6 +321,21 @@ SimpleTaskThread::~SimpleTaskThread() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleTaskThread::cleanup() {
|
||||||
|
if(this->overrideShutdownTask != NULL) {
|
||||||
|
this->overrideShutdownTask(this);
|
||||||
|
this->overrideShutdownTask = NULL;
|
||||||
|
}
|
||||||
|
else if(this->simpleTaskInterface != NULL) {
|
||||||
|
this->simpleTaskInterface->shutdownTask(this);
|
||||||
|
this->simpleTaskInterface = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimpleTaskThread::setOverrideShutdownTask(taskFunctionCallback *ptr) {
|
||||||
|
this->overrideShutdownTask = ptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool SimpleTaskThread::isThreadExecutionLagging() {
|
bool SimpleTaskThread::isThreadExecutionLagging() {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
|
|
|
@ -155,6 +155,9 @@ std::string SystemFlags::getHTTP(std::string URL,CURL *handle,int timeOut,CURLco
|
||||||
|
|
||||||
/* get contents from the URL */
|
/* get contents from the URL */
|
||||||
CURLcode result = curl_easy_perform(handle);
|
CURLcode result = curl_easy_perform(handle);
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("CURL result = %d\n",result);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("CURL errbuf [%s]\n",errbuf);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] return code [%d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,result,errbuf);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] return code [%d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,result,errbuf);
|
||||||
|
|
||||||
std::string serverResponse = (chunk.memory != NULL ? chunk.memory : "");
|
std::string serverResponse = (chunk.memory != NULL ? chunk.memory : "");
|
||||||
|
|
Loading…
Reference in New Issue