Blame SOURCES/0003-GLX-Use-the-sending-client-for-looking-up-XID-s.patch

05dbd3
From abeae4a6d356653d50026707ecc2afceac83631e Mon Sep 17 00:00:00 2001
05dbd3
From: Kyle Brenneman <kbrenneman@nvidia.com>
05dbd3
Date: Wed, 8 May 2019 08:44:54 -0600
05dbd3
Subject: [PATCH xserver 3/5] GLX: Use the sending client for looking up XID's
05dbd3
05dbd3
When GlxGetXIDMap looks up an unknown XID, it will now look up a vendor based
05dbd3
on the screen number for the XID and the client that sent the current request.
05dbd3
05dbd3
In GlxGetXIDMap, if the XID is for a regular X window, then it won't be in the
05dbd3
(XID -> vendor) mapping, so we have to look up a vendor by screen number.
05dbd3
05dbd3
With this change, GlxGetXIDMap will use the (screen -> vendor) map for
05dbd3
whichever client sent the current request, instead of using the global
05dbd3
(screen -> vendor) map.
05dbd3
05dbd3
Since GlxGetXIDMap doesn't take a ClientPtr argument, GlxDispatchRequest will
05dbd3
store the client for the current request in a global variable. That way, the
05dbd3
ABI for GLXVND doesn't need to change.
05dbd3
05dbd3
v2: Fix an error check in GlxDispatchRequest.
05dbd3
05dbd3
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
05dbd3
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
05dbd3
Reviewed-by: Adam Jackson <ajax@redhat.com>
05dbd3
(cherry picked from commit 8b67ec7cc6fda243480a5a8ca118b66242f3eb2c)
05dbd3
---
05dbd3
 glx/vndcmds.c          | 13 +++++++++++--
05dbd3
 glx/vndserver.h        |  7 +++++++
05dbd3
 glx/vndservermapping.c | 12 ++++++++----
05dbd3
 3 files changed, 26 insertions(+), 6 deletions(-)
05dbd3
05dbd3
diff --git a/glx/vndcmds.c b/glx/vndcmds.c
05dbd3
index f0779d14a2..21c6fef9ea 100644
05dbd3
--- a/glx/vndcmds.c
05dbd3
+++ b/glx/vndcmds.c
05dbd3
@@ -468,15 +468,24 @@ void GlxDispatchReset(void)
05dbd3
 int GlxDispatchRequest(ClientPtr client)
05dbd3
 {
05dbd3
     REQUEST(xReq);
05dbd3
+    int result;
05dbd3
+
05dbd3
     if (GlxExtensionEntry->base == 0)
05dbd3
         return BadRequest;
05dbd3
+
05dbd3
+    GlxSetRequestClient(client);
05dbd3
+
05dbd3
     if (stuff->data < OPCODE_ARRAY_LEN) {
05dbd3
         if (dispatchFuncs[stuff->data] == NULL) {
05dbd3
             // Try to find a dispatch stub.
05dbd3
             dispatchFuncs[stuff->data] = GetVendorDispatchFunc(stuff->data, 0);
05dbd3
         }
05dbd3
-        return dispatchFuncs[stuff->data](client);
05dbd3
+        result = dispatchFuncs[stuff->data](client);
05dbd3
     } else {
05dbd3
-        return dispatch_GLXSingle(client);
05dbd3
+        result = dispatch_GLXSingle(client);
05dbd3
     }
05dbd3
+
05dbd3
+    GlxSetRequestClient(NULL);
05dbd3
+
05dbd3
+    return result;
05dbd3
 }
05dbd3
diff --git a/glx/vndserver.h b/glx/vndserver.h
05dbd3
index 78246d212c..613fef0fe2 100644
05dbd3
--- a/glx/vndserver.h
05dbd3
+++ b/glx/vndserver.h
05dbd3
@@ -95,6 +95,13 @@ Bool GlxAddXIDMap(XID id, GlxServerVendor *vendor);
05dbd3
 GlxServerVendor * GlxGetXIDMap(XID id);
05dbd3
 void GlxRemoveXIDMap(XID id);
05dbd3
 
05dbd3
+/**
05dbd3
+ * Records the client that sent the current request. This is needed in
05dbd3
+ * GlxGetXIDMap to know which client's (screen -> vendor) mapping to use for a
05dbd3
+ * regular X window.
05dbd3
+ */
05dbd3
+void GlxSetRequestClient(ClientPtr client);
05dbd3
+
05dbd3
 GlxContextTagInfo *GlxAllocContextTag(ClientPtr client, GlxServerVendor *vendor);
05dbd3
 GlxContextTagInfo *GlxLookupContextTag(ClientPtr client, GLXContextTag tag);
05dbd3
 void GlxFreeContextTag(GlxContextTagInfo *tagInfo);
05dbd3
diff --git a/glx/vndservermapping.c b/glx/vndservermapping.c
05dbd3
index 778656bb6e..4efab8b81d 100644
05dbd3
--- a/glx/vndservermapping.c
05dbd3
+++ b/glx/vndservermapping.c
05dbd3
@@ -33,6 +33,13 @@
05dbd3
 
05dbd3
 #include "vndservervendor.h"
05dbd3
 
05dbd3
+static ClientPtr requestClient = NULL;
05dbd3
+
05dbd3
+void GlxSetRequestClient(ClientPtr client)
05dbd3
+{
05dbd3
+    requestClient = client;
05dbd3
+}
05dbd3
+
05dbd3
 static GlxServerVendor *LookupXIDMapResource(XID id)
05dbd3
 {
05dbd3
     void *ptr = NULL;
05dbd3
@@ -59,10 +66,7 @@ GlxServerVendor *GlxGetXIDMap(XID id)
05dbd3
                                          DixGetAttrAccess);
05dbd3
         if (rv == Success && ptr != NULL) {
05dbd3
             DrawablePtr draw = (DrawablePtr) ptr;
05dbd3
-            GlxScreenPriv *screenPriv = GlxGetScreen(draw->pScreen);
05dbd3
-            if (screenPriv != NULL) {
05dbd3
-                vendor = screenPriv->vendor;
05dbd3
-            }
05dbd3
+            vendor = GlxGetVendorForScreen(requestClient, draw->pScreen);
05dbd3
         }
05dbd3
     }
05dbd3
     return vendor;
05dbd3
-- 
05dbd3
2.21.0
05dbd3