[PATCH xcb/libxcb] Don't close file descriptors received before associated replies

Keith Packard <[email protected]>
Newsgroups gmane.comp.freedesktop.xcb
Message-ID <[email protected]>
The X server may send reply file descriptors at any point before the
reply itself as the buffering of fds in the socket is separate from
reply data. Instead of closing those received early, leave them around
in xcb and await the receipt of the associated reply.

Signed-off-by: Keith Packard <[email protected]>
---
 src/xcb_in.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/xcb_in.c b/src/xcb_in.c
index 73209e0..fc58622 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -1025,17 +1025,11 @@ int _xcb_in_read(xcb_connection_t *c)
                 c->in.in_fd.nfd * sizeof (int));
         c->in.in_fd.ifd = 0;
 
-        /* If we have any left-over file descriptors after emptying
-         * the input buffer, then the server sent some that we weren't
-         * expecting.  Close them and mark the connection as broken;
+        /* Leave any remaining file descriptors around; the associated
+         * replies will be along shortly to pick them up. This way,
+         * the X server just needs to make sure the fds are sent no
+         * later than the reply, but can be sent at any earlier time.
          */
-        if (c->in.queue_len == 0 && c->in.in_fd.nfd != 0) {
-            int i;
-            for (i = 0; i < c->in.in_fd.nfd; i++)
-                close(c->in.in_fd.fd[i]);
-            _xcb_conn_shutdown(c, XCB_CONN_CLOSED_FDPASSING_FAILED);
-            return 0;
-        }
     }
 #endif
 #ifndef _WIN32
-- 
2.16.2

_______________________________________________
Xcb mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xcb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.