mirror of
https://github.com/kingk85/uFTP.git
synced 2025-07-24 20:56:09 +03:00
Some refactoring the release is now a Release Candidate
This commit is contained in:
4
Makefile
4
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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/uFTP
BIN
build/uFTP
Binary file not shown.
@ -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");
|
||||
|
30
ftpData.c
30
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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <security/pam_appl.h>
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user