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

QWebSocket SIGPIPE on QWebSocketPrivate::close due to Timeout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.5
    • WebSockets
    • None
    • CentOS 7

      DevtoolSet 6

    Description

      Context

      I am developping a multithreaded server that serves mass requests from mass clients.

      My WebSocketServer is in an exclusive thread that only unstacks and parses the requests (deserialization) before adding them to a shared structure, then sends a response (within the same thread).

      All the operations are sheduled through signal / slot direct connections, except for the shared structure that is directly used (protected by a QMutex).

      Another thread checks that shared structure and handles the requests.

      Problem

      In the internal event notification from WebSocketServerQAbstractSocketPrivate::flush() leads to a SIGPIPE during to the qt_safe_write_nosignal call.

      The root cause is I try to write to an apparently closed socket while handling the resquests.

      The problem is my server is not notified in time.

      If my client crashes, I must not stop my server process too as I am serving lots of requests from other clients.

      Questions

      So, several questions here:

      • is it due to SIGPIPE that is ignored once only (qt_ignore_sigpipe()) ?
      • how can be several SIGPIPEs then ?
      • is there any mean to work around it ?

      Debug infos

      Here you can find the stack trace:

      {{1 write 0x7f5ee270e85d }}
      {{2 qt_safe_write qcore_unix_p.h 280 0x7f5ee4c7fb41 }}
      {{3 qt_safe_write_nosignal qcore_unix_p.h 289 0x7f5ee4c7fb41 }}
      {{4 QNativeSocketEnginePrivate::nativeWrite qnativesocketengine_unix.cpp 1280 0x7f5ee4c7fb41 }}
      {{5 QNativeSocketEngine::write qnativesocketengine.cpp 918 0x7f5ee4c7bb38 }}
      {{6 QAbstractSocketPrivate::writeToSocket qabstractsocket.cpp 849 0x7f5ee4c68609 }}
      {{7 QAbstractSocketPrivate::flush qabstractsocket.cpp 892 0x7f5ee4c66844 }}
      {{8 QAbstractSocket::flush qabstractsocket.cpp 2460 0x7f5ee4c68788 }}
      {{9 QWebSocketPrivate::close qwebsocket_p.cpp 352 0x7f5ee4b51d6b }}
      {{10 QWebSocketPrivate::processClose qwebsocket_p.cpp 1197 0x7f5ee4b51ee6 }}
      {{11 call qobjectdefs_impl.h 136 0x7f5ee4b58c2c }}
      {{12 call<QtPrivate::List<QWebSocketProtocol::CloseCode, QString const&>, void> qobjectdefs_impl.h 169 0x7f5ee4b58c2c }}
      {{13 QtPrivate::QPrivateSlotObject<void (QWebSocketPrivate:: *)(QWebSocketProtocol::CloseCode, QString), QtPrivate::List<QWebSocketProtocol::CloseCode, QString const&>, void>::impl qobject_p.h 311 0x7f5ee4b58c2c }}
      {{14 call qobject_impl.h 101 0x7f5ee47dd48f }}
      {{15 QMetaObject::activate qobject.cpp 3750 0x7f5ee47dd48f }}
      {{16 QMetaObject::activate qobject.cpp 3629 0x7f5ee47dd92b }}
      {{17 QWebSocketDataProcessor::closeReceived moc_qwebsocketdataprocessor_p.cpp 248 0x7f5ee4b68e2e }}
      {{18 QWebSocketDataProcessor::processControlFrame qwebsocketdataprocessor.cpp 274 0x7f5ee4b656fe }}
      {{19 QWebSocketDataProcessor::process qwebsocketdataprocessor.cpp 131 0x7f5ee4b65920 }}
      {{20 QWebSocketPrivate::processData qwebsocket_p.cpp 1159 0x7f5ee4b5801d }}
      {{21 call qobjectdefs_impl.h 136 0x7f5ee4b58883 }}
      {{22 call<QtPrivate::List<>, void> qobjectdefs_impl.h 169 0x7f5ee4b58883 }}
      {{23 QtPrivate::QPrivateSlotObject<void (QWebSocketPrivate:: *)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void * *, bool *) qobject_p.h 311 0x7f5ee4b58883 }}
      {{24 call qobject_impl.h 101 0x7f5ee47d9015 }}
      {{25 QMetaCallEvent::placeMetaCall qobject.cpp 502 0x7f5ee47d9015 }}
      {{26 QObject::event qobject.cpp 1247 0x7f5ee47dddb2 }}
      {{27 QCoreApplicationPrivate::notify_helper qcoreapplication.cpp 1158 0x7f5ee47ad55b }}
      {{28 doNotify qcoreapplication.cpp 1099 0x7f5ee47ad5e0 }}
      {{29 QCoreApplication::notify qcoreapplication.cpp 1085 0x7f5ee47ad6d1 }}
      {{30 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1024 0x7f5ee47ad67e }}
      {{31 sendEvent qcoreapplication.h 233 0x7f5ee47b28c6 }}
      {{32 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1699 0x7f5ee47b28c6 }}
      {{33 QEventDispatcherUNIX::processEvents qeventdispatcher_unix.cpp 466 0x7f5ee4803b0a }}
      {{34 QEventLoop::processEvents qeventloop.cpp 134 0x7f5ee47ab521 }}
      {{35 QEventLoop::exec qeventloop.cpp 212 0x7f5ee47ab979 }}
      {{36 QThread::exec qthread.cpp 515 0x7f5ee45e0af6 }}
      {{37 QThread::run qthread.cpp 582 0x7f5ee45e0b87 }}
      {{38 QThreadPrivate::start qthread_unix.cpp 368 0x7f5ee45e6e79 }}
      {{39 start_thread 0x7f5ee2410e25 }}
      40 clone

      The close reason is the following:

      QWebSocketProtocol::CloseCodeGoingAway (0x03e9)
      "Timeout when reading data from socket."

       

      Attachments

        Issue Links

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

          Activity

            People

              kurt.pattyn Kurt Pattyn
              tireur2litres Nicolas Ferrero
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes