summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-08-24 18:30:12 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2021-09-18 10:46:35 +0300
commit4e695eece7e1de874f3f8bb0a530a2ae05a0014a (patch)
treed7a92d2ace64ce126cdbd61149511bc81531b8b7 /src/corelib/io/qprocess_win.cpp
parent51e28dc54fab3caa9e2b3bea4fd7a2fb5724d7c7 (diff)
QWindowsPipeWriter: do not clear the buffer in thread pool callback
In a blocking application, receiving the results of write operations must be synchronized with the waitFor...() functions. But, clearing the buffer in another thread can cause the code localsocket.write(...); QVERIFY(localsocket.bytesToWrite() > 0); to fail unexpectedly, if the socket has been disconnected between the calls. So, defer resetting the buffer until checkForWrite() is called. Change-Id: I8c21036aab6a4c56d02c0d9a18d4bbce52d724f4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r--src/corelib/io/qprocess_win.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index d5b1bd6f6a..f935e4f491 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -737,7 +737,7 @@ bool QProcessPrivate::waitForBytesWritten(const QDeadlineTimer &deadline)
// start with, in which case we fail immediately. Also, if the input
// pipe goes down somewhere in the code below, we avoid waiting for
// a full timeout.
- if (pipeWriterBytesToWrite() == 0)
+ if (!stdinChannel.writer || !stdinChannel.writer->isWriteOperationActive())
return false;
QProcessPoller poller(*this);
@@ -747,7 +747,6 @@ bool QProcessPrivate::waitForBytesWritten(const QDeadlineTimer &deadline)
if (ret == 0)
break;
- Q_ASSERT(stdinChannel.writer);
if (stdinChannel.writer->checkForWrite())
return true;