Summary: | Socket file descriptor leak in ktorrent | ||
---|---|---|---|
Product: | [Applications] ktorrent | Reporter: | Rickard Närström <rickard.narstrom> |
Component: | general | Assignee: | Joris Guisson <joris.guisson> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | getaceres |
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Rickard Närström
2008-01-19 09:20:22 UTC
*** Bug 156331 has been marked as a duplicate of this bug. *** SVN commit 764849 by guisson: Fix problem with connections staying in close_wait state BUG: 156163 M +4 -0 socket.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=764849 This is still a problem in ktorrent 3.0rc1 I'm not seeing it happening, and I'm absolutely sure then when you stop a torrent, all it's sockets are closed. No they are not... I have just confirmed that after stopping all torrents ktorrent still have 369 fd's open to sockets in CLOSE_WAIT and 55 to sockets in ESTABLISHED. This only hapens with local connections, remote connections are close properly. So you will not see this if you are behind a firewall. This is properly unrelated but ktorrent dosn't seem to use SO_REUSEADDR for listening connection, if I close ktorrent and start it again it fails to bind to the listening port and a "address already in use" error is written to the log. Sorry, my mistake... it only hapens with remote connections, not with local connections. -- All sockets in CLOSE_WAIT are bound to ktorrents listening port. I found it!! in bt::Server::newConnection(int) (server.cpp line 116) you call the mse::StreamSocket(int) constructor with the fd as only argument, however mse::StreamSocket(int) expect ip-version as only argument not a fd. The fd is after that lost and left open, authentication with that host fails as the socket is not connected. I have for now work around this by applaing this patch, it works for me as I don't use IPv6. You probebly should check the ip-version of the listening socket and use that instead: ---- diff -Naur ktorrent-3.0rc1/libbtcore/torrent/server.cpp ktorrent-3.0rc1.patched/libbtcore/torrent/server.cpp --- ktorrent-3.0rc1/libbtcore/torrent/server.cpp 2008-01-27 12:56:51.000000000 +0100 +++ ktorrent-3.0rc1.patched/libbtcore/torrent/server.cpp 2008-01-27 21:32:30.000000000 +0100 @@ -113,7 +113,7 @@ void Server::newConnection(int socket) { - mse::StreamSocket* s = new mse::StreamSocket(socket); + mse::StreamSocket* s = new mse::StreamSocket(socket, 4); if (peer_managers.count() == 0) { s->close(); SVN commit 767757 by guisson: Fix socket descriptor leak, big thanks to Richard Narstrom for finding the problem and the solution BUG: 156163 M +1 -0 ktorrent/main.cpp M +1 -1 libbtcore/torrent/server.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=767757 |