diff --git a/ftpCommandElaborate.c b/ftpCommandElaborate.c index 2467971..ca61317 100644 --- a/ftpCommandElaborate.c +++ b/ftpCommandElaborate.c @@ -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"); diff --git a/ftpData.c b/ftpData.c index 283f646..b3a19b4 100644 --- a/ftpData.c +++ b/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); diff --git a/library/connection.c b/library/connection.c index 22d0baa..b53ed89 100644 --- a/library/connection.c +++ b/library/connection.c @@ -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);