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

for QSslSocket, readyRead slot is invoked recursively

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.2.0
    • Network: Sockets
    • None
    • MacOS 10.9, Qt 5.2.0 commercial

    Description

      I have an encrypted SSL communication, that reads data from the socket, but strange behavior of received data duplication is observed. I think the readyRead slot is invoked multiple times recursively when we are already in it and process the event (in contrast to the documentation of QIODevice::readyRead)

      int counter = 0;
      void NetworkManager::onSslData()
      {
      printf("enter onTcpData %d\n", ++counter); fflush(stdout);
      while (mSslSocket.bytesAvailable())

      { QByteArray data = mSslSocket.readAll(); process(data); }


      printf("leave onTcpData %d\n", --counter);fflush(stdout);
      }

      I can see multiple "enter" messages with increasing counter. Then multiple leave messages with decreasing counter. \

      If I implement the slot with disconnect from the readyRead while it is being processed, there is no duplication of data in my program and everything seems to work:
      void NetworkManager::onSslData()
      {
      disconnect(&mSslSocket, &QSslSocket::readyRead, this, &NetworkManager::onSslData);

      .... process ..

      connect(&mSslSocket, &QSslSocket::readyRead, this, &NetworkManager::onSslData);
      }

      Attachments

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

        Activity

          People

            peter-har Peter Hartmann
            neterror Plamen Todorov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes