ardar / flowlib

Automatically exported from code.google.com/p/flowlib
1 stars 0 forks source link

TransferManager.EndTransfer() ITransfer.Disconnect() locks down application #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Start download transfer
2. call TransferManager.EndTransfer() method or ITransfer.Disconnect() of 
created transfer

What is the expected output? What do you see instead?
Transfer should stop. Application stops responding.

What version of the product are you using? ~~(Do not write latest)~~
SVN r482

On what operating system?
Windows Vista Sp1

Call Stack? ~~(Line numbers and exception type helps much)~~
no exceptions

Original issue reported on code.google.com by hackw...@gmail.com on 17 Mar 2009 at 7:51

GoogleCodeExporter commented 8 years ago
Im using my mobile phone right now so i cant test this but, why do you need to 
close
the connection?

If the user is not granted a access the connection is closed.
If the connection is inactive in X seconds it is closed.

Original comment by blomman84 on 17 Mar 2009 at 9:53

GoogleCodeExporter commented 8 years ago
I need this to make pause for download.

Original comment by hackw...@gmail.com on 18 Mar 2009 at 2:27

GoogleCodeExporter commented 8 years ago
If you set a break point on: this.ConnectionStatusChange(this, new
FmdcEventArgs(Disconnected, new FmdcException(msg)));
in function TcpConnection:Disconnect(string msg)

and on the line: socket.Disconnect(true);

Do you get to the second line when calling 
TransferManager.EndTransfer(ITransfer trans)?

Original comment by blomman84 on 29 Mar 2009 at 7:21

GoogleCodeExporter commented 8 years ago
application locks on line socket.Disconnect(true); in this function.
this.ConnectionStatusChange(this, new
FmdcEventArgs(Disconnected, new FmdcException(msg))); runs quickly

Original comment by hackw...@gmail.com on 30 Mar 2009 at 1:34

GoogleCodeExporter commented 8 years ago
Solved by adding into void Disconnect(string msg) (TcpConnection.cs) following 
line
socket.Shutdown(SocketShutdown.Both);
before socket.Disconnect(true);

Original comment by hackw...@gmail.com on 30 Mar 2009 at 7:00

GoogleCodeExporter commented 8 years ago
What happens if you have this instead?
  socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,new
LingerOption(false, 0));
  socket.Disconnect(false);

Original comment by blomman84 on 31 Mar 2009 at 9:45

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
socket.Disconnect(false); still locking application
if I use 
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, 
new 
LingerOption(false, 0));
this works.

Original comment by hackw...@gmail.com on 1 Apr 2009 at 2:31

GoogleCodeExporter commented 8 years ago
what?

Does it or does it not work with those 2 lines? 

Original comment by blomman84 on 1 Apr 2009 at 4:42

GoogleCodeExporter commented 8 years ago
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, 
new 
LingerOption(false, 0)); 
socket.Disconnect(false); - this works

next 2 lines block application
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,new
LingerOption(false, 0));
socket.Disconnect(false);

If i use last 2 lines i cant resume connection after disconnect, it works only 
if 
use Shutdown

Original comment by hackw...@gmail.com on 1 Apr 2009 at 4:45

GoogleCodeExporter commented 8 years ago
ooh...
It should ofcourse be SocketOptionName.DontLinger and not 
SocketOptionName.Linger,
thanks :)
I have also changed back the socket.Disconnect(false) to 
socket.Disconnect(true).

I have commit it to svn :)
Still works?

But i dont understand why you want to resume connection.
If you use TransferManager.EndTransfer() you should not resume a connection.
You should start a new one.

When calling EndTransfer. That transfer is removed from TransferManagers 
collection
of known transfers.

Original comment by blomman84 on 1 Apr 2009 at 4:59

GoogleCodeExporter commented 8 years ago
You right i'm trying to create new conncection, it connects to user but dont 
downloading something in this case.

Original comment by hackw...@gmail.com on 1 Apr 2009 at 5:01

GoogleCodeExporter commented 8 years ago
I have checked it. Now it dont lock application. But if I start new transfer 
after 
that downloads dont starts. 

Original comment by hackw...@gmail.com on 1 Apr 2009 at 5:09

GoogleCodeExporter commented 8 years ago

Original comment by blomman84 on 9 Apr 2009 at 5:10

GoogleCodeExporter commented 8 years ago
Some times when stopping download from 10-20 sources it throws 
NullReferenceException in TcpConnection.cs on line 
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, 
new 
LingerOption(false, 0));
but all values including socket is not null

Original comment by hackw...@gmail.com on 10 Apr 2009 at 2:48

GoogleCodeExporter commented 8 years ago
"But if I start new transfer after that downloads dont starts."
What message do you get on the disconnect event?

"but all values including socket is not null"
strange. Do you have complete exception info?

Original comment by blomman84 on 13 Apr 2009 at 9:17

GoogleCodeExporter commented 8 years ago
After last changes, if download 3 files each from ~20 sources I got exception 
on 
line socket.SetSocketOption(SocketOptionLevel.Socket, 
SocketOptionName.DontLinger, 
new 
LingerOption(false, 0));
where socket is null

Original comment by hackw...@gmail.com on 17 Apr 2009 at 8:36

GoogleCodeExporter commented 8 years ago
"What message do you get on the disconnect event?" how i can get this message? 
flowlib establish connection but dont downloading something. I see it from 
StrongDC 
transfermanager.

Original comment by hackw...@gmail.com on 17 Apr 2009 at 8:55

GoogleCodeExporter commented 8 years ago
After cancelling and following calling StartTransfer all sockets being 
disconnected 
from next line in TcpConnection.cs OnRecieveData:

// If no data was recieved then the connection is probably dead
// Change Connection Status
this.ConnectionStatusChange(this, new FmdcEventArgs(Disconnected));

this line cancels all segments

Original comment by hackw...@gmail.com on 13 May 2009 at 7:17

GoogleCodeExporter commented 8 years ago
why TcpConnection trys to reuse socket after disconnecting?

Original comment by hackw...@gmail.com on 13 May 2009 at 7:28

GoogleCodeExporter commented 8 years ago
fresh news, socket.SetSocketOption(SocketOptionLevel.Socket, 
SocketOptionName.DontLinger, new 
LingerOption(false, 0)); always throws exception optionValue is incorrect

Original comment by hackw...@gmail.com on 13 May 2009 at 9:22

GoogleCodeExporter commented 8 years ago
for now I'm using 
{{{
                e.DisconnectReuseSocket = true;
                if(socket!=null)
                    socket.DisconnectAsync(e);
}}}
without SetSocketOption
It's appear to work. 

Original comment by hackw...@gmail.com on 19 May 2009 at 1:09