summaryrefslogtreecommitdiffstats
path: root/src/network/socket
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@nokia.com>2010-06-10 11:10:27 (GMT)
committerJoerg Bornemann <joerg.bornemann@nokia.com>2010-06-10 13:31:18 (GMT)
commit12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f (patch)
treee4ec8b700782701d7601d7d039f4b53b60cbe7a8 /src/network/socket
parentcbe3425a3bd226c61c94f92c521dc5c9b090ef96 (diff)
downloadQt-12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f.zip
Qt-12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f.tar.gz
Qt-12614b2c5aaaed44ef9b3d1b3f6dbf50fd2d405f.tar.bz2
QLocalSocket: fix reading from a socket after broken connection
Reading from a socket with a broken connection didn't work, even if there were still bytes to read in the internal read buffer. Autotest: tst_QLocalSocket::writeToClientAndDisconnect Task-number: QTBUG-10921 Reviewed-by: ossi
Diffstat (limited to 'src/network/socket')
-rw-r--r--src/network/socket/qlocalsocket_win.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 5f46ecb..dc87ade 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -192,6 +192,9 @@ qint64 QLocalSocket::readData(char *data, qint64 maxSize)
{
Q_D(QLocalSocket);
+ if (d->pipeClosed && d->actualReadBufferSize == 0)
+ return -1; // signal EOF
+
qint64 readSoFar;
// If startAsyncRead() read data, copy it to its destination.
if (maxSize == 1 && d->actualReadBufferSize > 0) {
@@ -213,10 +216,8 @@ qint64 QLocalSocket::readData(char *data, qint64 maxSize)
}
if (d->pipeClosed) {
- if (readSoFar == 0) {
+ if (d->actualReadBufferSize == 0)
QTimer::singleShot(0, this, SLOT(_q_pipeClosed()));
- return -1; // signal EOF
- }
} else {
if (!d->readSequenceStarted)
d->startAsyncRead();
@@ -345,7 +346,8 @@ DWORD QLocalSocketPrivate::bytesAvailable()
if (!pipeClosed) {
pipeClosed = true;
emit q->readChannelFinished();
- QTimer::singleShot(0, q, SLOT(_q_pipeClosed()));
+ if (actualReadBufferSize == 0)
+ QTimer::singleShot(0, q, SLOT(_q_pipeClosed()));
}
}
return 0;