mirror of
https://github.com/kingk85/uFTP.git
synced 2025-04-20 00:18:57 +03:00
Wait for thread cancel
This commit is contained in:
@ -497,6 +497,11 @@ int parseCommandPasv(ftpDataType * data, int socketId)
|
|||||||
{
|
{
|
||||||
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||||
//printf("\npasv pthread_cancel = %d", returnCode);
|
//printf("\npasv pthread_cancel = %d", returnCode);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
printf("\nQuit command received the Pasv Thread has been cancelled!!!");
|
||||||
|
usleep(10000);
|
||||||
|
} while (ftpData->clients[socketId].workerData.threadIsAlive == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->clients[socketId].workerData.threadHasBeenCreated == 1)
|
if (data->clients[socketId].workerData.threadHasBeenCreated == 1)
|
||||||
@ -533,6 +538,11 @@ int parseCommandPort(ftpDataType * data, int socketId)
|
|||||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||||
{
|
{
|
||||||
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
printf("\nQuit command received the Pasv Thread has been cancelled!!!");
|
||||||
|
usleep(10000);
|
||||||
|
} while (ftpData->clients[socketId].workerData.threadIsAlive == 1);
|
||||||
}
|
}
|
||||||
if (data->clients[socketId].workerData.threadHasBeenCreated == 1)
|
if (data->clients[socketId].workerData.threadHasBeenCreated == 1)
|
||||||
{
|
{
|
||||||
@ -566,6 +576,11 @@ int parseCommandAbor(ftpDataType * data, int socketId)
|
|||||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||||
{
|
{
|
||||||
pthread_cancel(data->clients[socketId].workerData.workerThread);
|
pthread_cancel(data->clients[socketId].workerData.workerThread);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
printf("\nQuit command received the Pasv Thread has been cancelled!!!");
|
||||||
|
usleep(10000);
|
||||||
|
} while (ftpData->clients[socketId].workerData.threadIsAlive == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
returnCode = socketPrintf(data, socketId, "s", "426 ABORT\r\n");
|
returnCode = socketPrintf(data, socketId, "s", "426 ABORT\r\n");
|
||||||
|
10
ftpData.c
10
ftpData.c
@ -632,10 +632,14 @@ void resetClientData(ftpDataType *data, int clientId, int isInitialization)
|
|||||||
{
|
{
|
||||||
if (isInitialization != 1)
|
if (isInitialization != 1)
|
||||||
{
|
{
|
||||||
if (data->clients[clientId].workerData.threadIsAlive == 1){
|
if (data->clients[clientId].workerData.threadIsAlive == 1) {
|
||||||
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
||||||
usleep(10000);
|
do
|
||||||
printf("Thread had ben cancelled!");
|
{
|
||||||
|
printf("\nQuit command received the Pasv Thread has been cancelled!!!");
|
||||||
|
usleep(10000);
|
||||||
|
} while (ftpData->clients[clientId].workerData.threadIsAlive == 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
pthread_mutex_destroy(&data->clients[clientId].conditionMutex);
|
pthread_mutex_destroy(&data->clients[clientId].conditionMutex);
|
||||||
pthread_cond_destroy(&data->clients[clientId].conditionVariable);
|
pthread_cond_destroy(&data->clients[clientId].conditionVariable);
|
||||||
|
@ -596,9 +596,15 @@ void closeClient(ftpDataType * ftpData, int processingSocket)
|
|||||||
|
|
||||||
if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1)
|
if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread);
|
pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread);
|
||||||
printf("\nQuit command received the Pasv Thread has been cancelled!!!");
|
|
||||||
usleep(10000);
|
do
|
||||||
|
{
|
||||||
|
printf("\nQuit command received the Pasv Thread has been cancelled!!!");
|
||||||
|
usleep(10000);
|
||||||
|
} while (ftpData->clients[processingSocket].workerData.threadIsAlive == 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_CLR(ftpData->clients[processingSocket].socketDescriptor, &ftpData->connectionData.rsetAll);
|
FD_CLR(ftpData->clients[processingSocket].socketDescriptor, &ftpData->connectionData.rsetAll);
|
||||||
|
Reference in New Issue
Block a user