]> source.dussan.org Git - tigervnc.git/commitdiff
Fix busy loop in FdOutStream::flush()
authorPierre Ossman <ossman@cendio.se>
Mon, 10 Oct 2016 14:05:46 +0000 (16:05 +0200)
committerPierre Ossman <ossman@cendio.se>
Mon, 10 Oct 2016 14:05:46 +0000 (16:05 +0200)
This bug was introduced in c6df31db. A non-blocking socket that did
not have any more space would busy loop until the write succeeded.
Instead now it returns without any action, just as it did before
the bug was introduced.

common/rdr/FdOutStream.cxx

index e6d081a365a4dd5254a39aa3cf5a45b057d2629e..29e864fc314c03b1b94786912112601b88590b99 100644 (file)
@@ -101,8 +101,13 @@ void FdOutStream::flush()
                              blocking? timeoutms : 0);
 
     // Timeout?
-    if ((n == 0) && blocking)
+    if (n == 0) {
+      // If non-blocking then we're done here
+      if (!blocking)
+        break;
+
       throw TimedOut();
+    }
 
     sentUpTo += n;
     offset += n;