diff options
author | Peter Hartmann <peter.hartmann@nokia.com> | 2009-12-15 09:52:52 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@nokia.com> | 2010-01-11 09:48:05 (GMT) |
commit | 145fecc833926c307819752912e6833169799a53 (patch) | |
tree | e527d59a10244b7b6c71b8e63c5019a7dd34c2e4 /src/network/access/qhttpnetworkconnectionchannel.cpp | |
parent | ef5a985cf47c32bac0ddd3bae1edb7e922e7ec69 (diff) | |
download | Qt-145fecc833926c307819752912e6833169799a53.zip Qt-145fecc833926c307819752912e6833169799a53.tar.gz Qt-145fecc833926c307819752912e6833169799a53.tar.bz2 |
network internals: start HTTP GET requests right away when called
on the code path from QNetworkAccessManager::get() to
QTcpSocket::write() there were two calls involved that were invoked
via a QueuedConnection, which would in some occasions delay writing the
data to the socket. This patch makes sure the data is written to the
socket immediately, without returning to the event loop (only the HTTP
backend was changed for that event, the other backends were not
changed)
Reviewed-by: Thiago Macieira
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 1a68e97..7cf632f 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -166,6 +166,8 @@ bool QHttpNetworkConnectionChannel::sendRequest() QByteArray header = QHttpNetworkRequestPrivate::header(request, false); #endif socket->write(header); + // flushing is dangerous (QSslSocket calls transmit which might read or error) +// socket->flush(); QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice(); if (uploadByteDevice) { // connect the signals so this function gets called again @@ -258,7 +260,7 @@ 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 - receiveReply(); + QMetaObject::invokeMethod(connection, "_q_receiveReply", Qt::QueuedConnection); break; } case QHttpNetworkConnectionChannel::ReadingState: @@ -272,7 +274,7 @@ bool QHttpNetworkConnectionChannel::sendRequest() } -void QHttpNetworkConnectionChannel::receiveReply() +void QHttpNetworkConnectionChannel::_q_receiveReply() { Q_ASSERT(socket); @@ -567,7 +569,7 @@ void QHttpNetworkConnectionChannel::allDone() connection->d_func()->fillPipeline(socket); // continue reading - receiveReply(); + _q_receiveReply(); } } else if (alreadyPipelinedRequests.isEmpty() && socket->bytesAvailable() > 0) { eatWhitespace(); @@ -739,7 +741,7 @@ void QHttpNetworkConnectionChannel::_q_readyRead() if (isSocketWaiting() || isSocketReading()) { state = QHttpNetworkConnectionChannel::ReadingState; if (reply) - receiveReply(); + _q_receiveReply(); } } @@ -758,7 +760,7 @@ void QHttpNetworkConnectionChannel::_q_disconnected() if (isSocketWaiting() || isSocketReading()) { state = QHttpNetworkConnectionChannel::ReadingState; if (reply) - receiveReply(); + _q_receiveReply(); } else if (state == QHttpNetworkConnectionChannel::IdleState && resendCurrent) { // re-sending request because the socket was in ClosingState QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); |