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

[WinRT] TCP loses initial data

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.8.0 RC
    • 5.6.0, 5.6.1, 5.7.0, 5.8.0 Alpha
    • Network: Sockets
    • None
    • WinRT
    • WinRT
    • dcf7da7c93c0d974bfb72ffa677a1d26fb9be5e0

    Description

      Server accepted TCP sockets drop data on the floor due to incorrect state handling.

      If a client connect and sends data immediately there is a high chance of the initial data being dropped due to socket state being set too late.

      In NativeSocketEngine::initialize the state is changed after setting callback handler, but the callback handler can and will fire immedietely, but since the state hasn't been set the data is just discarded.

      Crude fix:

       QNativeSocketEngine::~QNativeSocketEngine()
      @@ -259,7 +264,7 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::
           // Start processing incoming data
           if (d->socketType == QAbstractSocket::TcpSocket) {
               HRESULT hr;
      -        hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, this]() {
      +        hr = QEventDispatcherWinRT::runOnXamlThread([d, socket, socketState, this]() {
                   ComPtr<IBuffer> buffer;
                   HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer);
                   RETURN_HR_IF_FAILED("initialize(): Could not create buffer");
      @@ -273,6 +278,7 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::
                                     socketDescription(this).constData());
                       return E_FAIL;
                   }
      +            d->socketState = socketState;
                   hr = d->readOp->put_Completed(Callback<SocketReadCompletedHandler>(d, &QNativeSocketEnginePrivate::handleReadyRead).Get());
                   if (FAILED(hr)) {
                       qErrnoWarning(hr, "initialize(): Failed to set socket read callback (%s).",
      @@ -284,9 +290,10 @@ bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::
               if (hr == E_FAIL)
                   return false;
               Q_ASSERT_SUCCEEDED(hr);
      +    } else {
      +        d->socketState = socketState;
           }
       
      -    d->socketState = socketState;
           return true;
       }
      

      Attachments

        For Gerrit Dashboard: QTBUG-55889
        # Subject Branch Project Status CR V

        Activity

          People

            owolff Oliver Wolff
            kristjanbb Kristján Birgisson
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes