summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qwindowspipereader.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2018-04-06 16:09:18 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2018-04-12 18:08:29 +0000
commite8733ffc510cdf3a2e0c21afeeb11535e56d5e2b (patch)
tree9d17e11c6c33af26c48402328093d595e8f63854 /src/corelib/io/qwindowspipereader.cpp
parent38a16b8be0a1e408fae19611e68f2caa12440d68 (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 'src/corelib/io/qwindowspipereader.cpp')
-rw-r--r--src/corelib/io/qwindowspipereader.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 3055fb392e..2312d5ca63 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -316,15 +316,15 @@ void QWindowsPipeReader::emitPendingReadyRead()
*/
bool QWindowsPipeReader::waitForReadyRead(int msecs)
{
- if (!readSequenceStarted)
- return false;
-
if (readyReadPending) {
if (!inReadyRead)
emitPendingReadyRead();
return true;
}
+ if (!readSequenceStarted)
+ return false;
+
if (!waitForNotification(msecs))
return false;