mirror of
https://github.com/glest/glest-source.git
synced 2025-08-25 17:20:43 +02:00
- numerous thread bugfixes related to menu stability and ftp server socket usage
This commit is contained in:
@@ -160,9 +160,13 @@ void MainMenu::keyPress(char c){
|
|||||||
state->keyPress(c);
|
state->keyPress(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenu::setState(MenuState *state){
|
void MainMenu::setState(MenuState *newstate) {
|
||||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
printf("In [%s::%s Line: %d] oldstate [%p] newstate [%p] this->state [%p]\n",__FILE__,__FUNCTION__,__LINE__,oldstate,newstate,this->state);
|
||||||
if(oldstate != NULL && oldstate != state) {
|
|
||||||
|
//delete this->state;
|
||||||
|
//this->state = newstate;
|
||||||
|
|
||||||
|
if(oldstate != NULL && oldstate != newstate) {
|
||||||
delete oldstate;
|
delete oldstate;
|
||||||
|
|
||||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -180,9 +184,10 @@ void MainMenu::setState(MenuState *state){
|
|||||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
this->state= state;
|
this->state= newstate;
|
||||||
|
|
||||||
GraphicComponent::resetFade();
|
GraphicComponent::resetFade();
|
||||||
menuBackground.setTargetCamera(state->getCamera());
|
menuBackground.setTargetCamera(newstate->getCamera());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainMenu::isInSpecialKeyCaptureEvent() {
|
bool MainMenu::isInSpecialKeyCaptureEvent() {
|
||||||
|
@@ -518,23 +518,34 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuStateCustomGame::~MenuStateCustomGame() {
|
void MenuStateCustomGame::cleanup() {
|
||||||
|
//printf("IN MenuStateCustomGame cleanup - A\n");
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(publishToMasterserverThread != NULL) {
|
if(publishToMasterserverThread != NULL) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(publishToMasterserverThread != NULL &&
|
//printf("IN MenuStateCustomGame cleanup - B\n");
|
||||||
publishToMasterserverThread->canShutdown(true) == true &&
|
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
delete publishToMasterserverThread;
|
|
||||||
}
|
|
||||||
publishToMasterserverThread = NULL;
|
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
|
lastNetworkPing = time(NULL);
|
||||||
|
publishToMasterserverThread->setThreadOwnerValid(false);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
if(publishToMasterserverThread->canShutdown(true) == true &&
|
||||||
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
|
//printf("IN MenuStateCustomGame cleanup - C\n");
|
||||||
|
delete publishToMasterserverThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("IN MenuStateCustomGame cleanup - D\n");
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("IN MenuStateCustomGame cleanup - E\n");
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
cleanupFactionTexture();
|
cleanupFactionTexture();
|
||||||
cleanupMapPreviewTexture();
|
cleanupMapPreviewTexture();
|
||||||
@@ -542,28 +553,42 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuStateCustomGame::~MenuStateCustomGame() {
|
||||||
|
//printf("IN MenuStateCustomGame Destructor - A\n");
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::returnToParentMenu() {
|
void MenuStateCustomGame::returnToParentMenu() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
|
lastNetworkPing = time(NULL);
|
||||||
bool returnToMasterServerMenu = parentMenuIsMs;
|
bool returnToMasterServerMenu = parentMenuIsMs;
|
||||||
|
|
||||||
|
/*
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->canShutdown() == true &&
|
publishToMasterserverThread->canShutdown() == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
|
publishToMasterserverThread->setThreadOwnerValid(false);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(returnToMasterServerMenu) {
|
if(returnToMasterServerMenu) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
cleanup();
|
||||||
mainMenu->setState(new MenuStateMasterserver(program, mainMenu));
|
mainMenu->setState(new MenuStateMasterserver(program, mainMenu));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
cleanup();
|
||||||
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,17 +621,18 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
|
lastNetworkPing = time(NULL);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
/*
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->canShutdown() == true &&
|
publishToMasterserverThread->canShutdown() == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
|
publishToMasterserverThread->setThreadOwnerValid(false);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//publishToMasterserverThreadInDeletion = false;
|
|
||||||
//safeMutexPtr.ReleaseLock();
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
@@ -1091,20 +1117,24 @@ void MenuStateCustomGame::PlayNow() {
|
|||||||
}
|
}
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
|
lastNetworkPing = time(NULL);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
/*
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->canShutdown() == true &&
|
publishToMasterserverThread->canShutdown() == true &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
|
publishToMasterserverThread->setThreadOwnerValid(false);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
assert(program != NULL);
|
assert(program != NULL);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
cleanup();
|
||||||
program->setState(new Game(program, &gameSettings));
|
program->setState(new Game(program, &gameSettings));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1795,10 +1825,15 @@ void MenuStateCustomGame::publishToMasterserver()
|
|||||||
void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(callingThread->getQuitStatus() == true) {
|
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - A\n");
|
||||||
|
|
||||||
|
MutexSafeWrapper safeMutexThreadOwner(callingThread->getMutexThreadOwnerValid());
|
||||||
|
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - B\n");
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor());
|
MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor());
|
||||||
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0);
|
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0);
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
@@ -1807,19 +1842,22 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
|||||||
bool broadCastSettings = needToBroadcastServerSettings;
|
bool broadCastSettings = needToBroadcastServerSettings;
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
bool hasClientConnection = false;
|
bool hasClientConnection = false;
|
||||||
|
|
||||||
if(broadCastSettings == true) {
|
if(broadCastSettings == true) {
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface *serverInterface = NetworkManager::getInstance().getServerInterface(false);
|
||||||
hasClientConnection = serverInterface->hasClientConnection();
|
if(serverInterface != NULL) {
|
||||||
|
hasClientConnection = serverInterface->hasClientConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(callingThread->getQuitStatus() == true) {
|
if(callingThread->getQuitStatus() == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - C\n");
|
||||||
|
|
||||||
if(republish == true) {
|
if(republish == true) {
|
||||||
safeMutex.Lock();
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?";
|
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?";
|
||||||
@@ -1837,66 +1875,85 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
|||||||
//printf("the request is:\n%s\n",request.c_str());
|
//printf("the request is:\n%s\n",request.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the request is:\n%s\n",__FILE__,__FUNCTION__,__LINE__,request.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the request is:\n%s\n",__FILE__,__FUNCTION__,__LINE__,request.c_str());
|
||||||
safeMutex.ReleaseLock(true);
|
safeMutex.ReleaseLock(true);
|
||||||
|
safeMutexThreadOwner.ReleaseLock();
|
||||||
|
|
||||||
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
||||||
SystemFlags::cleanupHTTP(&handle);
|
SystemFlags::cleanupHTTP(&handle);
|
||||||
|
|
||||||
if(callingThread->getQuitStatus() == true) {
|
MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid());
|
||||||
|
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner2.isValidMutex() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
safeMutex.Lock();
|
safeMutex.Lock();
|
||||||
|
|
||||||
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
||||||
|
|
||||||
// uncomment to enable router setup check of this server
|
// uncomment to enable router setup check of this server
|
||||||
if(EndsWith(serverInfo, "OK") == false) {
|
if(EndsWith(serverInfo, "OK") == false) {
|
||||||
|
if(callingThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showMasterserverError=true;
|
showMasterserverError=true;
|
||||||
masterServererErrorToShow = (serverInfo != "" ? serverInfo : "No Reply");
|
masterServererErrorToShow = (serverInfo != "" ? serverInfo : "No Reply");
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock(true);
|
}
|
||||||
|
else {
|
||||||
|
safeMutexThreadOwner.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(callingThread->getQuitStatus() == true) {
|
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - D\n");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(broadCastSettings == true) {
|
if(broadCastSettings == true) {
|
||||||
safeMutex.Lock();
|
MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid());
|
||||||
|
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner2.isValidMutex() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
serverInterface->setGameSettings(&gameSettings,false);
|
|
||||||
|
|
||||||
if(hasClientConnection == true) {
|
if(callingThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ServerInterface *serverInterface= NetworkManager::getInstance().getServerInterface(false);
|
||||||
|
if(serverInterface != NULL) {
|
||||||
|
serverInterface->setGameSettings(&gameSettings,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasClientConnection == true && serverInterface != NULL) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
serverInterface->broadcastGameSetup(&gameSettings);
|
serverInterface->broadcastGameSetup(&gameSettings);
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(callingThread->getQuitStatus() == true) {
|
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - E\n");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
if(needPing == true) {
|
if(needPing == true) {
|
||||||
|
MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid());
|
||||||
|
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner2.isValidMutex() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lastNetworkPing = time(NULL);
|
lastNetworkPing = time(NULL);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] Sending nmtPing to clients\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] Sending nmtPing to clients\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
NetworkMessagePing msg(GameConstants::networkPingInterval,time(NULL));
|
|
||||||
|
|
||||||
serverInterface->broadcastPing(&msg);
|
ServerInterface *serverInterface= NetworkManager::getInstance().getServerInterface(false);
|
||||||
|
if(serverInterface != NULL) {
|
||||||
|
NetworkMessagePing msg(GameConstants::networkPingInterval,time(NULL));
|
||||||
|
serverInterface->broadcastPing(&msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
//printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - F\n");
|
||||||
}
|
}
|
||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
|
@@ -145,7 +145,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false, bool autostart=false);
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false, bool autostart=false);
|
||||||
~MenuStateCustomGame();
|
virtual ~MenuStateCustomGame();
|
||||||
|
|
||||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
@@ -191,6 +191,7 @@ private:
|
|||||||
void PlayNow();
|
void PlayNow();
|
||||||
|
|
||||||
void SetActivePlayerNameEditor();
|
void SetActivePlayerNameEditor();
|
||||||
|
void cleanup();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -300,13 +300,15 @@ void MenuStateMasterserver::cleanup() {
|
|||||||
|
|
||||||
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL));
|
||||||
needUpdateFromServer = false;
|
needUpdateFromServer = false;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(updateFromMasterserverThread != NULL &&
|
if(updateFromMasterserverThread != NULL &&
|
||||||
updateFromMasterserverThread->canShutdown(true) == true &&
|
updateFromMasterserverThread->canShutdown(true) == true) {
|
||||||
updateFromMasterserverThread->shutdownAndWait() == true) {
|
if(updateFromMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete updateFromMasterserverThread;
|
delete updateFromMasterserverThread;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateFromMasterserverThread = NULL;
|
updateFromMasterserverThread = NULL;
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ const int ClientInterface::messageWaitTimeout= 10000; //10 seconds
|
|||||||
const int ClientInterface::waitSleepTime= 10;
|
const int ClientInterface::waitSleepTime= 10;
|
||||||
const int ClientInterface::maxNetworkCommandListSendTimeWait = 4;
|
const int ClientInterface::maxNetworkCommandListSendTimeWait = 4;
|
||||||
|
|
||||||
ClientInterface::ClientInterface() {
|
ClientInterface::ClientInterface() : GameNetworkInterface() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] constructor for %p\n",__FILE__,__FUNCTION__,__LINE__,this);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] constructor for %p\n",__FILE__,__FUNCTION__,__LINE__,this);
|
||||||
|
|
||||||
clientSocket= NULL;
|
clientSocket= NULL;
|
||||||
|
@@ -27,83 +27,108 @@ NetworkManager &NetworkManager::getInstance(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::NetworkManager() {
|
NetworkManager::NetworkManager() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
|
|
||||||
gameNetworkInterface= NULL;
|
gameNetworkInterface= NULL;
|
||||||
networkRole= nrIdle;
|
networkRole= nrIdle;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::init(NetworkRole networkRole) {
|
void NetworkManager::init(NetworkRole networkRole) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
||||||
|
|
||||||
assert(gameNetworkInterface==NULL);
|
assert(gameNetworkInterface==NULL);
|
||||||
|
|
||||||
this->networkRole = networkRole;
|
this->networkRole = networkRole;
|
||||||
|
|
||||||
if(networkRole==nrServer){
|
if(networkRole == nrServer) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
||||||
gameNetworkInterface = new ServerInterface();
|
gameNetworkInterface = new ServerInterface();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d, networkRole = %d, gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,networkRole,gameNetworkInterface);
|
||||||
gameNetworkInterface = new ClientInterface();
|
gameNetworkInterface = new ClientInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
//printf("==========] CREATING gameNetworkInterface [%p]\n",gameNetworkInterface);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::end() {
|
void NetworkManager::end() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
|
|
||||||
|
//printf("==========] DELETING gameNetworkInterface [%p]\n",gameNetworkInterface);
|
||||||
|
|
||||||
delete gameNetworkInterface;
|
delete gameNetworkInterface;
|
||||||
gameNetworkInterface= NULL;
|
gameNetworkInterface= NULL;
|
||||||
networkRole= nrIdle;
|
networkRole= nrIdle;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::update(){
|
void NetworkManager::update() {
|
||||||
if(gameNetworkInterface!=NULL){
|
if(gameNetworkInterface!=NULL) {
|
||||||
gameNetworkInterface->update();
|
gameNetworkInterface->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkManager::isNetworkGame(){
|
bool NetworkManager::isNetworkGame() {
|
||||||
return networkRole==nrClient || getServerInterface()->getConnectedSlotCount()>0;
|
return networkRole==nrClient || getServerInterface()->getConnectedSlotCount()>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameNetworkInterface* NetworkManager::getGameNetworkInterface(){
|
GameNetworkInterface* NetworkManager::getGameNetworkInterface(bool throwErrorOnNull) {
|
||||||
assert(gameNetworkInterface!=NULL);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
if(gameNetworkInterface==NULL) {
|
//printf("==========] GET gameNetworkInterface [%p]\n",gameNetworkInterface);
|
||||||
throw runtime_error("gameNetworkInterface==NULL");
|
|
||||||
}
|
if(throwErrorOnNull) {
|
||||||
|
assert(gameNetworkInterface!=NULL);
|
||||||
|
|
||||||
|
if(gameNetworkInterface==NULL) {
|
||||||
|
throw runtime_error("gameNetworkInterface==NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
return gameNetworkInterface;
|
return gameNetworkInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInterface* NetworkManager::getServerInterface(){
|
ServerInterface* NetworkManager::getServerInterface(bool throwErrorOnNull) {
|
||||||
assert(gameNetworkInterface!=NULL);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
if(gameNetworkInterface==NULL) {
|
//printf("==========] GET gameNetworkInterface (server) [%p]\n",gameNetworkInterface);
|
||||||
throw runtime_error("gameNetworkInterface==NULL");
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(networkRole==nrServer);
|
if(throwErrorOnNull) {
|
||||||
if(networkRole!=nrServer) {
|
assert(gameNetworkInterface!=NULL);
|
||||||
throw runtime_error("networkRole!=nrServer");
|
if(gameNetworkInterface==NULL) {
|
||||||
}
|
throw runtime_error("gameNetworkInterface==NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(networkRole==nrServer);
|
||||||
|
if(networkRole!=nrServer) {
|
||||||
|
throw runtime_error("networkRole!=nrServer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
||||||
return dynamic_cast<ServerInterface*>(gameNetworkInterface);
|
return dynamic_cast<ServerInterface*>(gameNetworkInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientInterface* NetworkManager::getClientInterface(){
|
ClientInterface* NetworkManager::getClientInterface(bool throwErrorOnNull) {
|
||||||
assert(gameNetworkInterface!=NULL);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] this->networkRole = %d gameNetworkInterface [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole,gameNetworkInterface);
|
||||||
if(gameNetworkInterface==NULL) {
|
//printf("==========] GET gameNetworkInterface (client) [%p]\n",gameNetworkInterface);
|
||||||
throw runtime_error("gameNetworkInterface==NULL");
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(networkRole==nrClient);
|
if(throwErrorOnNull) {
|
||||||
if(networkRole!=nrClient) {
|
assert(gameNetworkInterface!=NULL);
|
||||||
throw runtime_error("networkRole!=nrClient");
|
if(gameNetworkInterface==NULL) {
|
||||||
}
|
throw runtime_error("gameNetworkInterface==NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(networkRole==nrClient);
|
||||||
|
if(networkRole!=nrClient) {
|
||||||
|
throw runtime_error("networkRole!=nrClient");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d this->networkRole = %d\n",__FILE__,__FUNCTION__,__LINE__,this->networkRole);
|
||||||
|
|
||||||
return dynamic_cast<ClientInterface*>(gameNetworkInterface);
|
return dynamic_cast<ClientInterface*>(gameNetworkInterface);
|
||||||
}
|
}
|
||||||
|
@@ -42,9 +42,9 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
bool isNetworkGame();
|
bool isNetworkGame();
|
||||||
GameNetworkInterface* getGameNetworkInterface();
|
GameNetworkInterface* getGameNetworkInterface(bool throwErrorOnNull=true);
|
||||||
ServerInterface* getServerInterface();
|
ServerInterface* getServerInterface(bool throwErrorOnNull=true);
|
||||||
ClientInterface* getClientInterface();
|
ClientInterface* getClientInterface(bool throwErrorOnNull=true);
|
||||||
NetworkRole getNetworkRole() { return networkRole; }
|
NetworkRole getNetworkRole() { return networkRole; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -60,7 +60,8 @@ double LAG_CHECK_GRACE_PERIOD = 15;
|
|||||||
// badly and we want to give time for them to catch up
|
// badly and we want to give time for them to catch up
|
||||||
double MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE = 1;
|
double MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE = 1;
|
||||||
|
|
||||||
ServerInterface::ServerInterface() {
|
ServerInterface::ServerInterface() : GameNetworkInterface() {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
gameHasBeenInitiated = false;
|
gameHasBeenInitiated = false;
|
||||||
gameSettingsUpdateCount = 0;
|
gameSettingsUpdateCount = 0;
|
||||||
currentFrameCount = 0;
|
currentFrameCount = 0;
|
||||||
@@ -82,10 +83,13 @@ ServerInterface::ServerInterface() {
|
|||||||
slots[i]= NULL;
|
slots[i]= NULL;
|
||||||
switchSetupRequests[i]= NULL;
|
switchSetupRequests[i]= NULL;
|
||||||
}
|
}
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
serverSocket.setBlock(false);
|
serverSocket.setBlock(false);
|
||||||
//serverSocket.bind(Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str()));
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
serverSocket.setBindPort(Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str()));
|
serverSocket.setBindPort(Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str()));
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(Config::getInstance().getBool("EnableFTPXfer","false") == true) {
|
if(Config::getInstance().getBool("EnableFTPXfer","false") == true) {
|
||||||
std::pair<string,string> mapsPath;
|
std::pair<string,string> mapsPath;
|
||||||
vector<string> pathList = Config::getInstance().getPathListForType(ptMaps);
|
vector<string> pathList = Config::getInstance().getPathListForType(ptMaps);
|
||||||
@@ -105,11 +109,13 @@ ServerInterface::ServerInterface() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
int portNumber = Config::getInstance().getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
|
int portNumber = Config::getInstance().getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
|
||||||
ServerSocket::setFTPServerPort(portNumber);
|
ServerSocket::setFTPServerPort(portNumber);
|
||||||
ftpServer = new FTPServerThread(mapsPath,tilesetsPath,portNumber);
|
ftpServer = new FTPServerThread(mapsPath,tilesetsPath,portNumber);
|
||||||
ftpServer->start();
|
ftpServer->start();
|
||||||
}
|
}
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInterface::~ServerInterface() {
|
ServerInterface::~ServerInterface() {
|
||||||
|
@@ -35,6 +35,9 @@ protected:
|
|||||||
|
|
||||||
Mutex mutexThreadObjectAccessor;
|
Mutex mutexThreadObjectAccessor;
|
||||||
|
|
||||||
|
bool threadOwnerValid;
|
||||||
|
Mutex mutexThreadOwnerValid;
|
||||||
|
|
||||||
Mutex mutexExecutingTask;
|
Mutex mutexExecutingTask;
|
||||||
bool executingTask;
|
bool executingTask;
|
||||||
|
|
||||||
@@ -74,6 +77,11 @@ public:
|
|||||||
void setExecutingTask(bool value);
|
void setExecutingTask(bool value);
|
||||||
bool getExecutingTask();
|
bool getExecutingTask();
|
||||||
|
|
||||||
|
|
||||||
|
void setThreadOwnerValid(bool value);
|
||||||
|
bool getThreadOwnerValid();
|
||||||
|
Mutex * getMutexThreadOwnerValid();
|
||||||
|
|
||||||
Mutex * getMutexThreadObjectAccessor() { return &mutexThreadObjectAccessor; }
|
Mutex * getMutexThreadObjectAccessor() { return &mutexThreadObjectAccessor; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -91,6 +91,9 @@ public:
|
|||||||
this->ownerId = ownerId;
|
this->ownerId = ownerId;
|
||||||
Lock();
|
Lock();
|
||||||
}
|
}
|
||||||
|
bool isValidMutex() const {
|
||||||
|
return(this->mutex != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void Lock() {
|
void Lock() {
|
||||||
if(this->mutex != NULL) {
|
if(this->mutex != NULL) {
|
||||||
|
@@ -674,14 +674,13 @@ LOCAL int ftpCmdPasv(int sessionId, const char* args, int len)
|
|||||||
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPasv sessionId = %d, client IP = %u, remote IP = %u, port = %d, ftpAddUPNPPortForward = %p, ftpRemoveUPNPPortForward = %p\n",
|
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPasv sessionId = %d, client IP = %u, remote IP = %u, port = %d, ftpAddUPNPPortForward = %p, ftpRemoveUPNPPortForward = %p\n",
|
||||||
sessionId, ftpGetSession(sessionId)->remoteIp, ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp), port,ftpAddUPNPPortForward,ftpRemoveUPNPPortForward);
|
sessionId, ftpGetSession(sessionId)->remoteIp, ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp), port,ftpAddUPNPPortForward,ftpRemoveUPNPPortForward);
|
||||||
|
|
||||||
if(ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp) != 0)
|
if(ftpAddUPNPPortForward != NULL && ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp) != 0)
|
||||||
{
|
{
|
||||||
ftpGetSession(sessionId)->remoteFTPServerPassivePort = port;
|
ftpGetSession(sessionId)->remoteFTPServerPassivePort = port;
|
||||||
if(ftpAddUPNPPortForward) {
|
|
||||||
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPasv sessionId = %d, adding UPNP port forward\n", sessionId);
|
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPasv sessionId = %d, adding UPNP port forward\n", sessionId);
|
||||||
|
|
||||||
ftpAddUPNPPortForward(port, port);
|
ftpAddUPNPPortForward(port, port);
|
||||||
}
|
|
||||||
|
|
||||||
remoteFTPServerIp = ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp);
|
remoteFTPServerIp = ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp);
|
||||||
|
|
||||||
|
@@ -205,8 +205,8 @@ int ftpShutdown(void)
|
|||||||
if(ftpGetSession(n)->open)
|
if(ftpGetSession(n)->open)
|
||||||
{
|
{
|
||||||
ftpUntrackSocket(ftpGetSession(n)->ctrlSocket);
|
ftpUntrackSocket(ftpGetSession(n)->ctrlSocket);
|
||||||
ftpCloseSession(n);
|
|
||||||
}
|
}
|
||||||
|
ftpCloseSession(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
ftpArchCleanup();
|
ftpArchCleanup();
|
||||||
|
@@ -129,11 +129,15 @@ if(VERBOSE_MODE_ENABLED) printf("In ftpCloseSession sessionId = %d, remote IP =
|
|||||||
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPasv sessionId = %d, removing UPNP port forward [%d]\n", id,sessions[id].remoteFTPServerPassivePort);
|
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPasv sessionId = %d, removing UPNP port forward [%d]\n", id,sessions[id].remoteFTPServerPassivePort);
|
||||||
|
|
||||||
ftpRemoveUPNPPortForward(sessions[id].remoteFTPServerPassivePort, sessions[id].remoteFTPServerPassivePort);
|
ftpRemoveUPNPPortForward(sessions[id].remoteFTPServerPassivePort, sessions[id].remoteFTPServerPassivePort);
|
||||||
|
sessions[id].remoteFTPServerPassivePort = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ftpCloseSocket(sessions[id].ctrlSocket);
|
if(sessions[id].open) {
|
||||||
ftpCloseTransmission(id);
|
ftpCloseSocket(sessions[id].ctrlSocket);
|
||||||
|
ftpCloseTransmission(id);
|
||||||
|
}
|
||||||
|
sessions[id].remoteIp = 0;
|
||||||
|
sessions[id].ctrlSocket = 0;
|
||||||
sessions[id].open = FALSE;
|
sessions[id].open = FALSE;
|
||||||
|
|
||||||
if(VERBOSE_MODE_ENABLED) printf("Session %d closed\n", id);
|
if(VERBOSE_MODE_ENABLED) printf("Session %d closed\n", id);
|
||||||
|
@@ -29,6 +29,7 @@ BaseThread::BaseThread() : Thread() {
|
|||||||
setHasBeginExecution(false);
|
setHasBeginExecution(false);
|
||||||
setExecutingTask(false);
|
setExecutingTask(false);
|
||||||
setDeleteSelfOnExecutionDone(false);
|
setDeleteSelfOnExecutionDone(false);
|
||||||
|
setThreadOwnerValid(true);
|
||||||
|
|
||||||
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__);
|
||||||
}
|
}
|
||||||
@@ -39,6 +40,28 @@ BaseThread::~BaseThread() {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mutex * BaseThread::getMutexThreadOwnerValid() {
|
||||||
|
if(getThreadOwnerValid() == true) {
|
||||||
|
return &mutexThreadOwnerValid;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseThread::setThreadOwnerValid(bool value) {
|
||||||
|
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid);
|
||||||
|
threadOwnerValid = value;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseThread::getThreadOwnerValid() {
|
||||||
|
bool ret = false;
|
||||||
|
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid);
|
||||||
|
ret = threadOwnerValid;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseThread::signalQuit() {
|
void BaseThread::signalQuit() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
|
|||||||
|
|
||||||
bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
||||||
bool ret = (getExecutingTask() == false);
|
bool ret = (getExecutingTask() == false);
|
||||||
if(deleteSelfIfShutdownDelayed == true) {
|
if(ret == false && deleteSelfIfShutdownDelayed == true) {
|
||||||
setDeleteSelfOnExecutionDone(deleteSelfIfShutdownDelayed);
|
setDeleteSelfOnExecutionDone(deleteSelfIfShutdownDelayed);
|
||||||
signalQuit();
|
signalQuit();
|
||||||
}
|
}
|
||||||
|
@@ -753,6 +753,8 @@ Socket::Socket(PLATFORM_SOCKET sock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Socket::Socket() {
|
Socket::Socket() {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
this->pingThread = NULL;
|
this->pingThread = NULL;
|
||||||
this->connectedIpAddress = "";
|
this->connectedIpAddress = "";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user