Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7815

QLocalSocket on Win32 destructor doesn't close the socket

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.3
    • 4.6.1
    • Network
    • None
    • Win32
      VC9
    • c09ef77cd271c47cb3c2607553dab669d6cbcddc

    Description

      A QLocalSocket on Win32 will not actually be closed when deleted

      If you have a QLocalSocket which has unflushed data to be written, QLocalSocket::close(), which is called from the destructor, diverts to disconnectFromHost. However, as this is done from the desctructor and the object is now deleted, the pipewriter will never signal the deleted object that it has finished writing, meaning things like CloseHandle(d->handle) never gets called, leaking local resources and incorrectly giving the other end of the pipe the impression the connection is still maintained.
      Furthermore, QLocalSocket::abort() just calls close(), meaning that instead of disconnecting immediately, it disconnects as soon as all data has been written, which is the opposite of what it's documentation states.

      To work around this, you need to have an object call close() on the socket, then wait for it to emit its disconnected signal before actually deleting the socket.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jbornema Joerg Bornemann
            slicer Thorvald Natvig
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes