diff --git a/Makefile b/Makefile index a718517..85663b8 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,10 @@ OUTPATH=./build/ SOURCE_MODULES_PATH=./library/ #FOR DEBUG PURPOSE -#CFLAGSTEMP=-c -Wall -I. -g -O0 +CFLAGSTEMP=-c -Wall -I. -g -O0 #FOR RELEASE -CFLAGSTEMP=-c -Wall -I. +#CFLAGSTEMP=-c -Wall -I. OPTIMIZATION=-O3 HEADERS=-I diff --git a/build/modules/auth.o b/build/modules/auth.o deleted file mode 100644 index 274c747..0000000 Binary files a/build/modules/auth.o and /dev/null differ diff --git a/build/modules/configRead.o b/build/modules/configRead.o deleted file mode 100644 index 5c49d20..0000000 Binary files a/build/modules/configRead.o and /dev/null differ diff --git a/build/modules/connection.o b/build/modules/connection.o deleted file mode 100644 index b07252a..0000000 Binary files a/build/modules/connection.o and /dev/null differ diff --git a/build/modules/daemon.o b/build/modules/daemon.o deleted file mode 100644 index 1e60449..0000000 Binary files a/build/modules/daemon.o and /dev/null differ diff --git a/build/modules/dynamicMemory.o b/build/modules/dynamicMemory.o deleted file mode 100644 index 0ea6505..0000000 Binary files a/build/modules/dynamicMemory.o and /dev/null differ diff --git a/build/modules/dynamicVectors.o b/build/modules/dynamicVectors.o deleted file mode 100644 index 5a967df..0000000 Binary files a/build/modules/dynamicVectors.o and /dev/null differ diff --git a/build/modules/errorHandling.o b/build/modules/errorHandling.o deleted file mode 100644 index 46c51ee..0000000 Binary files a/build/modules/errorHandling.o and /dev/null differ diff --git a/build/modules/fileManagement.o b/build/modules/fileManagement.o deleted file mode 100644 index 187f1fc..0000000 Binary files a/build/modules/fileManagement.o and /dev/null differ diff --git a/build/modules/ftpCommandElaborate.o b/build/modules/ftpCommandElaborate.o deleted file mode 100644 index 284b52f..0000000 Binary files a/build/modules/ftpCommandElaborate.o and /dev/null differ diff --git a/build/modules/ftpData.o b/build/modules/ftpData.o deleted file mode 100644 index a7bd9e6..0000000 Binary files a/build/modules/ftpData.o and /dev/null differ diff --git a/build/modules/ftpServer.o b/build/modules/ftpServer.o deleted file mode 100644 index 4024845..0000000 Binary files a/build/modules/ftpServer.o and /dev/null differ diff --git a/build/modules/logFunctions.o b/build/modules/logFunctions.o deleted file mode 100644 index ca9f615..0000000 Binary files a/build/modules/logFunctions.o and /dev/null differ diff --git a/build/modules/openSsl.o b/build/modules/openSsl.o deleted file mode 100644 index b85496d..0000000 Binary files a/build/modules/openSsl.o and /dev/null differ diff --git a/build/modules/signals.o b/build/modules/signals.o deleted file mode 100644 index 66a36f9..0000000 Binary files a/build/modules/signals.o and /dev/null differ diff --git a/build/uFTP b/build/uFTP deleted file mode 100755 index c404c95..0000000 Binary files a/build/uFTP and /dev/null differ diff --git a/ftpCommandElaborate.c b/ftpCommandElaborate.c index 1fb964b..2d48ff4 100644 --- a/ftpCommandElaborate.c +++ b/ftpCommandElaborate.c @@ -495,19 +495,7 @@ int parseCommandPasv(ftpDataType * data, int socketId) //printf("\n data->clients[%d].workerData.threadHasBeenCreated = %d", socketId, data->clients[socketId].workerData.threadHasBeenCreated); if (data->clients[socketId].workerData.threadIsAlive == 1) { - printf("\nPASV PTHREAD CANCEL"); - int returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread); - printf ("\npthread_cancel return code: %d", returnCode); - - returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn); - //fflush(0); - data->clients[socketId].workerData.threadHasBeenCreated = 0; - printf("\nparseCommand PASV JOIN RETURN STATUS %d", returnCode); - - printf("\nPASV THREAD CANCELLED!!!"); - - printf("\nftpData->clients[processingSocket].workerData.threadIsAlive = %d", data->clients[socketId].workerData.threadIsAlive); - + cancelWorker(data, socketId); } if (data->clients[socketId].workerData.threadHasBeenCreated == 1) @@ -543,19 +531,9 @@ int parseCommandPort(ftpDataType * data, int socketId) void *pReturn; if (data->clients[socketId].workerData.threadIsAlive == 1) { - printf("\nPORT PTHREAD CANCEL"); - int returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread); - printf ("\npthread_cancel return code: %d", returnCode); - //fflush(0); - - returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn); - data->clients[socketId].workerData.threadHasBeenCreated = 0; - printf("\nparseCommand PORT JOIN RETURN STATUS %d", returnCode); - - printf("\nPORT Thread cancelled!!!"); - - printf("\nftpData->clients[processingSocket].workerData.threadIsAlive = %d", data->clients[socketId].workerData.threadIsAlive); + cancelWorker(data, socketId); } + if (data->clients[socketId].workerData.threadHasBeenCreated == 1) { returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn); @@ -588,20 +566,7 @@ int parseCommandAbor(ftpDataType * data, int socketId) { if (data->clients[socketId].workerData.threadIsAlive == 1) { - void *pReturn; - - printf("\nABOR PTHREAD CANCEL"); - int returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread); - printf ("\npthread_cancel return code: %d", returnCode); - //fflush(0); - - returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn); - data->clients[socketId].workerData.threadHasBeenCreated = 0; - printf("\nparseCommand ABOR JOIN RETURN STATUS %d", returnCode); - - printf("\nAbor thread cancelled!!!"); - - printf("\nftpData->clients[processingSocket].workerData.threadIsAlive = %d", data->clients[socketId].workerData.threadIsAlive); + cancelWorker(data, socketId); } returnCode = socketPrintf(data, socketId, "s", "426 ABORT\r\n"); diff --git a/ftpData.c b/ftpData.c index 33fce72..e762cac 100644 --- a/ftpData.c +++ b/ftpData.c @@ -565,6 +565,15 @@ void deleteListDataInfoVector(DYNV_VectorGenericDataType *theVector) } } +void cancelWorker(ftpDataType *data, int clientId) +{ + void *pReturn; + int returnCode = pthread_cancel(data->clients[clientId].workerData.workerThread); + returnCode = pthread_join(data->clients[clientId].workerData.workerThread, &pReturn); + data->clients[clientId].workerData.threadHasBeenCreated = 0; +} + + void resetWorkerData(ftpDataType *data, int clientId, int isInitialization) { @@ -645,24 +654,11 @@ void resetClientData(ftpDataType *data, int clientId, int isInitialization) { if (isInitialization != 1) { - if (data->clients[clientId].workerData.threadIsAlive == 1) { - void *pReturn; - - printf("\nRESET CLIENT PTHREAD CANCEL"); - int returnCode = pthread_cancel(data->clients[clientId].workerData.workerThread); - printf ("\npthread_cancel return code: %d", returnCode); - //fflush(0); - - - returnCode = pthread_join(data->clients[clientId].workerData.workerThread, &pReturn); - data->clients[clientId].workerData.threadHasBeenCreated = 0; - printf("\nReset client data JOIN RETURN STATUS %d", returnCode); - - - printf("\nReset client data thread cancelled!!!"); - - printf("\nftpData->clients[processingSocket].workerData.threadIsAlive = %d", data->clients[clientId].workerData.threadIsAlive); + if (data->clients[clientId].workerData.threadIsAlive == 1) + { + cancelWorker(data, clientId); } + pthread_mutex_destroy(&data->clients[clientId].conditionMutex); pthread_cond_destroy(&data->clients[clientId].conditionVariable); diff --git a/ftpData.h b/ftpData.h index 8211d16..ae1c049 100644 --- a/ftpData.h +++ b/ftpData.h @@ -277,6 +277,7 @@ int searchInLoginFailsVector(void *loginFailsVector, void *element); void deleteLoginFailsData(void *element); void deleteListDataInfoVector(DYNV_VectorGenericDataType *theVector); void resetWorkerData(ftpDataType *data, int clientId, int isInitialization); +void cancelWorker(ftpDataType *data, int clientId); void resetClientData(ftpDataType *data, int clientId, int isInitialization); int compareStringCaseInsensitive(char *stringIn, char* stringRef, int stringLenght); int isCharInString(char *theString, int stringLen, char theChar); diff --git a/ftpServer.c b/ftpServer.c index cb4332f..c32785f 100644 --- a/ftpServer.c +++ b/ftpServer.c @@ -512,7 +512,7 @@ void *connectionWorkerHandle(void * socketId) void runFtpServer(void) { - printf("\nHello uFTP server v%s starting..\n", UFTP_SERVER_VERSION); + printf("\nHello uFTP server %s starting..\n", UFTP_SERVER_VERSION); /* Needed for Select*/ static int processingSock = 0, returnCode = 0; @@ -674,7 +674,7 @@ void runFtpServer(void) if (ftpData.clients[processingSock].buffer[i] == '\n') { ftpData.clients[processingSock].socketCommandReceived = 1; - printf("\n Processing the command: %s", ftpData.clients[processingSock].theCommandReceived); + //printf("\n Processing the command: %s", ftpData.clients[processingSock].theCommandReceived); commandProcessStatus = processCommand(processingSock); //Echo unrecognized commands if (commandProcessStatus == FTP_COMMAND_NOT_RECONIZED) diff --git a/ftpServer.h b/ftpServer.h index 634a8b0..63b9d91 100644 --- a/ftpServer.h +++ b/ftpServer.h @@ -27,7 +27,7 @@ #define FTPSERVER_H #define MAX_FTP_CLIENTS 10 -#define UFTP_SERVER_VERSION "v2.1.0 beta" +#define UFTP_SERVER_VERSION "v2.2.0 RC1" void runFtpServer(void); diff --git a/library/auth.c b/library/auth.c index 51108d5..b5e4d68 100644 --- a/library/auth.c +++ b/library/auth.c @@ -12,6 +12,7 @@ #include #include #include + #include #include diff --git a/library/connection.c b/library/connection.c index 43030a3..a299f0e 100644 --- a/library/connection.c +++ b/library/connection.c @@ -595,19 +595,7 @@ void closeClient(ftpDataType * ftpData, int processingSocket) if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1) { - printf("\nCLOSE THE CLIENT PTHREAD CANCEL"); - void *pReturn; - int returnCode = pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread); - printf ("\npthread_cancel return code: %d", returnCode); - //fflush(0); - - returnCode = pthread_join(ftpData->clients[processingSocket].workerData.workerThread, &pReturn); - ftpData->clients[processingSocket].workerData.threadHasBeenCreated = 0; - printf("\nCLOSE THE CLIENT JOIN RETURN STATUS %d", returnCode); - - printf("\nClose client thread cancelled!!!"); - printf("\nftpData->clients[processingSocket].workerData.threadIsAlive = %d", ftpData->clients[processingSocket].workerData.threadIsAlive); - + cancelWorker(ftpData, processingSocket); } FD_CLR(ftpData->clients[processingSocket].socketDescriptor, &ftpData->connectionData.rsetAll);