- more ftp bugfixes

This commit is contained in:
Mark Vejvoda 2011-01-16 03:05:11 +00:00
parent 6e7bcd2ece
commit 3814702b18
4 changed files with 19 additions and 7 deletions

View File

@ -25,22 +25,22 @@
/** /**
* @brief max. possible simultaneous FTP client connections * @brief max. possible simultaneous FTP client connections
*/ */
#define MAX_CONNECTIONS 16 #define MAX_CONNECTIONS 60
/** /**
* @brief max. possible user accounts * @brief max. possible user accounts
*/ */
#define MAX_USERS 16 #define MAX_USERS 20
/** /**
* @brief max. length of a user account name * @brief max. length of a user account name
*/ */
#define MAXLEN_USERNAME 25 #define MAXLEN_USERNAME 40
/** /**
* @brief max. length of a user account password * @brief max. length of a user account password
*/ */
#define MAXLEN_PASSWORD 25 #define MAXLEN_PASSWORD 40
/** /**
* @brief session timeout in seconds * @brief session timeout in seconds
@ -50,7 +50,7 @@
/** /**
* @brief maximum length of a complete directory path * @brief maximum length of a complete directory path
*/ */
#define MAX_PATH_LEN 260 #define MAX_PATH_LEN 1024
/** /**
* @brief Size of the scratch buffer * @brief Size of the scratch buffer

View File

@ -128,7 +128,7 @@ int ftpExecTransmission(int sessionId)
break; break;
rxLen += len; rxLen += len;
}while(rxLen < LEN_SCRATCHBUF); } while(rxLen < LEN_SCRATCHBUF);
if(rxLen > 0) if(rxLen > 0)
{ {
@ -159,7 +159,9 @@ int ftpExecTransmission(int sessionId)
return 1; return 1;
} }
else else
{
return 0; return 0;
}
} }
LOCAL int ftpCmdUser(int sessionId, const char* args, int len) LOCAL int ftpCmdUser(int sessionId, const char* args, int len)

View File

@ -171,6 +171,8 @@ int ftpExecute(void)
clientSocket = ftpAcceptServerConnection(server, &remoteIP, &remotePort); clientSocket = ftpAcceptServerConnection(server, &remoteIP, &remotePort);
if(clientSocket >= 0) if(clientSocket >= 0)
{ {
if(VERBOSE_MODE_ENABLED) printf("ftpExecute ftpAcceptServerConnection = %d\n",clientSocket);
sessionId = ftpOpenSession(clientSocket, remoteIP, remotePort); sessionId = ftpOpenSession(clientSocket, remoteIP, remotePort);
if(sessionId >= 0) if(sessionId >= 0)
{ {
@ -195,6 +197,7 @@ if(VERBOSE_MODE_ENABLED) printf("ERROR: Connection refused; Session limit reache
if(ftpTestSocket(ctrlSocket)) if(ftpTestSocket(ctrlSocket))
{ {
if(VERBOSE_MODE_ENABLED) printf("ftpExecute socket signalled = %d\n",ctrlSocket);
int len; int len;
socksRdy--; socksRdy--;
len = ftpReceive(ctrlSocket, len = ftpReceive(ctrlSocket,
@ -202,6 +205,8 @@ if(VERBOSE_MODE_ENABLED) printf("ERROR: Connection refused; Session limit reache
LEN_RXBUF - pSession->rxBufWriteIdx); LEN_RXBUF - pSession->rxBufWriteIdx);
if(len <= 0) // has client shutdown the connection? if(len <= 0) // has client shutdown the connection?
{ {
if(VERBOSE_MODE_ENABLED) printf("ftpExecute ERROR ON RECEIVE for socket = %d\n",ctrlSocket);
ftpUntrackSocket(ctrlSocket); ftpUntrackSocket(ctrlSocket);
ftpCloseSession(n); ftpCloseSession(n);
} }
@ -214,6 +219,8 @@ if(VERBOSE_MODE_ENABLED) printf("ERROR: Connection refused; Session limit reache
/// @bug Session-Timeout-Management doesn't work /// @bug Session-Timeout-Management doesn't work
if((ftpGetUnixTime() - pSession->timeLastCmd) > SESSION_TIMEOUT) if((ftpGetUnixTime() - pSession->timeLastCmd) > SESSION_TIMEOUT)
{ {
if(VERBOSE_MODE_ENABLED) printf("ftpExecute ERROR: SESSION TIMED OUT for socket = %d\n",ctrlSocket);
ftpSendMsg(MSG_NORMAL, n, 421, ftpMsg036); ftpSendMsg(MSG_NORMAL, n, 421, ftpMsg036);
ftpUntrackSocket(ctrlSocket); ftpUntrackSocket(ctrlSocket);
ftpCloseSession(n); ftpCloseSession(n);

View File

@ -166,7 +166,9 @@ std::string SystemFlags::getHTTP(std::string URL,CURL *handle,int timeOut) {
CURL *SystemFlags::initHTTP() { CURL *SystemFlags::initHTTP() {
if(SystemFlags::curl_global_init_called == false) { if(SystemFlags::curl_global_init_called == false) {
SystemFlags::curl_global_init_called = true; SystemFlags::curl_global_init_called = true;
curl_global_init(CURL_GLOBAL_ALL); CURLcode result = curl_global_init(CURL_GLOBAL_ALL);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] curl_global_init called and returned: result %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,result,curl_easy_strerror(result));
//printf("In [%s::%s Line %d] curl_global_init called and returned: result %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,result,curl_easy_strerror(result));
} }
CURL *handle = curl_easy_init(); CURL *handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1);
@ -236,6 +238,7 @@ void SystemFlags::cleanupHTTP(CURL **handle, bool globalCleanup) {
if(SystemFlags::curl_global_init_called == true) { if(SystemFlags::curl_global_init_called == true) {
SystemFlags::curl_global_init_called = false; SystemFlags::curl_global_init_called = false;
curl_global_cleanup(); curl_global_cleanup();
//printf("In [%s::%s Line %d] curl_global_cleanup called\n",__FILE__,__FUNCTION__,__LINE__);
} }
} }
} }