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
diff --git a/rdr/FdInStream.cxx b/rdr/FdInStream.cxx
index 397847a..26e6d0d 100644
--- a/rdr/FdInStream.cxx
+++ b/rdr/FdInStream.cxx
@@ -128,8 +128,18 @@
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;
}