diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-12-19 15:10:45 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2012-01-04 17:28:55 (GMT) |
commit | 26f1ca8681db995e82c0f4c0fa9363c842520700 (patch) | |
tree | 1c7c02b1059c3390f12daf9ea2cef9d81ad46f33 /src/network/ssl/qsslsocket_openssl.cpp | |
parent | ddb295b7b5c68c0c34cc3c2ec26e0f8e3cc371c9 (diff) | |
download | Qt-26f1ca8681db995e82c0f4c0fa9363c842520700.zip Qt-26f1ca8681db995e82c0f4c0fa9363c842520700.tar.gz Qt-26f1ca8681db995e82c0f4c0fa9363c842520700.tar.bz2 |
Handle plain socket write errors in SSL
When an ssl socket is closed during connecting, and it is using a proxy
then it is possible for the plain socket to be in pending close state
when transmit() is called.
As errors were not handled, this caused the socket (and https request)
to "hang".
It now propagates the error from plain socket.
Change-Id: I6fb86815a2a63e197cea582f4b153e487543477c
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 2cc78885b0b7d08f965998d156945a077e56c1d8)
Diffstat (limited to 'src/network/ssl/qsslsocket_openssl.cpp')
-rw-r--r-- | src/network/ssl/qsslsocket_openssl.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 872b19c..900bfdb 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1044,10 +1044,17 @@ void QSslSocketBackendPrivate::transmit() int encryptedBytesRead = q_BIO_read(writeBio, data.data(), pendingBytes); // Write encrypted data from the buffer to the socket. - plainSocket->write(data.constData(), encryptedBytesRead); + qint64 actualWritten = plainSocket->write(data.constData(), encryptedBytesRead); #ifdef QSSLSOCKET_DEBUG - qDebug() << "QSslSocketBackendPrivate::transmit: wrote" << encryptedBytesRead << "encrypted bytes to the socket"; + qDebug() << "QSslSocketBackendPrivate::transmit: wrote" << encryptedBytesRead << "encrypted bytes to the socket" << actualWritten << "actual."; #endif + if (actualWritten < 0) { + //plain socket write fails if it was in the pending close state. + q->setErrorString(plainSocket->errorString()); + q->setSocketError(plainSocket->error()); + emit q->error(plainSocket->error()); + return; + } transmitting = true; } |