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

QWebSocketServer internal queued connections possibly break API

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.8.0
    • WebSockets
    • None

    Description

      I have ran to an issue, when i was checking if there still was a leak problem, opening and closing many of simultaneous connections. There is a case, that client webscoket might disconnect right after handshake, but before &QWebSocketServerPrivate::handshakeReceived invocation. And so QWebSocketServer::nextPendingConnection will return a socket instance, which state is QAbstractSocket::ClosingState. This contradicts QWebSocketServer detailed description, which says that returned socket instance is in QAbstractSocket::ConnectedState.
      This happens because of &QTcpSocket::readyRead connection to &QWebSocketServerPrivate::handshakeReceived in qwebsocketserver_p.cpp at line 490 is queued.
      This leads to a leak. One manages QWebSocket instance deletion on QWebSocket::disconnected signal by calling deleteLater(). Such an instance from the case above would persist, because the disconnected signal was already emitted, before one even got an opportunity to connect to it on QWebSocketServer::newConnection signal handler.
      It might be worth checking socket state before emitting newConnection signal or switch back to direct internal signal/slot connections. Please, note, that QTcpServer doesn't have this problem by design due to queued connections absence.

      Attachments

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

        Activity

          People

            kurt.pattyn Kurt Pattyn
            danilshkodin danilshkodin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes