aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os/io.c')
-rw-r--r--xorg-server/os/io.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c
index 380036664..a20faa56f 100644
--- a/xorg-server/os/io.c
+++ b/xorg-server/os/io.c
@@ -259,6 +259,12 @@ ReadRequestFromClient(ClientPtr client)
oc->input = oci;
}
+ /* Discard any unused file descriptors */
+ while (client->req_fds > 0) {
+ int req_fd = ReadFdFromClient(client);
+ if (req_fd >= 0)
+ close(req_fd);
+ }
/* advance to start of next request */
oci->bufptr += oci->lenLastReq;
@@ -485,6 +491,29 @@ ReadRequestFromClient(ClientPtr client)
return needed;
}
+int
+ReadFdFromClient(ClientPtr client)
+{
+ int fd = -1;
+
+ if (client->req_fds > 0) {
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ --client->req_fds;
+ fd = _XSERVTransRecvFd(oc->trans_conn);
+ } else
+ LogMessage(X_ERROR, "Request asks for FD without setting req_fds\n");
+ return fd;
+}
+
+int
+WriteFdToClient(ClientPtr client, int fd, Bool do_close)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return _XSERVTransSendFd(oc->trans_conn, fd, do_close);
+}
+
/*****************************************************************
* InsertFakeRequest
* Splice a consed up (possibly partial) request in as the next request.