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>bb10
parent
96cda705dc
commit
2cc78885b0
|
|
@ -870,10 +870,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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue