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

QWebSocket ping undefined value on time change

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.3.2, 5.4.0 Alpha, 5.4.0 Beta, 5.4.0 RC, 5.4.0, 5.4.1, 5.4.2, 5.5.0 Alpha, 5.5.0 Beta, 5.5.0 RC, 5.5.0, 5.6.0 Alpha, 5.6.0 Beta, 5.6.0 RC, 5.6.0
    • WebSockets
    • None

      QTimer QWebSocketPrivate::m_pingTimer is affected by changes to local time so according to documentation a time change can lead QTime to "undefined result". Time changes can be due to DST, automatic time zone while traveling, clock synchronization (e.g. ntp). The type used should be QElapsedTimer instead.
      Likewise in void QWebSocketPrivate::ping the code is calling m_pingTimer.restart, according to documentation m_PingTimer.start should be used when the previous elapsed value is ignored. see: http://doc.qt.io/qt-5/qtime.html#elapsed (the warning section)

      Steps to reproduce bug:

      abstract_test.cpp
      //this code won't compile and is intended just to demonstrate the idea
      void setup(){
          // WebSocket* socket;
          connect(socket, SIGNAL(pong(quint64,QByteArray)),
                  this,   SLOT(pong(quint64,QByteArray)));
      }
      
      void callPing(){
          socket->ping();
          //somehow modify system time between ping and pong
          //it can even be an automatic system event like DST or ntp sync
          system("date","--set='00:00:00'");
      }
      void pong(quint64 elapsedTime, const QByteArray &payload){
          qWarning()<<"Undefined result"<<elapsedTime;
      }

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

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

              Created:
              Updated:

                There are no open Gerrit changes