summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp39
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h2
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp10
-rw-r--r--src/network/access/qhttpnetworkreply.cpp3
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp13
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h4
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp7
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp13
-rw-r--r--src/network/access/qnetworkaccesshttpbackend_p.h3
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp27
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp8
-rw-r--r--src/network/access/qnetworkrequest.cpp52
-rw-r--r--src/network/access/qnetworkrequest.h7
-rw-r--r--src/network/kernel/qhostinfo.cpp33
-rw-r--r--src/network/kernel/qhostinfo_p.h4
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp1
-rw-r--r--src/network/kernel/qhostinfo_win.cpp1
-rw-r--r--src/network/socket/qlocalserver_win.cpp2
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp3
-rw-r--r--src/network/socket/qtcpserver.cpp18
-rw-r--r--src/network/socket/qtcpserver.h1
22 files changed, 209 insertions, 43 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 559124f..1afabec 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -343,9 +343,16 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket
copyCredentials(i, auth, isProxy);
QMetaObject::invokeMethod(q, "_q_restartAuthPendingRequests", Qt::QueuedConnection);
}
+ } else if (priv->phase == QAuthenticatorPrivate::Start) {
+ // If the url's authenticator has a 'user' set we will end up here (phase is only set to 'Done' by
+ // parseHttpResponse above if 'user' is empty). So if credentials were supplied with the request,
+ // such as in the case of an XMLHttpRequest, this is our only opportunity to cache them.
+ emit q->cacheCredentials(reply->request(), auth, q);
}
- // changing values in QAuthenticator will reset the 'phase'
- if (priv->phase == QAuthenticatorPrivate::Done) {
+ // - Changing values in QAuthenticator will reset the 'phase'.
+ // - If withCredentials has been set to false (e.g. by QtWebKit for a cross-origin XMLHttpRequest) then
+ // we need to bail out if authentication is required.
+ if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) {
// authentication is cancelled, send the current contents to the user.
emit channels[i].reply->headerChanged();
emit channels[i].reply->readyRead();
@@ -716,6 +723,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply)
// This function must be called from the event loop. The only
// exception is documented in QHttpNetworkConnectionPrivate::queueRequest
+// although it is called _q_startNextRequest, it will actually start multiple requests when possible
void QHttpNetworkConnectionPrivate::_q_startNextRequest()
{
//resend the necessary ones.
@@ -733,26 +741,23 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
// dequeue new ones
- QAbstractSocket *socket = 0;
+ // return fast if there is nothing to do
+ if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
+ return;
+ // try to get a free AND connected socket
for (int i = 0; i < channelCount; ++i) {
- QAbstractSocket *chSocket = channels[i].socket;
- // try to get a free AND connected socket
if (!channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {
- socket = chSocket;
- dequeueAndSendRequest(socket);
- break;
+ dequeueAndSendRequest(channels[i].socket);
}
}
- if (!socket) {
- for (int i = 0; i < channelCount; ++i) {
- QAbstractSocket *chSocket = channels[i].socket;
- // try to get a free unconnected socket
- if (!channels[i].isSocketBusy()) {
- socket = chSocket;
- dequeueAndSendRequest(socket);
- break;
- }
+ // return fast if there is nothing to do
+ if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
+ return;
+ // try to get a free unconnected socket
+ for (int i = 0; i < channelCount; ++i) {
+ if (!channels[i].isSocketBusy()) {
+ dequeueAndSendRequest(channels[i].socket);
}
}
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index b5bd300..51666d6 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -133,6 +133,8 @@ Q_SIGNALS:
#endif
void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator,
const QHttpNetworkConnection *connection = 0);
+ void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator,
+ const QHttpNetworkConnection *connection = 0);
void error(QNetworkReply::NetworkError errorCode, const QString &detail = QString());
private:
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 3b7bc9e..d3576dd 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -173,7 +173,7 @@ bool QHttpNetworkConnectionChannel::sendRequest()
pendingEncrypt = false;
// if the url contains authentication parameters, use the new ones
// both channels will use the new authentication parameters
- if (!request.url().userInfo().isEmpty()) {
+ if (!request.url().userInfo().isEmpty() && request.withCredentials()) {
QUrl url = request.url();
QAuthenticator &auth = authenticator;
if (url.userName() != auth.user()
@@ -187,7 +187,10 @@ bool QHttpNetworkConnectionChannel::sendRequest()
url.setUserInfo(QString());
request.setUrl(url);
}
- connection->d_func()->createAuthorization(socket, request);
+ // Will only be false if QtWebKit is performing a cross-origin XMLHttpRequest
+ // and withCredentials has not been set to true.
+ if (request.withCredentials())
+ connection->d_func()->createAuthorization(socket, request);
#ifndef QT_NO_NETWORKPROXY
QByteArray header = QHttpNetworkRequestPrivate::header(request,
(connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy));
@@ -291,7 +294,8 @@ bool QHttpNetworkConnectionChannel::sendRequest()
// ensure we try to receive a reply in all cases, even if _q_readyRead_ hat not been called
// this is needed if the sends an reply before we have finished sending the request. In that
// case receiveReply had been called before but ignored the server reply
- QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection);
+ if (socket->bytesAvailable())
+ QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection);
break;
}
case QHttpNetworkConnectionChannel::ReadingState:
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 338236e..108ba8a 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -179,6 +179,9 @@ qint64 QHttpNetworkReply::bytesAvailableNextBlock() const
QByteArray QHttpNetworkReply::readAny()
{
Q_D(QHttpNetworkReply);
+ if (d->responseData.bufferCount() == 0)
+ return QByteArray();
+
// we'll take the last buffer, so schedule another read from http
if (d->downstreamLimited && d->responseData.bufferCount() == 1)
d->connection->d_func()->readMoreLater(this);
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index 9eb2399..639025e 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
QHttpNetworkRequest::Priority pri, const QUrl &newUrl)
: QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0),
- autoDecompress(false), pipeliningAllowed(false)
+ autoDecompress(false), pipeliningAllowed(false), withCredentials(true)
{
}
@@ -62,6 +62,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest
autoDecompress = other.autoDecompress;
pipeliningAllowed = other.pipeliningAllowed;
customVerb = other.customVerb;
+ withCredentials = other.withCredentials;
}
QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate()
@@ -274,6 +275,16 @@ void QHttpNetworkRequest::setPipeliningAllowed(bool b)
d->pipeliningAllowed = b;
}
+bool QHttpNetworkRequest::withCredentials() const
+{
+ return d->withCredentials;
+}
+
+void QHttpNetworkRequest::setWithCredentials(bool b)
+{
+ d->withCredentials = b;
+}
+
void QHttpNetworkRequest::setUploadByteDevice(QNonContiguousByteDevice *bd)
{
d->uploadByteDevice = bd;
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index 1b35a84..15cab73 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -113,6 +113,9 @@ public:
bool isPipeliningAllowed() const;
void setPipeliningAllowed(bool b);
+ bool withCredentials() const;
+ void setWithCredentials(bool b);
+
void setUploadByteDevice(QNonContiguousByteDevice *bd);
QNonContiguousByteDevice* uploadByteDevice() const;
@@ -142,6 +145,7 @@ public:
mutable QNonContiguousByteDevice* uploadByteDevice;
bool autoDecompress;
bool pipeliningAllowed;
+ bool withCredentials;
};
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index f188bd5..60f7dc6 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -74,7 +74,7 @@ Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData)
QNetworkAccessBackendFactory::QNetworkAccessBackendFactory()
{
QMutexLocker locker(&factoryData()->mutex);
- factoryData()->prepend(this);
+ factoryData()->append(this);
}
QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory()
@@ -327,6 +327,11 @@ void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator
manager->authenticationRequired(this, authenticator);
}
+void QNetworkAccessBackend::cacheCredentials(QAuthenticator *authenticator)
+{
+ manager->addCredentials(this->reply->url, authenticator);
+}
+
void QNetworkAccessBackend::metaDataChanged()
{
reply->metaDataChanged();
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index 4ce37a6..4fe6de6 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -188,6 +188,7 @@ protected slots:
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
#endif
void authenticationRequired(QAuthenticator *auth);
+ void cacheCredentials(QAuthenticator *auth);
void metaDataChanged();
void redirectionRequested(const QUrl &destination);
void sslErrors(const QList<QSslError> &errors);
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 3154ed6..a6c5c02 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -346,6 +346,8 @@ void QNetworkAccessHttpBackend::setupConnection()
#endif
connect(http, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)),
SLOT(httpAuthenticationRequired(QHttpNetworkRequest,QAuthenticator*)));
+ connect(http, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)),
+ SLOT(httpCacheCredentials(QHttpNetworkRequest,QAuthenticator*)));
connect(http, SIGNAL(error(QNetworkReply::NetworkError,QString)),
SLOT(httpError(QNetworkReply::NetworkError,QString)));
#ifndef QT_NO_OPENSSL
@@ -578,6 +580,11 @@ void QNetworkAccessHttpBackend::postRequest()
if (request().attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool() == true)
httpRequest.setPipeliningAllowed(true);
+ if (static_cast<QNetworkRequest::LoadControl>
+ (request().attribute(QNetworkRequest::AuthenticationReuseAttribute,
+ QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual)
+ httpRequest.setWithCredentials(false);
+
httpReply = http->sendRequest(httpRequest);
httpReply->setParent(this);
#ifndef QT_NO_OPENSSL
@@ -861,6 +868,12 @@ void QNetworkAccessHttpBackend::httpAuthenticationRequired(const QHttpNetworkReq
authenticationRequired(auth);
}
+void QNetworkAccessHttpBackend::httpCacheCredentials(const QHttpNetworkRequest &,
+ QAuthenticator *auth)
+{
+ cacheCredentials(auth);
+}
+
void QNetworkAccessHttpBackend::httpError(QNetworkReply::NetworkError errorCode,
const QString &errorString)
{
diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h
index e5cc0ab..c4c88ae 100644
--- a/src/network/access/qnetworkaccesshttpbackend_p.h
+++ b/src/network/access/qnetworkaccesshttpbackend_p.h
@@ -94,8 +94,6 @@ public:
#endif
QNetworkCacheMetaData fetchCacheMetaData(const QNetworkCacheMetaData &metaData) const;
- qint64 deviceReadData(char *buffer, qint64 maxlen);
-
// we return true since HTTP needs to send PUT/POST data again after having authenticated
bool needsResetableUploadData() { return true; }
@@ -107,6 +105,7 @@ private slots:
void replyFinished();
void replyHeaderChanged();
void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth);
+ void httpCacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *auth);
void httpError(QNetworkReply::NetworkError error, const QString &errorString);
bool sendCacheContents(const QNetworkCacheMetaData &metaData);
void finished(); // override
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index feb9d99..1c7661d 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -948,10 +948,15 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
// but the data that is outgoing is random-access
request.setHeader(QNetworkRequest::ContentLengthHeader, outgoingData->size());
}
- if (d->cookieJar) {
- QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url());
- if (!cookies.isEmpty())
- request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
+
+ if (static_cast<QNetworkRequest::LoadControl>
+ (request.attribute(QNetworkRequest::CookieLoadControlAttribute,
+ QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) {
+ if (d->cookieJar) {
+ QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url());
+ if (!cookies.isEmpty())
+ request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
+ }
}
// first step: create the reply
@@ -967,11 +972,15 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
priv->manager = this;
// second step: fetch cached credentials
- QNetworkAuthenticationCredential *cred = d->fetchCachedCredentials(url);
- if (cred) {
- url.setUserName(cred->user);
- url.setPassword(cred->password);
- priv->urlForLastAuthentication = url;
+ if (static_cast<QNetworkRequest::LoadControl>
+ (request.attribute(QNetworkRequest::AuthenticationReuseAttribute,
+ QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) {
+ QNetworkAuthenticationCredential *cred = d->fetchCachedCredentials(url);
+ if (cred) {
+ url.setUserName(cred->user);
+ url.setPassword(cred->password);
+ priv->urlForLastAuthentication = url;
+ }
}
// third step: find a backend
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 128d18f..31ee2a4 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -673,8 +673,12 @@ void QNetworkReplyImplPrivate::error(QNetworkReplyImpl::NetworkError code, const
void QNetworkReplyImplPrivate::metaDataChanged()
{
Q_Q(QNetworkReplyImpl);
- // do we have cookies?
- if (cookedHeaders.contains(QNetworkRequest::SetCookieHeader) && !manager.isNull()) {
+ // 1. do we have cookies?
+ // 2. are we allowed to set them?
+ if (cookedHeaders.contains(QNetworkRequest::SetCookieHeader) && !manager.isNull()
+ && (static_cast<QNetworkRequest::LoadControl>
+ (request.attribute(QNetworkRequest::CookieSaveControlAttribute,
+ QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic)) {
QList<QNetworkCookie> cookies =
qvariant_cast<QList<QNetworkCookie> >(cookedHeaders.value(QNetworkRequest::SetCookieHeader));
QNetworkCookieJar *jar = manager->cookieJar();
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 61c116d..911eadc 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -190,6 +190,46 @@ QT_BEGIN_NAMESPACE
of other verbs than GET, POST, PUT and DELETE). This verb is set
when calling QNetworkAccessManager::sendCustomRequest().
+ \value CookieLoadControlAttribute
+ Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic)
+ Indicates whether to send 'Cookie' headers in the request.
+
+ This attribute is set to false by QtWebKit when creating a cross-origin
+ XMLHttpRequest where withCredentials has not been set explicitly to true by the
+ Javascript that created the request.
+
+ See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information.
+
+ \since 4.7
+
+ \value CookieSaveControlAttribute
+ Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic)
+ Indicates whether to save 'Cookie' headers received from the server in reply
+ to the request.
+
+ This attribute is set to false by QtWebKit when creating a cross-origin
+ XMLHttpRequest where withCredentials has not been set explicitly to true by the
+ Javascript that created the request.
+
+ See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information.
+
+ \since 4.7
+
+ \value AuthenticationReuseControlAttribute
+ Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic)
+ Indicates whether to use cached authorization credentials in the request,
+ if available. If this is set to QNetworkRequest::Manual and the authentication
+ mechanism is 'Basic' or 'Digest', Qt will not send an an 'Authorization' HTTP
+ header with any cached credentials it may have for the request's URL.
+
+ This attribute is set to QNetworkRequest::Manual by QtWebKit when creating a cross-origin
+ XMLHttpRequest where withCredentials has not been set explicitly to true by the
+ Javascript that created the request.
+
+ See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information.
+
+ \since 4.7
+
\value User
Special type. Additional information can be passed in
QVariants with types ranging from User to UserMax. The default
@@ -222,6 +262,18 @@ QT_BEGIN_NAMESPACE
if the item was not cached (i.e., off-line mode)
*/
+/*!
+ \enum QNetworkRequest::LoadControl
+ \since 4.7
+
+ Indicates if an aspect of the request's loading mechanism has been
+ manually overridden, e.g. by QtWebKit.
+
+ \value Automatic default value: indicates default behaviour.
+
+ \value Manual indicates behaviour has been manually overridden.
+*/
+
class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate
{
public:
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index a0ef1a6..d2945c4 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -79,6 +79,9 @@ public:
HttpPipeliningAllowedAttribute,
HttpPipeliningWasUsedAttribute,
CustomVerbAttribute,
+ CookieLoadControlAttribute,
+ AuthenticationReuseAttribute,
+ CookieSaveControlAttribute,
User = 1000,
UserMax = 32767
@@ -89,6 +92,10 @@ public:
PreferCache,
AlwaysCache
};
+ enum LoadControl {
+ Automatic = 0,
+ Manual
+ };
enum Priority {
HighPriority = 1,
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index a2c2c63..985caf4 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -44,14 +44,10 @@
#include "QtCore/qscopedpointer.h"
#include <qabstracteventdispatcher.h>
-#include <private/qunicodetables_p.h>
#include <qcoreapplication.h>
#include <qmetaobject.h>
-#include <qregexp.h>
-#include <private/qnativesocketengine_p.h>
#include <qstringlist.h>
#include <qthread.h>
-#include <qtimer.h>
#include <qurl.h>
#ifdef Q_OS_UNIX
@@ -451,6 +447,18 @@ void QHostInfoRunnable::run()
hostInfo.setLookupId(id);
resultEmitter.emitResultsReady(hostInfo);
+ // now also iterate through the postponed ones
+ QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups);
+ while (iterator.hasNext()) {
+ QHostInfoRunnable* postponed = iterator.next();
+ if (toBeLookedUp == postponed->toBeLookedUp) {
+ // we can now emit
+ iterator.remove();
+ hostInfo.setLookupId(postponed->id);
+ postponed->resultEmitter.emitResultsReady(hostInfo);
+ }
+ }
+
manager->lookupFinished(this);
// thread goes back to QThreadPool
@@ -576,6 +584,23 @@ void QHostInfoLookupManager::abortLookup(int id)
return;
QMutexLocker locker(&this->mutex);
+
+ // is postponed? delete and return
+ for (int i = 0; i < postponedLookups.length(); i++) {
+ if (postponedLookups.at(i)->id == id) {
+ delete postponedLookups.takeAt(i);
+ return;
+ }
+ }
+
+ // is scheduled? delete and return
+ for (int i = 0; i < scheduledLookups.length(); i++) {
+ if (scheduledLookups.at(i)->id == id) {
+ delete scheduledLookups.takeAt(i);
+ return;
+ }
+ }
+
if (!abortedLookups.contains(id))
abortedLookups.append(id);
}
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index acd2bf0..134335f 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -82,7 +82,7 @@ public Q_SLOTS:
}
Q_SIGNALS:
- void resultsReady(const QHostInfo info);
+ void resultsReady(const QHostInfo &info);
};
// needs to be QObject because fromName calls tr()
@@ -170,6 +170,8 @@ public:
bool wasAborted(int id);
QHostInfoCache cache;
+
+ friend class QHostInfoRunnable;
protected:
QList<QHostInfoRunnable*> currentLookups; // in progress
QList<QHostInfoRunnable*> postponedLookups; // postponed because in progress for same host
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 0887f89..0c8caa0 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -44,6 +44,7 @@
#include "qplatformdefs.h"
#include "qhostinfo_p.h"
+#include "private/qnativesocketengine_p.h"
#include "qiodevice.h"
#include <qbytearray.h>
#include <qlibrary.h>
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index 89aaa34..65257e8 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -50,7 +50,6 @@
#include "private/qnativesocketengine_p.h"
#include <ws2tcpip.h>
#include <qlibrary.h>
-#include <qtimer.h>
#include <qmutex.h>
#include <qurl.h>
#include <private/qmutexpool_p.h>
diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp
index 5d2be72..07baf1e 100644
--- a/src/network/socket/qlocalserver_win.cpp
+++ b/src/network/socket/qlocalserver_win.cpp
@@ -167,8 +167,8 @@ void QLocalServerPrivate::_q_onNewConnection()
q->incomingConnection((quintptr)handle);
} else {
if (GetLastError() != ERROR_IO_INCOMPLETE) {
+ q->close();
setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection"));
- closeServer();
return;
}
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index d155357..70bb0da 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -425,6 +425,9 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
case EBADF:
case EFAULT:
case ENOTSOCK:
+#ifdef Q_OS_SYMBIAN
+ case EPIPE:
+#endif
socketState = QAbstractSocket::UnconnectedState;
default:
break;
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index 932126d..55f926d 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -562,7 +562,7 @@ QTcpSocket *QTcpServer::nextPendingConnection()
to the other thread and create the QTcpSocket object there and
use its setSocketDescriptor() method.
- \sa newConnection(), nextPendingConnection()
+ \sa newConnection(), nextPendingConnection(), addPendingConnection()
*/
void QTcpServer::incomingConnection(int socketDescriptor)
{
@@ -572,6 +572,22 @@ void QTcpServer::incomingConnection(int socketDescriptor)
QTcpSocket *socket = new QTcpSocket(this);
socket->setSocketDescriptor(socketDescriptor);
+ addPendingConnection(socket);
+}
+
+/*!
+ This function is called by QTcpServer::incomingConnection()
+ to add a socket to the list of pending incoming connections.
+
+ \note Don't forget to call this member from reimplemented
+ incomingConnection() if you do not want to break the
+ Pending Connections mechanism.
+
+ \sa incomingConnection()
+ \since 4.7
+*/
+void QTcpServer::addPendingConnection(QTcpSocket* socket)
+{
d_func()->pendingConnections.append(socket);
}
diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h
index 7aebffe..b206678 100644
--- a/src/network/socket/qtcpserver.h
+++ b/src/network/socket/qtcpserver.h
@@ -93,6 +93,7 @@ public:
protected:
virtual void incomingConnection(int handle);
+ void addPendingConnection(QTcpSocket* socket);
Q_SIGNALS:
void newConnection();