QAbstractSocket: do not try to disable write notifications twice
When canWriteNotication() is called and the socket successfully writes a chunk of data, then condition for disabling the notifications will be checked both in writeToSocket() and canWriteNotification(). Moving the code which handles notifications' state from canWriteNotification() to another branch in writeToSocket() eliminates a duplication and forces writeToSocket() to handle disabling the notifications in all cases. Change-Id: I6c14db552afe77b0cf1c9f5c511bafa127a45fe5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
This commit is contained in:
parent
3d3b056f89
commit
510272ce6c
@ -788,12 +788,8 @@ bool QAbstractSocketPrivate::canWriteNotification()
|
||||
#if defined (QABSTRACTSOCKET_DEBUG)
|
||||
qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
|
||||
#endif
|
||||
bool dataWasWritten = writeToSocket();
|
||||
|
||||
if (socketEngine && writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)
|
||||
socketEngine->setWriteNotificationEnabled(false);
|
||||
|
||||
return dataWasWritten;
|
||||
return writeToSocket();
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
@ -833,8 +829,12 @@ bool QAbstractSocketPrivate::writeToSocket()
|
||||
#endif
|
||||
|
||||
// this covers the case when the buffer was empty, but we had to wait for the socket engine to finish
|
||||
if (state == QAbstractSocket::ClosingState)
|
||||
if (state == QAbstractSocket::ClosingState) {
|
||||
q->disconnectFromHost();
|
||||
} else {
|
||||
if (socketEngine)
|
||||
socketEngine->setWriteNotificationEnabled(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user