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

Network operation returns ProtocolUnknownError error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Duplicate
    • Affects Version/s: 4.7.0
    • Fix Version/s: 4.8.0, 5.0.0
    • Component/s: Network
    • Labels:
      None

      Description

      The problem is QNetworkAccessManagerPrivate::findBackend() returns NULL because factoryDataShutdown = true.

      factoryDataShutdown is set to true due a bug.

      This is the relevant code in qnetworkaccessbackend.cpp:

      static bool factoryDataShutdown = false;
      class QNetworkAccessBackendFactoryData: public QList<QNetworkAccessBackendFactory *>
      {
      public:
      QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) { }
      ~QNetworkAccessBackendFactoryData()

      { QMutexLocker locker(&mutex); // why do we need to lock? factoryDataShutdown = true; }

      QMutex mutex;
      };
      Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData)

      So, when a QNetworkAccessBackendFactoryData object is deleted, it sets factoryDataShutdown to true.

      Now here is the code for Q_GLOBAL_STATIC():

      #define Q_GLOBAL_STATIC(TYPE, NAME) \
      Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
      static TYPE *NAME() \
      { \
      if (!this_##NAME.pointer && !this_##NAME.destroyed)

      { \ TYPE *x = new TYPE; \ if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \ delete x; \ else \ static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \ }

      \
      return this_##NAME.pointer; \
      }

      So if 2 threads try to create the pointer at the same time, one of them will call "delete x".

      In the case of QNetworkAccessBackendFactoryData() this disables the backend factory (on program startup) by setting factoryDataShutdown = true.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              earthdomain Earth Domain (Inactive)
              Reporter:
              paul-mccullagh Paul McCullagh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes