Closed whyrusleeping closed 8 years ago
Hm good catch, I never use that part of the code. The logic behind Socket has changed a lot since that function was first written. Now the underlying "real" file descriptor should not be closed until all the uTP connections hanging from it (utp.Conn) are also closed and finalized. It should be sufficient to close the Socket as soon as a Conn is created by dialing on it.
@anacrolix so even though we call Close
on the socket, it wont actually close until the Conn
gets closed?
That's how it currently works. Of course if you use Dial() or DialTimeout() without your own Socket, one is made for you, and it appears that is never closed. I'm constructing a test for it now.
Well that was a deep rabbit hole. Please let me know if the commits I made address your problem. In particular ca69c553ddfe8406a28819ec0cb1fc198ea14628 fixes this, and the others fix a bunch of related stuff.
Thank you so much! I should have that integrated into go-ipfs by the end of the day. I'll test it out and let you know
calling
Dial
opens a new socket, then calls dial on that socket. closing the returned connection doesnt appear to close the opened socket, leading to a file descriptor leak.