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

QWebSocketServer (Qt7): the QWebSockets it returns should be parented to the server

    XMLWordPrintable

Details

    Description

      With QTcpServer, and other servers, the sockets that they return on new established connection all have their lifetime tied to the server.

      QWebSocketServer, however, does not act this way and, upon destruction, leaves the QWebSockets alive but useless since the internal QTcpServer will destroy the QTcpSockets internal to the QWebSockets!
      The websocket code works around crashes by checking the QTcpSocket::destroyed signal and then unsetting the socket and making sure, everywhere, that the socket is not null.

      This inconsistency makes it harder to get things right without checking documentation when writing code that deals with both behaviors.

      So, the ideal way to fix this would be to simply:
      1. Set the server as parent of the QWebSockets returned from https://doc.qt.io/qt-6/qwebsocketserver.html#nextPendingConnection
      2. Update documentation

      However, there may now be code in the wild that are relying on https://doc.qt.io/qt-6/qwebsocket.html#isValid to tell them if the internal TcpSocket is deallocated.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            manordheim MÃ¥rten Nordheim
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes