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

QSslSocket::waitForReadyRead() does not work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 5.3.1
    • Network: SSL
    • None
    • Debian 7.6 running on Linux beaglebone 3.8.13-bone62 armv7l GNU/Linux

    Description

      Hi

      QSslSocket::waitForReadyRead() seems to be broken in this case:

      // Write message to the socket:
      socket->write(data);
      socket->waitForBytesWritten(msecs);

      // Synchronous wait for response
      socket->waitForReadyRead(msecs);

      waitForReadyRead always waits until timeout and returns false.
      However the other side alredy send response:
      socket->encryptedBytesAvailable() is after timeout greater then 0.
      If i connect slot to socket readRead() signal, i can read data without problems. But i have to use synchronous api this time.

      So received data are already in the QTcpSocket buffer but they are not decrypted until control gets back to the event loop.

      I have fixed this by subclasing QSslSocket and overwrite waitForReadyRead() method (using private headers). Change part is here:

      // test readyReadEmitted first because either operation above
      // (waitForEncrypted or transmit) may have set it
      while (!readyReadEmitted &&
      d->plainSocket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) {
      // FIXED HERE
      if (encryptedBytesAvailable() > 0)

      { d->transmit(); }

      }

      Now waitForReadyRead() works as expected.

      It seems like a bug for me.
      Correct me if i'm wrong.
      Is my solution correct?
      Thanks.

      Attachments

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

        Activity

          People

            jefernan Jesus Fernandez
            dorny Michal Dorner
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes