wasm: enable Network for nothread
Task-number: QTBUG-70208 Change-Id: Ib73ca0d3c0736336bf517ffb968cbdbab4610319 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>bb10
parent
9c72ae61aa
commit
cd60b78765
|
|
@ -1169,7 +1169,6 @@
|
|||
},
|
||||
"network": {
|
||||
"label": "Qt Network",
|
||||
"condition": "features.thread",
|
||||
"output": [ "privateFeature" ]
|
||||
},
|
||||
"sql": {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
Q_GLOBAL_STATIC(QDnsLookupThreadPool, theDnsLookupThreadPool);
|
||||
#endif
|
||||
|
||||
static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2)
|
||||
{
|
||||
|
|
@ -503,7 +505,9 @@ void QDnsLookup::lookup()
|
|||
connect(d->runnable, SIGNAL(finished(QDnsLookupReply)),
|
||||
this, SLOT(_q_lookupFinished(QDnsLookupReply)),
|
||||
Qt::BlockingQueuedConnection);
|
||||
#if QT_CONFIG(thread)
|
||||
theDnsLookupThreadPool()->start(d->runnable);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -1016,6 +1020,7 @@ void QDnsLookupRunnable::run()
|
|||
emit finished(reply);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
QDnsLookupThreadPool::QDnsLookupThreadPool()
|
||||
: signalsConnected(false)
|
||||
{
|
||||
|
|
@ -1051,7 +1056,7 @@ void QDnsLookupThreadPool::_q_applicationDestroyed()
|
|||
waitForDone();
|
||||
signalsConnected = false;
|
||||
}
|
||||
|
||||
#endif // QT_CONFIG(thread)
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qdnslookup.cpp"
|
||||
|
|
|
|||
|
|
@ -55,7 +55,9 @@
|
|||
#include "QtCore/qmutex.h"
|
||||
#include "QtCore/qrunnable.h"
|
||||
#include "QtCore/qsharedpointer.h"
|
||||
#if QT_CONFIG(thread)
|
||||
#include "QtCore/qthreadpool.h"
|
||||
#endif
|
||||
#include "QtNetwork/qdnslookup.h"
|
||||
#include "QtNetwork/qhostaddress.h"
|
||||
#include "private/qobject_p.h"
|
||||
|
|
@ -132,6 +134,7 @@ private:
|
|||
QHostAddress nameserver;
|
||||
};
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
class QDnsLookupThreadPool : public QThreadPool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -147,6 +150,7 @@ private:
|
|||
QMutex signalsMutex;
|
||||
bool signalsConnected;
|
||||
};
|
||||
#endif // QT_CONFIG(thread)
|
||||
|
||||
class QDnsRecordPrivate : public QSharedData
|
||||
{
|
||||
|
|
|
|||
|
|
@ -704,6 +704,7 @@ void QHostInfoRunnable::run()
|
|||
hostInfo.setLookupId(id);
|
||||
resultEmitter.emitResultsReady(hostInfo);
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
// now also iterate through the postponed ones
|
||||
{
|
||||
QMutexLocker locker(&manager->mutex);
|
||||
|
|
@ -720,6 +721,7 @@ void QHostInfoRunnable::run()
|
|||
manager->postponedLookups.erase(partitionBegin, partitionEnd);
|
||||
}
|
||||
|
||||
#endif
|
||||
manager->lookupFinished(this);
|
||||
|
||||
// thread goes back to QThreadPool
|
||||
|
|
@ -728,8 +730,10 @@ void QHostInfoRunnable::run()
|
|||
QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false)
|
||||
{
|
||||
moveToThread(QCoreApplicationPrivate::mainThread());
|
||||
#if QT_CONFIG(thread)
|
||||
connect(QCoreApplication::instance(), SIGNAL(destroyed()), SLOT(waitForThreadPoolDone()), Qt::DirectConnection);
|
||||
threadPool.setMaxThreadCount(20); // do up to 20 DNS lookups in parallel
|
||||
#endif
|
||||
}
|
||||
|
||||
QHostInfoLookupManager::~QHostInfoLookupManager()
|
||||
|
|
@ -744,15 +748,19 @@ void QHostInfoLookupManager::clear()
|
|||
{
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
qDeleteAll(postponedLookups);
|
||||
qDeleteAll(scheduledLookups);
|
||||
qDeleteAll(finishedLookups);
|
||||
#if QT_CONFIG(thread)
|
||||
qDeleteAll(postponedLookups);
|
||||
postponedLookups.clear();
|
||||
#endif
|
||||
scheduledLookups.clear();
|
||||
finishedLookups.clear();
|
||||
}
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
threadPool.waitForDone();
|
||||
#endif
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
|
|
@ -776,6 +784,7 @@ void QHostInfoLookupManager::work()
|
|||
finishedLookups.clear();
|
||||
}
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
auto isAlreadyRunning = [this](QHostInfoRunnable *lookup) {
|
||||
return any_of(currentLookups.cbegin(), currentLookups.cend(), ToBeLookedUpEquals(lookup->toBeLookedUp));
|
||||
};
|
||||
|
|
@ -808,6 +817,10 @@ void QHostInfoLookupManager::work()
|
|||
}
|
||||
scheduledLookups.erase(scheduledLookups.begin(), it);
|
||||
}
|
||||
#else
|
||||
if (!scheduledLookups.isEmpty())
|
||||
scheduledLookups.takeFirst()->run();
|
||||
#endif
|
||||
}
|
||||
|
||||
// called by QHostInfo
|
||||
|
|
@ -829,6 +842,7 @@ void QHostInfoLookupManager::abortLookup(int id)
|
|||
|
||||
QMutexLocker locker(&this->mutex);
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
// is postponed? delete and return
|
||||
for (int i = 0; i < postponedLookups.length(); i++) {
|
||||
if (postponedLookups.at(i)->id == id) {
|
||||
|
|
@ -836,6 +850,7 @@ void QHostInfoLookupManager::abortLookup(int id)
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// is scheduled? delete and return
|
||||
for (int i = 0; i < scheduledLookups.length(); i++) {
|
||||
|
|
@ -866,7 +881,9 @@ void QHostInfoLookupManager::lookupFinished(QHostInfoRunnable *r)
|
|||
return;
|
||||
|
||||
QMutexLocker locker(&this->mutex);
|
||||
#if QT_CONFIG(thread)
|
||||
currentLookups.removeOne(r);
|
||||
#endif
|
||||
finishedLookups.append(r);
|
||||
work();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@
|
|||
#include "QtCore/qobject.h"
|
||||
#include "QtCore/qpointer.h"
|
||||
#include "QtCore/qthread.h"
|
||||
#if QT_CONFIG(thread)
|
||||
#include "QtCore/qthreadpool.h"
|
||||
#endif
|
||||
#include "QtCore/qrunnable.h"
|
||||
#include "QtCore/qlist.h"
|
||||
#include "QtCore/qqueue.h"
|
||||
|
|
@ -238,20 +240,25 @@ public:
|
|||
|
||||
friend class QHostInfoRunnable;
|
||||
protected:
|
||||
#if QT_CONFIG(thread)
|
||||
QList<QHostInfoRunnable*> currentLookups; // in progress
|
||||
QList<QHostInfoRunnable*> postponedLookups; // postponed because in progress for same host
|
||||
#endif
|
||||
QQueue<QHostInfoRunnable*> scheduledLookups; // not yet started
|
||||
QList<QHostInfoRunnable*> finishedLookups; // recently finished
|
||||
QList<int> abortedLookups; // ids of aborted lookups
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
QThreadPool threadPool;
|
||||
|
||||
#endif
|
||||
QMutex mutex;
|
||||
|
||||
bool wasDeleted;
|
||||
|
||||
private slots:
|
||||
#if QT_CONFIG(thread)
|
||||
void waitForThreadPoolDone() { threadPool.waitForDone(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -44,8 +44,9 @@
|
|||
#include "qsslkey_p.h"
|
||||
#include "qsslcertificateextension_p.h"
|
||||
|
||||
#if QT_CONFIG(thread)
|
||||
#include <QtCore/private/qmutexpool_p.h>
|
||||
|
||||
#endif
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// forward declaration
|
||||
|
|
@ -90,7 +91,9 @@ bool QSslCertificate::isSelfSigned() const
|
|||
|
||||
QByteArray QSslCertificate::version() const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
if (d->versionString.isEmpty() && d->x509)
|
||||
d->versionString = QByteArray::number(qlonglong(q_X509_get_version(d->x509)) + 1);
|
||||
|
||||
|
|
@ -99,7 +102,9 @@ QByteArray QSslCertificate::version() const
|
|||
|
||||
QByteArray QSslCertificate::serialNumber() const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
if (d->serialNumberString.isEmpty() && d->x509) {
|
||||
ASN1_INTEGER *serialNumber = q_X509_get_serialNumber(d->x509);
|
||||
QByteArray hexString;
|
||||
|
|
@ -116,7 +121,9 @@ QByteArray QSslCertificate::serialNumber() const
|
|||
|
||||
QStringList QSslCertificate::issuerInfo(SubjectInfo info) const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
// lazy init
|
||||
if (d->issuerInfo.isEmpty() && d->x509)
|
||||
d->issuerInfo =
|
||||
|
|
@ -127,7 +134,9 @@ QStringList QSslCertificate::issuerInfo(SubjectInfo info) const
|
|||
|
||||
QStringList QSslCertificate::issuerInfo(const QByteArray &attribute) const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
// lazy init
|
||||
if (d->issuerInfo.isEmpty() && d->x509)
|
||||
d->issuerInfo =
|
||||
|
|
@ -138,7 +147,9 @@ QStringList QSslCertificate::issuerInfo(const QByteArray &attribute) const
|
|||
|
||||
QStringList QSslCertificate::subjectInfo(SubjectInfo info) const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
// lazy init
|
||||
if (d->subjectInfo.isEmpty() && d->x509)
|
||||
d->subjectInfo =
|
||||
|
|
@ -149,7 +160,9 @@ QStringList QSslCertificate::subjectInfo(SubjectInfo info) const
|
|||
|
||||
QStringList QSslCertificate::subjectInfo(const QByteArray &attribute) const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
// lazy init
|
||||
if (d->subjectInfo.isEmpty() && d->x509)
|
||||
d->subjectInfo =
|
||||
|
|
@ -160,7 +173,9 @@ QStringList QSslCertificate::subjectInfo(const QByteArray &attribute) const
|
|||
|
||||
QList<QByteArray> QSslCertificate::subjectInfoAttributes() const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
// lazy init
|
||||
if (d->subjectInfo.isEmpty() && d->x509)
|
||||
d->subjectInfo =
|
||||
|
|
@ -171,7 +186,9 @@ QList<QByteArray> QSslCertificate::subjectInfoAttributes() const
|
|||
|
||||
QList<QByteArray> QSslCertificate::issuerInfoAttributes() const
|
||||
{
|
||||
#if QT_CONFIG(thread)
|
||||
QMutexLocker lock(QMutexPool::globalInstanceGet(d.data()));
|
||||
#endif
|
||||
// lazy init
|
||||
if (d->issuerInfo.isEmpty() && d->x509)
|
||||
d->issuerInfo =
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@
|
|||
# include <QtCore/qlibrary.h>
|
||||
#endif
|
||||
#include <QtCore/qmutex.h>
|
||||
#if QT_CONFIG(thread)
|
||||
#include <private/qmutexpool_p.h>
|
||||
#endif
|
||||
#include <QtCore/qdatetime.h>
|
||||
#if defined(Q_OS_UNIX)
|
||||
#include <QtCore/qdir.h>
|
||||
|
|
@ -903,10 +905,12 @@ bool q_resolveOpenSslSymbols()
|
|||
{
|
||||
static bool symbolsResolved = false;
|
||||
static bool triedToResolveSymbols = false;
|
||||
#if QT_CONFIG(thread)
|
||||
#if QT_CONFIG(opensslv11)
|
||||
QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_OPENSSL_init_ssl));
|
||||
#else
|
||||
QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_SSL_library_init));
|
||||
#endif
|
||||
#endif
|
||||
if (symbolsResolved)
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue