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

QAbstractSocket::Unbuffered is ignored when using setSocketDescriptor()

    XMLWordPrintable

Details

    Description

      When using

      connectToHost()
      

      QAbstractSocket::isBuffered gets set correctly. But when one uses

      setSocketDescriptor(desc, QAsbtractSocket::ConnectedState, QAbstractSocket::ReadWrite | QAbstractSocket::Unbuffered);
      

      the variable isBuffered doesn't get set.

      Thus when calling waitForDisconnected() on an unbuffered QTcpSocket, canReadNotification() calls readFromSocket() and as no data is available, 4096 bytes get allocated. In a scenario where hundreds of sockets are used, this pollutes memory a lot.

      The following code in setSocketDescriptor() right before return true; would solve the problem:

      d->isBuffered = !(openMode & Unbuffered);
      

      Attachments

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

        Activity

          People

            peter-har Peter Hartmann
            hardcorevirus Oliver Becker
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes