attempt to fix a thread bug when starting a game

This commit is contained in:
Mark Vejvoda 2013-06-01 06:28:03 +00:00
parent 7f88d866c1
commit 22eb5cc4d4
3 changed files with 19 additions and 14 deletions

View File

@ -976,22 +976,12 @@ void MenuStateConnectedGame::simpleTask(BaseThread *callingThread) {
Lang &lang= Lang::getInstance();
Config &config = Config::getInstance();
// string fileArchiveExtractCommand = config.getString("FileArchiveExtractCommand","");
// int expectedResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
// bool findArchive = executeShellCommand(fileArchiveExtractCommand,expectedResult);
// if(findArchive == false) {
// mainMessageBoxState = ftpmsg_None;
// mainMessageBox.init(lang.get("Ok"),450);
// showMessageBox(lang.get("ModRequires7z"), lang.get("Notice"), true);
// }
std::string techsMetaData = "";
std::string tilesetsMetaData = "";
std::string mapsMetaData = "";
std::string scenariosMetaData = "";
//modMenuState=mmst_Loading;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(config.getString("Masterserver","") != "") {
@ -1005,6 +995,7 @@ void MenuStateConnectedGame::simpleTask(BaseThread *callingThread) {
CURL *handle = SystemFlags::initHTTP();
CURLcode curlResult = CURLE_OK;
techsMetaData = SystemFlags::getHTTP(baseURL + "showTechsForGlest.php"+phpVersionParam+gameVersion+playerUUID,handle,-1,&curlResult);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("techsMetaData [%s] curlResult = %d\n",techsMetaData.c_str(),curlResult);
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
@ -1167,8 +1158,6 @@ void MenuStateConnectedGame::simpleTask(BaseThread *callingThread) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//modMenuState=mmst_None;
if(modHttpServerThread != NULL) {
modHttpServerThread->signalQuit();
}
@ -2304,6 +2293,8 @@ void MenuStateConnectedGame::returnToJoinMenu() {
if(modHttpServerThread != NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
modHttpServerThread->setSimpleTaskInterfaceValid(false);
modHttpServerThread->signalQuit();
//modHttpServerThread->setThreadOwnerValid(false);
@ -3369,6 +3360,7 @@ void MenuStateConnectedGame::update() {
if(modHttpServerThread != NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
modHttpServerThread->setSimpleTaskInterfaceValid(false);
modHttpServerThread->signalQuit();
//modHttpServerThread->setThreadOwnerValid(false);

View File

@ -117,8 +117,8 @@ public:
void setOverrideShutdownTask(taskFunctionCallback *ptr);
bool getSimpleTaskInterfaceValid() const { return this->simpleTaskInterfaceValid; }
void setSimpleTaskInterfaceValid(bool value) { this->simpleTaskInterfaceValid = value; }
bool getSimpleTaskInterfaceValid();
void setSimpleTaskInterfaceValid(bool value);
};
// =====================================================

View File

@ -427,6 +427,19 @@ bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
return ret;
}
bool SimpleTaskThread::getSimpleTaskInterfaceValid() {
string mutexOwnerId1 = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
return this->simpleTaskInterfaceValid;
}
void SimpleTaskThread::setSimpleTaskInterfaceValid(bool value) {
string mutexOwnerId1 = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex1(&mutexSimpleTaskInterfaceValid,mutexOwnerId1);
this->simpleTaskInterfaceValid = value;
}
void SimpleTaskThread::execute() {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
void *ptr_cpy = this->ptr;