- numerous thread bugfixes related to menu stability and ftp server socket usage

This commit is contained in:
Mark Vejvoda
2011-01-02 09:33:37 +00:00
parent 2b1732e27e
commit 5f4d3e9088
16 changed files with 235 additions and 100 deletions

View File

@@ -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",
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;
if(ftpAddUPNPPortForward) {
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);

View File

@@ -205,8 +205,8 @@ int ftpShutdown(void)
if(ftpGetSession(n)->open)
{
ftpUntrackSocket(ftpGetSession(n)->ctrlSocket);
ftpCloseSession(n);
}
}
ftpCloseSession(n);
}
ftpArchCleanup();

View File

@@ -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);
ftpRemoveUPNPPortForward(sessions[id].remoteFTPServerPassivePort, sessions[id].remoteFTPServerPassivePort);
sessions[id].remoteFTPServerPassivePort = 0;
}
}
ftpCloseSocket(sessions[id].ctrlSocket);
ftpCloseTransmission(id);
if(sessions[id].open) {
ftpCloseSocket(sessions[id].ctrlSocket);
ftpCloseTransmission(id);
}
sessions[id].remoteIp = 0;
sessions[id].ctrlSocket = 0;
sessions[id].open = FALSE;
if(VERBOSE_MODE_ENABLED) printf("Session %d closed\n", id);

View File

@@ -29,6 +29,7 @@ BaseThread::BaseThread() : Thread() {
setHasBeginExecution(false);
setExecutingTask(false);
setDeleteSelfOnExecutionDone(false);
setThreadOwnerValid(true);
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);
}
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() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());

View File

@@ -89,7 +89,7 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter
bool SimpleTaskThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
bool ret = (getExecutingTask() == false);
if(deleteSelfIfShutdownDelayed == true) {
if(ret == false && deleteSelfIfShutdownDelayed == true) {
setDeleteSelfOnExecutionDone(deleteSelfIfShutdownDelayed);
signalQuit();
}

View File

@@ -753,6 +753,8 @@ Socket::Socket(PLATFORM_SOCKET sock) {
}
Socket::Socket() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
this->pingThread = NULL;
this->connectedIpAddress = "";