summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-07-02 17:31:26 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2021-07-08 16:14:11 +0300
commit1a57a4974be9dbdeedef6f5c6eb4332eecf6f0c9 (patch)
tree383496919e92f6fe57e87d157a6d34bc5b29641c /src/corelib/io
parent82499f81478032911d8f788aa28e8d780b31c973 (diff)
QLocalSocket/Win: reimplement skipData() function
The base implementation discards the data by reading into a dummy buffer, which is slower than necessary. Change-Id: Iabf0c4a25746af6cac5b61d7bda66d89501c808c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qwindowspipereader.cpp19
-rw-r--r--src/corelib/io/qwindowspipereader_p.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index c3ac51df94..5415ad7830 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -233,6 +233,25 @@ qint64 QWindowsPipeReader::readLine(char *data, qint64 maxlen)
}
/*!
+ Skips up to \c{maxlen} bytes from the internal read buffer.
+ */
+qint64 QWindowsPipeReader::skip(qint64 maxlen)
+{
+ QMutexLocker locker(&mutex);
+
+ const qint64 skippedSoFar = readBuffer.skip(qMin(actualReadBufferSize, maxlen));
+ actualReadBufferSize -= skippedSoFar;
+
+ if (!pipeBroken) {
+ startAsyncReadHelper(&locker);
+ if (skippedSoFar == 0)
+ return -2; // signal EWOULDBLOCK
+ }
+
+ return skippedSoFar;
+}
+
+/*!
Returns \c true if a complete line of data can be read from the buffer.
*/
bool QWindowsPipeReader::canReadLine() const
diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h
index e2190d67d9..5eb62cb393 100644
--- a/src/corelib/io/qwindowspipereader_p.h
+++ b/src/corelib/io/qwindowspipereader_p.h
@@ -79,6 +79,7 @@ public:
qint64 bytesAvailable() const;
qint64 read(char *data, qint64 maxlen);
qint64 readLine(char *data, qint64 maxlen);
+ qint64 skip(qint64 maxlen);
bool canReadLine() const;
DWORD checkPipeState();
bool checkForReadyRead() { return consumePendingAndEmit(false); }