summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qwindowspipereader_p.h
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-01-15 19:39:08 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2021-01-22 16:26:39 +0200
commit3fc6b45cbb7b9bf3800be7c1f68b1484749489a3 (patch)
tree3db50e11933c6c5115e1c1001ca234bcdda0b4e0 /src/corelib/io/qwindowspipereader_p.h
parent5ea701337dc2a4e153a22e6e4aba1939f88714cf (diff)
QProcess/Win: move pipe draining into QWindowsPipeReader
... where it belongs. To avoid the loop, introduce the drainAndStop() function, which allows QWindowsPipeReader to flush the pipe itself. It determines the number of bytes pending and blocks until the remainder of the process output is received. Note that the loop in drainOutputPipes() didn't actually have to interleave the two pipes (because we're presuming that the operations will finish instantly), so we don't do it now. Also, the code violated the API contract: 'true' was returned when the 'wrong' channel received data; this is now fixed as a side effect. Change-Id: I38ed4861a238e39e793c3716e856e5bfdeed3d74 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qwindowspipereader_p.h')
-rw-r--r--src/corelib/io/qwindowspipereader_p.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h
index 2842343597..c61018d87d 100644
--- a/src/corelib/io/qwindowspipereader_p.h
+++ b/src/corelib/io/qwindowspipereader_p.h
@@ -68,6 +68,7 @@ public:
void setHandle(HANDLE hPipeReadEnd);
void startAsyncRead();
void stop();
+ void drainAndStop();
void setMaxReadBufferSize(qint64 size) { readBufferMaxSize = size; }
qint64 maxReadBufferSize() const { return readBufferMaxSize; }
@@ -88,12 +89,15 @@ Q_SIGNALS:
void _q_queueReadyRead(QPrivateSignal);
private:
+ void startAsyncReadHelper(qint64 bytesToRead);
+ void cancelAsyncRead();
static void CALLBACK readFileCompleted(DWORD errorCode, DWORD numberOfBytesTransfered,
OVERLAPPED *overlappedBase);
void notified(DWORD errorCode, DWORD numberOfBytesRead);
DWORD checkPipeState();
bool waitForNotification(int timeout);
void emitPendingReadyRead();
+ void emitPipeClosed();
class Overlapped : public OVERLAPPED
{
@@ -109,7 +113,9 @@ private:
qint64 readBufferMaxSize;
QRingBuffer readBuffer;
qint64 actualReadBufferSize;
- bool stopped;
+ qint64 bytesPending;
+
+ enum State { Stopped, Running, Draining } state;
bool readSequenceStarted;
bool notifiedCalled;
bool pipeBroken;