mirror of
https://github.com/kingk85/uFTP.git
synced 2025-07-31 05:47:34 +03:00
Some bug fix
This commit is contained in:
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.
@ -463,12 +463,17 @@ int parseCommandPasv(ftpDataType * data, int socketId)
|
||||
|
||||
//if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
// {
|
||||
|
||||
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||
}
|
||||
printf("\npasv pthread_cancel = %d", returnCode);
|
||||
//}
|
||||
printf("\npasv join ");
|
||||
returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
|
||||
|
||||
if (data->clients[socketId].workerData.threadHasBeenCreated == 1)
|
||||
returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
|
||||
|
||||
printf("\npasv join ok");
|
||||
data->clients[socketId].workerData.passiveModeOn = 1;
|
||||
data->clients[socketId].workerData.activeModeOn = 0;
|
||||
@ -495,11 +500,12 @@ int parseCommandPort(ftpDataType * data, int socketId)
|
||||
returnCode = snprintf(data->clients[socketId].workerData.activeIpAddress, CLIENT_BUFFER_STRING_SIZE, "%d.%d.%d.%d", ipAddressBytes[0],ipAddressBytes[1],ipAddressBytes[2],ipAddressBytes[3]);
|
||||
|
||||
void *pReturn;
|
||||
//if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
//{
|
||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||
//}
|
||||
returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
|
||||
}
|
||||
if (data->clients[socketId].workerData.threadHasBeenCreated == 1)
|
||||
returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
|
||||
data->clients[socketId].workerData.passiveModeOn = 0;
|
||||
data->clients[socketId].workerData.activeModeOn = 1;
|
||||
returnCode = pthread_create(&data->clients[socketId].workerData.workerThread, NULL, connectionWorkerHandle, (void *) &data->clients[socketId].clientProgressiveNumber);
|
||||
@ -526,11 +532,10 @@ int parseCommandAbor(ftpDataType * data, int socketId)
|
||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
void *pReturn;
|
||||
//if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
//{
|
||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||
//}
|
||||
pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
|
||||
}
|
||||
|
||||
returnCode = socketPrintf(data, socketId, "s", "426 ABORT\r\n");
|
||||
if (returnCode <= 0)
|
||||
|
29
ftpData.c
29
ftpData.c
@ -602,7 +602,8 @@ void resetWorkerData(ftpDataType *data, int clientId, int isInitialization)
|
||||
{
|
||||
DYNV_VectorGeneric_Init(&data->clients[clientId].workerData.directoryInfo);
|
||||
data->clients[clientId].workerData.theStorFile = NULL;
|
||||
data->clients[clientId].workerData.workerThread = 0;
|
||||
data->clients[clientId].workerData.threadHasBeenCreated = 0;
|
||||
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&data->clients[clientId].workerData.conditionMutex, NULL) != 0)
|
||||
@ -639,25 +640,16 @@ void resetClientData(ftpDataType *data, int clientId, int isInitialization)
|
||||
|
||||
if (isInitialization != 1)
|
||||
{
|
||||
if (data->clients[clientId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
void *pReturn;
|
||||
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
||||
pthread_join(data->clients[clientId].workerData.workerThread, &pReturn);
|
||||
}
|
||||
else
|
||||
{
|
||||
void *pReturn = NULL;
|
||||
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
||||
pthread_join(data->clients[clientId].workerData.workerThread, &pReturn);
|
||||
}
|
||||
void *pReturn;
|
||||
if (data->clients[clientId].workerData.threadIsAlive == 1)
|
||||
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
||||
|
||||
pthread_mutex_destroy(&data->clients[clientId].writeMutex);
|
||||
pthread_mutex_destroy(&data->clients[clientId].writeMutex);
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL_free(data->clients[clientId].ssl);
|
||||
//SSL_free(data->clients[clientId].workerData.ssl);
|
||||
#endif
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL_free(data->clients[clientId].ssl);
|
||||
//SSL_free(data->clients[clientId].workerData.ssl);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&data->clients[clientId].writeMutex, NULL) != 0)
|
||||
@ -665,6 +657,7 @@ void resetClientData(ftpDataType *data, int clientId, int isInitialization)
|
||||
printf("\nclientData->writeMutex init failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
data->clients[clientId].tlsIsNegotiating = 0;
|
||||
data->clients[clientId].tlsIsEnabled = 0;
|
||||
data->clients[clientId].dataChannelIsTls = 0;
|
||||
|
@ -125,6 +125,7 @@ struct workerData
|
||||
#endif
|
||||
|
||||
int threadIsAlive;
|
||||
int threadHasBeenCreated;
|
||||
int connectionPort;
|
||||
int passiveModeOn;
|
||||
int activeModeOn;
|
||||
|
@ -570,7 +570,7 @@ void runFtpServer(void)
|
||||
//Debug print errors
|
||||
if (ftpData.clients[processingSock].bufferIndex < 0)
|
||||
{
|
||||
//ftpData.clients[processingSock].closeTheClient = 1;
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
printf("\n1 Errno = %d", errno);
|
||||
perror("1 Error: ");
|
||||
continue;
|
||||
|
@ -460,13 +460,13 @@ void closeClient(ftpDataType * ftpData, int processingSocket)
|
||||
{
|
||||
printf("\nQUIT FLAG SET!\n");
|
||||
|
||||
// if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1)
|
||||
// {
|
||||
void *pReturn;
|
||||
pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread);
|
||||
pthread_join(ftpData->clients[processingSocket].workerData.workerThread, &pReturn);
|
||||
printf("\nQuit command received the Pasv Thread has been cancelled.");
|
||||
// }
|
||||
if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1)
|
||||
{
|
||||
void *pReturn;
|
||||
pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread);
|
||||
//pthread_join(ftpData->clients[processingSocket].workerData.workerThread, &pReturn);
|
||||
printf("\nQuit command received the Pasv Thread has been cancelled.");
|
||||
}
|
||||
|
||||
FD_CLR(ftpData->clients[processingSocket].socketDescriptor, &ftpData->connectionData.rsetAll);
|
||||
FD_CLR(ftpData->clients[processingSocket].socketDescriptor, &ftpData->connectionData.wsetAll);
|
||||
@ -630,7 +630,7 @@ int evaluateClientSocketConnection(ftpDataType * ftpData)
|
||||
//Errors while accepting, socket will be closed
|
||||
ftpData->clients[availableSocketIndex].closeTheClient = 1;
|
||||
printf("\n2 Errno = %d", errno);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user