From 5fd59eb00f00141db9e05236cf9cb8d08d44884b Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 4 Apr 2011 17:56:47 +0000 Subject: [PATCH] - added more debug info and error output to detect failures to write file data during file xfers --- .../sources/platform/posix/miniftpclient.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/shared_lib/sources/platform/posix/miniftpclient.cpp b/source/shared_lib/sources/platform/posix/miniftpclient.cpp index fb49c27c..1f902efa 100644 --- a/source/shared_lib/sources/platform/posix/miniftpclient.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpclient.cpp @@ -62,7 +62,7 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { fullFilePath += out->filename; } - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread writing file [%s]\n",fullFilePath.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread writing to file [%s]\n",fullFilePath.c_str()); // Abort file xfer and delete partial file if(out && out->ftpServer && out->ftpServer->getQuitStatus() == true) { @@ -88,12 +88,20 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { if(out->stream == NULL) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"===> FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str()); return -1; /* failure, can't open file to write */ } out->isValidXfer = true; } - return fwrite(buffer, size, nmemb, out->stream); + size_t result = fwrite(buffer, size, nmemb, out->stream); + if(result != nmemb) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %lu, result = %lu\n",fullFilePath.c_str(),nmemb,result); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %lu, result = %lu\n",fullFilePath.c_str(),nmemb,result); + SystemFlags::OutputDebug(SystemFlags::debugError,"===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %lu, result = %lu\n",fullFilePath.c_str(),nmemb,result); + //return -1; /* failure, can't open file to write */ + } + return result; } /*