mirror of
https://github.com/kingk85/uFTP.git
synced 2025-04-12 10:48:40 +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);
|
||||
//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)
|
||||
@ -533,6 +538,11 @@ int parseCommandPort(ftpDataType * data, int socketId)
|
||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -566,6 +576,11 @@ int parseCommandAbor(ftpDataType * data, int socketId)
|
||||
if (data->clients[socketId].workerData.threadIsAlive == 1)
|
||||
{
|
||||
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");
|
||||
|
10
ftpData.c
10
ftpData.c
@ -632,10 +632,14 @@ void resetClientData(ftpDataType *data, int clientId, int isInitialization)
|
||||
{
|
||||
if (isInitialization != 1)
|
||||
{
|
||||
if (data->clients[clientId].workerData.threadIsAlive == 1){
|
||||
if (data->clients[clientId].workerData.threadIsAlive == 1) {
|
||||
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
||||
usleep(10000);
|
||||
printf("Thread had ben cancelled!");
|
||||
do
|
||||
{
|
||||
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_cond_destroy(&data->clients[clientId].conditionVariable);
|
||||
|
@ -596,9 +596,15 @@ void closeClient(ftpDataType * ftpData, int processingSocket)
|
||||
|
||||
if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1)
|
||||
{
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user