From 9fd35daa3160fd36f00ed354bfcbefefa1353cce Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 17 Jan 2013 13:43:02 -0800 Subject: Add interfaces to get FDs from clients over the socket This adds two interfaces: void SetReqFds(ClientPtr client, int req_fds) Marks the number of file descriptors expected for this request. Call this before any request processing so that any un-retrieved file descriptors will be closed automatically. int ReadFdFromClient(ClientPtr client) Reads the next queued file descriptor from the connection. If this request is not expecting any more file descriptors, or if there are no more file descriptors available from the connection, then this will return -1. Signed-off-by: Keith Packard Reviewed-by: Adam Jackson --- include/dixstruct.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/dixstruct.h') diff --git a/include/dixstruct.h b/include/dixstruct.h index 7711cde99..456e63360 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -110,8 +110,16 @@ typedef struct _Client { DeviceIntPtr clientPtr; ClientIdPtr clientIds; + int req_fds; } ClientRec; +static inline void +SetReqFds(ClientPtr client, int req_fds) { + if (client->req_fds != 0 && req_fds != client->req_fds) + LogMessage(X_ERROR, "Mismatching number of request fds %d != %d\n", req_fds, client->req_fds); + client->req_fds = req_fds; +} + /* * Scheduling interface */ -- cgit v1.2.3