From 884ea10d037d855b91ea5ef947b5c23d2f09aead Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 17 Feb 2010 23:04:34 +0100 Subject: Fix undefined sequence point compiler warning level = ++level is not guaranteed to work, as the increment is not required to happen before the assignment. Change this code to be less obscure and use standard defined behavior. Merge-request: 471 Reviewed-by: Thiago Macieira --- src/gui/kernel/qsoftkeymanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 6d108b0..d89276f 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -215,7 +215,7 @@ bool QSoftKeyManager::handleUpdateSoftKeys() if (source) { bool added = appendSoftkeys(*source, level); source = softkeySource(source, recursiveMerging); - level = added ? ++level : level; + level = added ? level + 1 : level; } } while (source); -- cgit v0.12 From cdf4701f442149546043b155cddcc53116875f1c Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 17 Feb 2010 23:17:36 +0100 Subject: Fix s390(x) atomic ops related crashes The s390 implementation of the pointer related atomic ops never worked before, and the memory barrier was mixed up between the Acquire and the Relaxed variant. This fixes both. Merge-request: 2312 Reviewed-by: Thiago Macieira --- src/corelib/arch/qatomic_s390.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/corelib/arch/qatomic_s390.h b/src/corelib/arch/qatomic_s390.h index 21f5037..273c17b 100644 --- a/src/corelib/arch/qatomic_s390.h +++ b/src/corelib/arch/qatomic_s390.h @@ -366,11 +366,9 @@ template Q_INLINE_TEMPLATE T* QBasicAtomicPointer::fetchAndStoreRelaxed(T *newValue) { #ifndef __s390x__ - return (T*)__CS_OLD_LOOP(reinterpret_cast(_q_value), (int)newValue, "lr", - "", "bcr 15,0\n"); + return (T*)__CS_OLD_LOOP(&_q_value, (int)newValue, "lr", "", ""); #else - return (T*)__CSG_OLD_LOOP(reinterpret_cast(_q_value), (long)newValue, "lgr", - "", "bcr 15,0\n"); + return (T*)__CSG_OLD_LOOP(&_q_value, (long)newValue, "lgr", "", ""); #endif } @@ -378,9 +376,9 @@ template Q_INLINE_TEMPLATE T* QBasicAtomicPointer::fetchAndStoreAcquire(T *newValue) { #ifndef __s390x__ - return (T*)__CS_OLD_LOOP(reinterpret_cast(_q_value), (int)newValue, "lr", "", ""); + return (T*)__CS_OLD_LOOP(&_q_value, (int)newValue, "lr", "", "bcr 15,0 \n"); #else - return (T*)__CSG_OLD_LOOP(reinterpret_cast(_q_value), (long)newValue, "lgr", "", ""); + return (T*)__CSG_OLD_LOOP(&_q_value, (long)newValue, "lgr", "", "bcr 15,0 \n"); #endif } @@ -388,11 +386,9 @@ template Q_INLINE_TEMPLATE T* QBasicAtomicPointer::fetchAndStoreRelease(T *newValue) { #ifndef __s390x__ - return (T*)__CS_OLD_LOOP(reinterpret_cast(_q_value), (int)newValue, "lr", - "bcr 15,0 \n", ""); + return (T*)__CS_OLD_LOOP(&_q_value, (int)newValue, "lr", "bcr 15,0 \n", ""); #else - return (T*)__CSG_OLD_LOOP(reinterpret_cast(_q_value), (long)newValue, "lgr", - "bcr 15,0\n", ""); + return (T*)__CSG_OLD_LOOP(&_q_value, (long)newValue, "lgr", "bcr 15,0\n", ""); #endif } -- cgit v0.12 From 4971430290ecb11012ef5cbf8ef041da0ec3a824 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Thu, 18 Feb 2010 11:16:26 +0100 Subject: Revert "Added note to make QList destructor virtual in version 5" Virtual functions should not be used with copyable types due to slicing. This reverts commit c1db6c2c5a3bbe96a628207af169a032d535426f. --- src/corelib/tools/qlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index a549f2f..1ad7528 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -112,7 +112,7 @@ class QList public: inline QList() : d(&QListData::shared_null) { d->ref.ref(); } inline QList(const QList &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); } - ~QList(); // ### Qt5: make this destructor virtual + ~QList(); QList &operator=(const QList &l); bool operator==(const QList &l) const; inline bool operator!=(const QList &l) const { return !(*this == l); } -- cgit v0.12 From a4332ce058cf3fe567b386d300ba740442a69f44 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 17 Feb 2010 16:36:40 +0100 Subject: QNAM HTTP: Always set channel.reply to 0 when done This will help us to track down a sporadic bug that made requests being sent again even if they were already done. Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 12 +----------- src/network/access/qhttpnetworkconnection_p.h | 5 ----- src/network/access/qhttpnetworkconnectionchannel.cpp | 17 ++++++++++++++--- src/network/access/qhttpnetworkreply.cpp | 13 ++++++++++--- src/network/access/qhttpnetworkreply_p.h | 2 ++ 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index cc6a1c8..327d2db 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -404,6 +404,7 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor QHttpNetworkReply *reply = new QHttpNetworkReply(request.url()); reply->setRequest(request); reply->d_func()->connection = q; + reply->d_func()->connectionChannel = &channels[0]; // will have the correct one set later HttpMessagePair pair = qMakePair(request, reply); switch (request.priority()) { @@ -861,17 +862,6 @@ QNetworkProxy QHttpNetworkConnection::transparentProxy() const // SSL support below #ifndef QT_NO_OPENSSL -QSslConfiguration QHttpNetworkConnectionPrivate::sslConfiguration(const QHttpNetworkReply &reply) const -{ - if (!encrypt) - return QSslConfiguration(); - - for (int i = 0; i < channelCount; ++i) - if (channels[i].reply == &reply) - return static_cast(channels[0].socket)->sslConfiguration(); - return QSslConfiguration(); // pending or done request -} - void QHttpNetworkConnection::setSslConfiguration(const QSslConfiguration &config) { Q_D(QHttpNetworkConnection); diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 03cf09c..823774e 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -210,11 +210,6 @@ public: void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode); bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend); - -#ifndef QT_NO_OPENSSL - QSslConfiguration sslConfiguration(const QHttpNetworkReply &reply) const; -#endif - #ifndef QT_NO_NETWORKPROXY QNetworkProxy networkProxy; void emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator* auth); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 2a3036b..89fd032 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -137,6 +137,7 @@ bool QHttpNetworkConnectionChannel::sendRequest() if (reply) { reply->d_func()->clear(); reply->d_func()->connection = connection; + reply->d_func()->connectionChannel = this; reply->d_func()->autoDecompress = request.d->autoDecompress; reply->d_func()->pipeliningUsed = false; } @@ -568,7 +569,8 @@ void QHttpNetworkConnectionChannel::allDone() handleStatus(); // ### at this point there should be no more data on the socket // close if server requested - if (reply->d_func()->isConnectionCloseEnabled()) + bool connectionCloseEnabled = reply->d_func()->isConnectionCloseEnabled(); + if (connectionCloseEnabled) close(); // queue the finished signal, this is required since we might send new requests from // slot connected to it. The socket will not fire readyRead signal, if we are already @@ -579,14 +581,22 @@ void QHttpNetworkConnectionChannel::allDone() // in case of failures, each channel will attempt two reconnects before emitting error. reconnectAttempts = 2; + detectPipeliningSupport(); + // now the channel can be seen as free/idle again, all signal emissions for the reply have been done this->state = QHttpNetworkConnectionChannel::IdleState; - detectPipeliningSupport(); + // if it does not need to be sent again we can set it to 0 + // the previous code did not do that and we had problems with accidental re-sending of a + // finished request. + // Note that this may trigger a segfault at some other point. But then we can fix the underlying + // problem. + if (!resendCurrent) + reply = 0; // move next from pipeline to current request if (!alreadyPipelinedRequests.isEmpty()) { - if (resendCurrent || reply->d_func()->isConnectionCloseEnabled() || socket->state() != QAbstractSocket::ConnectedState) { + if (resendCurrent || connectionCloseEnabled || socket->state() != QAbstractSocket::ConnectedState) { // move the pipelined ones back to the main queue requeueCurrentlyPipelinedRequests(); close(); @@ -745,6 +755,7 @@ void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair) if (reply) { reply->d_func()->clear(); reply->d_func()->connection = connection; + reply->d_func()->connectionChannel = this; reply->d_func()->autoDecompress = request.d->autoDecompress; reply->d_func()->pipeliningUsed = true; } diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 512c045..984f557 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -230,6 +230,7 @@ void QHttpNetworkReplyPrivate::clear() currentChunkRead = 0; connectionCloseEnabled = true; connection = 0; + connectionChannel = 0; #ifndef QT_NO_COMPRESS if (initInflate) inflateEnd(&inflateStrm); @@ -803,9 +804,15 @@ void QHttpNetworkReplyPrivate::eraseData() QSslConfiguration QHttpNetworkReply::sslConfiguration() const { Q_D(const QHttpNetworkReply); - if (d->connection) - return d->connection->d_func()->sslConfiguration(*this); - return QSslConfiguration(); + + if (!d->connectionChannel) + return QSslConfiguration(); + + QSslSocket *sslSocket = qobject_cast(d->connectionChannel->socket); + if (!sslSocket) + return QSslConfiguration(); + + return sslSocket->sslConfiguration(); } void QHttpNetworkReply::setSslConfiguration(const QSslConfiguration &config) diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index af9266b..fa240ec 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -86,6 +86,7 @@ static const unsigned char gz_magic[2] = {0x1f, 0x8b}; // gzip magic header QT_BEGIN_NAMESPACE class QHttpNetworkConnection; +class QHttpNetworkConnectionChannel; class QHttpNetworkRequest; class QHttpNetworkConnectionPrivate; class QHttpNetworkReplyPrivate; @@ -218,6 +219,7 @@ public: qint64 currentChunkSize; qint64 currentChunkRead; QPointer connection; + QPointer connectionChannel; bool initInflate; bool streamEnd; #ifndef QT_NO_COMPRESS -- cgit v0.12