From 0fe254415653efdc58a0e7b233fbe86c6b791417 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20=C3=85strand?= Date: Thu, 30 Dec 2004 15:01:59 +0000 Subject: [PATCH] Bugfix for problem with line speed estimate staying at zero for a long time. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@73 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rdr/FdInStream.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rdr/FdInStream.cxx b/rdr/FdInStream.cxx index 397847a4..26e6d0df 100644 --- a/rdr/FdInStream.cxx +++ b/rdr/FdInStream.cxx @@ -128,8 +128,18 @@ int FdInStream::overrun(int itemSize, int nItems, bool wait) end -= ptr - start; ptr = start; + int bytes_to_read; while (end < start + itemSize) { - int n = readWithTimeoutOrCallback((U8*)end, start + bufSize - end, wait); + if (timing) { + bytes_to_read = start + bufSize - end; + } else { + // When not timing, we must be careful not to read extra data + // into the buffer. Otherwise, the line speed estimation might + // stay at zero for a long time: All reads during timing=1 can + // be satisfied without calling readWithTimeoutOrCallback. + bytes_to_read = start + itemSize*nItems - end; + } + int n = readWithTimeoutOrCallback((U8*)end, bytes_to_read, wait); if (n == 0) return 0; end += n; } -- 2.39.5