Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.6k views
in .NET FTP by (160 points)
My application uses async transfers and as long as I don't interrupt the transfers it shuts down quickly. However if I call AbortAsynchronous() and then shut down my app refuses to exit completely. After a couple of minutes I find that a thread from the ftp lib tries to call back into my code:

> Framework.UI.BLLInterface.dll!Stc.Bll.FileTransfer.FileTransferList.ftpConnection_Downloaded(object sender = {EnterpriseDT.Net.Ftp.ExFTPConnection}, EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs e = {EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs}) Line 440 C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) + 0x5a bytes
mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0x5 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.InvokeDelegate(bool preferGuiThread = true, bool permitAsync = true, System.Delegate del = {EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler}, object[] args = {Dimensions:[2]}) + 0x51f bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.InvokeEventHandler(System.Delegate eventHandler = {EnterpriseDT.Net.Ftp.FTPFileTransferEventHandler}, object sender = {EnterpriseDT.Net.Ftp.ExFTPConnection}, System.EventArgs e = {EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs}) + 0xb8 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.OnDownloaded(string localPath = "C:\\Documents and Settings\\DiLynch\\My Documents\\Spirent\\Test Center\\dummy1.log", string remoteFile = "C:\\TestCenterServer\\TestCenterServerManager2008-02-29_09-22-39\\STC_Core\\2.30.3118.0000\\Test Session 9 - DiLynch\\dummy1.log", System.Exception ex = {"The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established."}) + 0x90 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.DownloadFile(string localPath = "C:\\Documents and Settings\\DiLynch\\My Documents\\Spirent\\Test Center\\dummy1.log", string remoteFile = "C:\\TestCenterServer\\TestCenterServerManager2008-02-29_09-22-39\\STC_Core\\2.30.3118.0000\\Test Session 9 - DiLynch\\dummy1.log") + 0x135 bytes
[Native to Managed Transition]
[Managed to Native Transition]
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.ExFTPConnection.a.a(System.Reflection.MethodInfo A_0 = {Void DownloadFile(System.String, System.String)}, object[] A_1 = {Dimensions:[2]}) + 0x27 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) + 0x5a bytes
mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0x5 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.InvokeDelegate(bool preferGuiThread = false, bool permitAsync = false, System.Delegate del = {EnterpriseDT.Net.Ftp.ExFTPConnection.a.a}, object[] args = {Dimensions:[2]}) + 0x51f bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.ExFTPConnection.a.f() + 0xc3 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.ExFTPConnection.b.a() + 0xdf bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(System.RuntimeMethodHandle md, object[] args, object server, int methodPtr, bool fExecuteInContext, out object[] outArgs) + 0x30 bytes
mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink = {System.Runtime.Remoting.Messaging.AsyncResult}) + 0x1ab bytes
mscorlib.dll!System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(object o) + 0x51 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(object state) + 0x1a bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x81 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback tpWaitCallBack) + 0x50 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(object state) + 0x60 bytes

4 Answers

0 votes
by (51.6k points)
Hi Uncle Festis

Firstly, instead of calling AbortAsynchronous(), try calling Close(true).

Secondly, I think we fixed a bug like this some versions back. What version are you using?

- Hans (EnterpriseDT
0 votes
by (160 points)
Calling Close( true ); causes my app to hang in the close call:

[In a sleep, wait, or join]
mscorlib.dll!System.Threading.Thread.Sleep(int millisecondsTimeout) + 0x5 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.Close(bool abruptClose = true) + 0x6a bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.ExFTPConnection.Close(bool abruptClose = true) + 0x33 bytes
> Framework.UI.BLLInterface.dll!Stc.Bll.FileTransfer.FileTransferList.CancelTransfer() Line 364 + 0x10 bytes C#
Framework.UI.CAB.dll!Stc.Frmwk.UI.CAB.Forms.FileTransferControl.TransferFiles.AnonymousMethod() Line 211 + 0xe bytes C#
Framework.UI.Utils.dll!Stc.Frmwk.Utils.FileTransferProgressBar.cancelButton_Click(object sender = {Text = Cannot evaluate expression because the current thread is in a sleep, wait, or join}, System.EventArgs e = {X = 50 Y = 11 Button = Left}) Line 247 + 0x18 bytes C#


If I check the other thread call stacks It looks like the async thread is still waiting for the socket to close?


> System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer = {Dimensions:[1024]}, int offset = 0, int size, System.Net.Sockets.SocketFlags socketFlags = None, out System.Net.Sockets.SocketError errorCode = Success) + 0xd3 bytes
System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) + 0x21 bytes
System.dll!System.Net.Sockets.NetworkStream.Read(byte[] buffer, int offset, int size) + 0x78 bytes
mscorlib.dll!System.IO.StreamReader.ReadBuffer() + 0x5c bytes
mscorlib.dll!System.IO.StreamReader.ReadLine() + 0x1f bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply() + 0x1c1 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPClient.ValidateTransfer() + 0x34 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPClient.Get(string localPath = "C:\\Documents and Settings\\DiLynch\\My Documents\\Spirent\\Test Center\\dummy1.log", string remoteFile = "STC_Core/2.30.3118.0000/Test Session 9 - DiLynch/dummy1.log") + 0x120 bytes
edtFTPnetEx.dll!EnterpriseDT.Net.Ftp.FTPConnection.DownloadFile(string localPath = "C:\\Documents and Settings\\DiLynch\\My Documents\\Spirent\\Test Center\\dummy1.log", string remoteFile = "STC_Core/2.30.3118.0000/Test Session 9 - DiLynch/dummy1.log") + 0xcc bytes


Finally, if I wait a couple of minutes (for the socket to timeout I assume) I get an AsyncCallback for my BeginDownloadFile() call. When I call EndDownloadFile I get an exception "The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established."

My version is 2.0.2.0, which I downloaded last week. Also note that I am using the UseGuiThreadIfAvailable=false option as sometimes I need to transfer files before the main form is created.
0 votes
by (51.6k points)
We are trying to replicate the problem and will let you know as soon as we have some results.

- Hans (EnterpriseDT)
0 votes
by (162k points)
Please email support@enterprisedt.com for a patched DLL. Please indicate whether you are using edtFTPnet/Express or edtFTPnet/PRO.

Categories

...