diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2018-04-06 16:09:18 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2018-04-12 18:08:29 +0000 |
commit | e8733ffc510cdf3a2e0c21afeeb11535e56d5e2b (patch) | |
tree | 9d17e11c6c33af26c48402328093d595e8f63854 /tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | |
parent | 38a16b8be0a1e408fae19611e68f2caa12440d68 (diff) |
QWindowsPipeReader: fix waiting on inactive pipe
To read data from a named pipe, QWindowsPipeReader uses the ReadFileEx()
function which runs asynchronously. When reading is completed and the
thread is in an alertable wait state, the notified() callback is called
by the system, reporting a completion status of that operation. Then the
callback queues a readyRead signal and starts a new sequence. The latter
is skipped if the pipe is broken or the read buffer is full.
Thus, if an application does not run the event loop, the next call to
QWindowsPipeReader::waitForReadyRead() should emit the queued signal
and report true to the caller even if no new read operation was started.
Change-Id: I37102dbb1c00191d93365bfc2e94e743d9f3962a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp')
-rw-r--r-- | tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 08e9e05463..53d260f19e 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -42,6 +42,10 @@ #include <unistd.h> // for unlink() #endif +#ifdef Q_OS_WIN +#include <QtCore/qt_windows.h> +#endif + Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError) Q_DECLARE_METATYPE(QLocalSocket::LocalSocketState) Q_DECLARE_METATYPE(QLocalServer::SocketOption) @@ -629,6 +633,14 @@ void tst_QLocalSocket::readBufferOverflow() QCOMPARE(client.bytesAvailable(), 0); #ifdef Q_OS_WIN + serverSocket->write(buffer, readBufferSize); + QVERIFY(serverSocket->waitForBytesWritten()); + + // ensure the read completion routine is called + SleepEx(100, true); + QVERIFY(client.waitForReadyRead()); + QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); + // Test overflow caused by an asynchronous pipe operation. client.setReadBufferSize(1); serverSocket->write(buffer, 2); |