summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@trolltech.com>2009-07-09 16:09:12 (GMT)
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-07-09 16:30:27 (GMT)
commit020ed5b7caaba5cf877cdb9ebaa575db1d15b7f0 (patch)
treea85c62ae06667c772d40ea48f0c188985f057a96 /src/network
parent4bec76fceb2297cdbde765b74075046b94bfaf75 (diff)
downloadQt-020ed5b7caaba5cf877cdb9ebaa575db1d15b7f0.zip
Qt-020ed5b7caaba5cf877cdb9ebaa575db1d15b7f0.tar.gz
Qt-020ed5b7caaba5cf877cdb9ebaa575db1d15b7f0.tar.bz2
QLocalSocket WriteOnly mode fixed on Windows
Write only local sockets silently disconnected after some time. Reason: we cannot call PeekNamedPipe on a write only pipe. Task-number: 257714 Reviewed-by: ossi Autotest: tst_QLocalSocket::writeOnlySocket
Diffstat (limited to 'src/network')
-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 1a971f0..794b2b7 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -168,7 +168,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
// we have a valid handle
d->serverName = name;
- if (setSocketDescriptor((quintptr)localSocket), openMode) {
+ if (setSocketDescriptor((quintptr)localSocket, ConnectedState, openMode)) {
d->handle = localSocket;
emit connected();
}
@@ -299,8 +299,6 @@ void QLocalSocket::abort()
DWORD QLocalSocketPrivate::bytesAvailable()
{
Q_Q(QLocalSocket);
- if (q->state() != QLocalSocket::ConnectedState)
- return 0;
DWORD bytes;
if (PeekNamedPipe(handle, NULL, 0, NULL, &bytes, NULL)) {
return bytes;
@@ -410,7 +408,7 @@ bool QLocalSocket::setSocketDescriptor(quintptr socketDescriptor,
d->handle = (int*)socketDescriptor;
d->state = socketState;
emit stateChanged(d->state);
- if (d->state == ConnectedState) {
+ if (d->state == ConnectedState && openMode.testFlag(QIODevice::ReadOnly)) {
d->startAsyncRead();
d->checkReadyRead();
}
@@ -471,6 +469,10 @@ bool QLocalSocket::waitForDisconnected(int msecs)
Q_D(QLocalSocket);
if (state() == UnconnectedState)
return false;
+ if (!openMode().testFlag(QIODevice::ReadOnly)) {
+ qWarning("QLocalSocket::waitForDisconnected isn't supported for write only pipes.");
+ return false;
+ }
QIncrementalSleepTimer timer(msecs);
forever {
d->bytesAvailable(); // to check if PeekNamedPipe fails