]> source.dussan.org Git - tigervnc.git/commitdiff
Bugfix for problem with line speed estimate staying at zero for a long
authorPeter Åstrand <astrand@cendio.se>
Thu, 30 Dec 2004 15:01:59 +0000 (15:01 +0000)
committerPeter Åstrand <astrand@cendio.se>
Thu, 30 Dec 2004 15:01:59 +0000 (15:01 +0000)
time.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@73 3789f03b-4d11-0410-bbf8-ca57d06f2519

rdr/FdInStream.cxx

index 397847a49dfb395ccb5aa8b77c0a3c93e5405ffa..26e6d0df6f4bbbab19b239a3715e5645705830ff 100644 (file)
@@ -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;
   }