Skip to content

Commit

Permalink
stability and compatibility improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
UldisRinkevichs committed Jul 8, 2018
1 parent e26e9fb commit 679fc0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Source/ftpserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,14 @@ void WorkerThreadCleanup(PFTPCONTEXT context)
* trying to stop gracefully
*/
context->WorkerThreadAbort = 1;
sleep(2);

err = pthread_join(context->WorkerThreadId, &retv);
if ( err != 0)
{
writelogentry(context, "Enter cancel", "");
pthread_cancel(context->WorkerThreadId);
}

context->WorkerThreadValid = -1;
}
Expand All @@ -401,6 +405,7 @@ void WorkerThreadCleanup(PFTPCONTEXT context)

context->DataIPv4 = 0;
context->DataPort = 0;
writelogentry(context, "WorkerThreadCleanup complete", "");
}

int ftpUSER(PFTPCONTEXT context, const char *params)
Expand Down Expand Up @@ -952,6 +957,7 @@ int ftpABOR(PFTPCONTEXT context, const char *params)
if ( context->Access == FTP_ACCESS_NOT_LOGGED_IN )
return sendstring(context, error530);

writelogentry(context, " ABORT command", NULL);
WorkerThreadCleanup(context);
return sendstring(context, success226);
}
Expand Down Expand Up @@ -1904,16 +1910,16 @@ void *ftp_client_thread(SOCKET *s)
break;

i = 0;
while (rcvbuf[i] == ' ')
i++;
while ((rcvbuf[i] != 0) && (isalpha(rcvbuf[i]) == 0))
++i;

cmd = &rcvbuf[i];
while ((rcvbuf[i] != 0) && (rcvbuf[i] != ' '))
i++;
++i;

cmdlen = &rcvbuf[i] - cmd;
while (rcvbuf[i] == ' ')
i++;
++i;

if (rcvbuf[i] == 0)
params = NULL;
Expand Down
1 change: 1 addition & 0 deletions Source/ftpserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <ctype.h>
#include <fcntl.h>
#include <dirent.h>
#include <pthread.h>
Expand Down

0 comments on commit 679fc0c

Please sign in to comment.