xserver: Branch 'master' - 2 commits

Keith Packard keithp at kemper.freedesktop.org
Sat Apr 29 16:15:24 UTC 2017


 os/io.c |   38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

New commits:
commit e2f68296ffb8e40035c0ebd949b67d1e2e424e11
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Apr 29 00:26:10 2017 -0700

    os: Mark client as ready to read when closing due to write failure [100863]
    
    This makes sure the server will go look at the client again, notice
    that the FD is no longer valid and close the client down.
    
    Bugzilla: https://bugs.freedesktop.org/100863
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer at amd.com>

diff --git a/os/io.c b/os/io.c
index 9b6a7d459..e1b90d17e 100644
--- a/os/io.c
+++ b/os/io.c
@@ -635,7 +635,10 @@ SetCriticalOutputPending(void)
 /*****************
  * AbortClient:
  *    When a write error occurs to a client, close
- *    the connection and clean things up.
+ *    the connection and clean things up. Mark
+ *    the client as 'ready' so that the server will
+ *    try to read from it again, notice that the fd is
+ *    closed and clean up from there.
  *****************/
 
 static void
@@ -647,6 +650,7 @@ AbortClient(ClientPtr client)
         _XSERVTransDisconnect(oc->trans_conn);
         _XSERVTransClose(oc->trans_conn);
         oc->trans_conn = NULL;
+        mark_client_ready(client);
     }
 }
 
commit a82971b07035ee9a4e3ed01326e7c1eab34b5a19
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Apr 29 00:21:47 2017 -0700

    os: un-duplicate code to close client on write failure
    
    There are three copies of the same short sequence of operations to
    close down a client when a write error occurs. Create a new function,
    AbortClient, which performs these operations and then call it from the
    three places.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer at amd.com>

diff --git a/os/io.c b/os/io.c
index 46c7e2371..9b6a7d459 100644
--- a/os/io.c
+++ b/os/io.c
@@ -633,6 +633,24 @@ SetCriticalOutputPending(void)
 }
 
 /*****************
+ * AbortClient:
+ *    When a write error occurs to a client, close
+ *    the connection and clean things up.
+ *****************/
+
+static void
+AbortClient(ClientPtr client)
+{
+    OsCommPtr oc = client->osPrivate;
+
+    if (oc->trans_conn) {
+        _XSERVTransDisconnect(oc->trans_conn);
+        _XSERVTransClose(oc->trans_conn);
+        oc->trans_conn = NULL;
+    }
+}
+
+/*****************
  * WriteToClient
  *    Copies buf into ClientPtr.buf if it fits (with padding), else
  *    flushes ClientPtr.buf and buf to client.  As of this writing,
@@ -707,11 +725,7 @@ WriteToClient(ClientPtr who, int count, const void *__buf)
             FreeOutputs = oco->next;
         }
         else if (!(oco = AllocateOutputBuffer())) {
-            if (oc->trans_conn) {
-                _XSERVTransDisconnect(oc->trans_conn);
-                _XSERVTransClose(oc->trans_conn);
-                oc->trans_conn = NULL;
-            }
+            AbortClient(who);
             MarkClientException(who);
             return -1;
         }
@@ -892,9 +906,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
                     obuf = realloc(oco->buf, notWritten + BUFSIZE);
                 }
                 if (!obuf) {
-                    _XSERVTransDisconnect(oc->trans_conn);
-                    _XSERVTransClose(oc->trans_conn);
-                    oc->trans_conn = NULL;
+                    AbortClient(who);
                     MarkClientException(who);
                     oco->count = 0;
                     return -1;
@@ -921,11 +933,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
         }
 #endif
         else {
-            if (oc->trans_conn) {
-                _XSERVTransDisconnect(oc->trans_conn);
-                _XSERVTransClose(oc->trans_conn);
-                oc->trans_conn = NULL;
-            }
+            AbortClient(who);
             MarkClientException(who);
             oco->count = 0;
             return -1;


More information about the xorg-commit mailing list