FTP Server file transfer cancellation

Discussion to talk about software related topics only.
Post Reply
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

FTP Server file transfer cancellation

Post by khoney »

I have the FTP Server task started in my Nano54415 application. I can perform file transfers to and from the SD card without incident using Explorer's 'Page->Open FTP Site in Windows Explorter' drag and drop window. However, when I'm transferring a large file (either to or from the SD card) and I hit the Cancel button on the progress bar dialog, it causes the Netburner to have a watchdog timeout and reset. My watchdog is currently set to 8 seconds (sim2.scm.cwcr=0x00DE).

Do I need to modify some Netburner code to prevent this?
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: FTP Server file transfer cancellation

Post by dciliske »

Can you give some details regarding what a 'large' file is (1MB? 40MB? ~1GB?)? If I were to guess, this is probably related to the mmc driver (aka, SD driver) for the MCF54415 parts blocking the task during transfers. If you've got an 8 second timeout on your watchdog (refreshed in a lower priority task I'm guessing), then you're likely to fail this condition with files >~8MB. Is this what you're seeing?
Dan Ciliske
Project Engineer
Netburner, Inc
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: FTP Server file transfer cancellation

Post by khoney »

I'm transferring 60MB files, and I have no problem grabbing 30 of them and transferring them to my PC. The problem only occurs when I cancel the transfer of a file by clicking the Cancel button on the windows file copy dialog. It's acting like the FTP process does not know the file transfer has been cancelled, and is waiting on something?
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: FTP Server file transfer cancellation

Post by seulater »

It would help if you shown the section of code where your uploading the data.
Are you checking to see if the connection gets closed ?
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: FTP Server file transfer cancellation

Post by khoney »

Wow... seulater, thanks for your post. It's been so long since I worked with this app that I forgot I even had any ftp code. I was thinking it was all handled by the runtime library!

I see where the problem is (there's a writeall function call that is writing blocks of the file to the FTP file desciptor in an infinite loop). Now how to fix it so I can check on whether the connection has been closed...?
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: FTP Server file transfer cancellation

Post by khoney »

All better now :)
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: FTP Server file transfer cancellation

Post by ecasey »

FYI, there is a loop in the ftp_f.ccp program in the C:\nburn\examples\StandardStack\EFFS\ examples that provide FTP that becomes an infinite loop if the ftp session is cancelled or refreshed while a file is being transferred.
At around line 506 in ftp_f.ccp:

Code: Select all

  while( ( RetryAttempts < NetworkRetryLimit ) && ( TotalBytesWritten != BytesRead ) )
      {
         BytesWritten = write( fd, FTP_buffer + TotalBytesWritten, BytesRead-TotalBytesWritten );
         // retry if busy

         if ( BytesWritten == 0 )
         {
            RetryAttempts++;
            OSTimeDly( TICKS_PER_SECOND/4 );
         }

         TotalBytesWritten += BytesWritten;
      }

      if( RetryAttempts >= NetworkRetryLimit )
      TransferError = 2;

   }
write() returns a negative number if it fails. If the session is cancelled or refreshed while in this loop, the write() will continue to return -2 and there is no way out of the loop. Changing the exit counter condition from if ( BytesWritten == 0 ) to if ( BytesWritten <= 0 ) fixes the problem, although that might not be the best way to deal with this.

Perhaps someone else has a more robust solution that should be incorporated into the ftp_f.cpp program.
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: FTP Server file transfer cancellation

Post by dciliske »

I'm making a note of this to examine this issue later. I have encountered this error and been frustrated by it. Thank you for pointing out the cause.

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
Post Reply