summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qabstractsocket.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2016-03-09 18:59:33 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2016-03-15 16:41:30 +0000
commit510272ce6c60fb5304db07f67b7ef67dee9e85f4 (patch)
tree3fd934990bad88e43dac2613cd38c75ae1ed5174 /src/network/socket/qabstractsocket.cpp
parent3d3b056f8956281aa93e4c3192ec479a2ed845b0 (diff)
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>
Diffstat (limited to 'src/network/socket/qabstractsocket.cpp')
-rw-r--r--src/network/socket/qabstractsocket.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 0c7972d30f..a4ed5cc2df 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -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;
}