Results 1 to 3 of 3

Thread: 'Losing' sockets in Qt torrent example / QTcpServer

  1. #1
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default 'Losing' sockets in Qt torrent example / QTcpServer

    Hi, I have a strange problem with the Trolltech examples/network/torrent code. I took the code to build my own bittorrent client with it. But something is not right either with the code, with QTcpServer or with my computer. I doubt the last.

    When the program runs for a while, sockets in close_wait states pile up. Sooner or later I get a 'too many files open' error message and the program stops.

    Now I logged all addresses/ports of all incoming and outgoing peers. These are either the connections I initiate with the peer list I get from the tracker, or incoming connections, which are initiated by other peers.

    The problem is I never see the close_wait sockets in my logs. In my program they simply don't exist (the address/port pair).

    How likely is it that this is some sort of race bug in QTcpServer? It accepts a connection, but somehow 'swallows' the notification sometimes. My program never sees those swallowed connections, sends no data and the peer closes the connection on his side. The socket remains in close_wait forever and I cannot close it manually since it is unreachable for me.


    Found the bug. QTcpServer is ok.
    Last edited by Kumosan; 13th August 2007 at 21:02.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: 'Losing' sockets in Qt torrent example / QTcpServer

    What was the problem?

  3. #3
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 38 Times in 30 Posts

    Smile Re: 'Losing' sockets in Qt torrent example / QTcpServer

    This bug was recently reported, and will be fixed in the next Qt release. Basically there's a bug in torrentserver.cpp, swap the two ifs (if (socket.setSocketDescriptor()) should go before the if (canAddConnection)).

    The bug is that the server implementation in this example doesn't close the sockets if it doesn't have room for it. So it leaks sockets until it can no longer create more.
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.