In commit:

        commit 092c57ab173c8b71056f6feb3b9d04d063a46579
        Author: Adam Jackson <[email protected]>
        Date:   Fri Jun 17 14:03:01 2011 -0400

            os: Hide the Connection{In,Out}put implementation details

            Reviewed-by: Daniel Stone <[email protected]>
            Signed-off-by: Adam Jackson <[email protected]>

the check for an empty output buffer was moved from one calling
location into the FlushClient implementation itself. However, this
neglected the possibility that additional data, in the form of
'extraBuf' would be passed to FlushClient from othe code paths. If the
output buffer happened to be empty at that time, the extra data would
never be written to the client.

This is fixed by checking the total data to be written, which includes
both pending and extra data, instead of just the pending data.

Signed-off-by: Keith Packard <[email protected]>
---
 os/io.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/os/io.c b/os/io.c
index 015f137..5c3aceb 100644
--- a/os/io.c
+++ b/os/io.c
@@ -862,11 +862,14 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void 
*__extraBuf, int extraCount)
     long notWritten;
     long todo;
 
-    if (!oco || !oco->count)
+    if (!oco)
        return 0;
     written = 0;
     padsize = padding_for_int32(extraCount);
     notWritten = oco->count + extraCount + padsize;
+    if (!notWritten)
+        return 0;
+
     todo = notWritten;
     while (notWritten) {
         long before = written;  /* amount of whole thing written */
-- 
1.7.10.4

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to