[PATCH 09/10] dri2: Introduce a third version of the AuthMagic function
Adam Jackson
ajax at redhat.com
Thu Oct 17 09:36:51 PDT 2013
From: Tiago Vignatti <tiago.vignatti at intel.com>
This most recent version takes a client pointer to allow xwayland to
asynchronously authenticate a client.
Reviewed-by: Adam Jackson <ajax at redhat.com>
---
hw/xfree86/dri2/dri2.c | 12 ++++++++----
hw/xfree86/dri2/dri2.h | 7 +++++++
hw/xfree86/dri2/dri2ext.c | 27 +++++++++++++++++++--------
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 0b047f0..efdcd66 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -121,8 +121,9 @@ typedef struct _DRI2Screen {
DRI2ScheduleSwapProcPtr ScheduleSwap;
DRI2GetMSCProcPtr GetMSC;
DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
- DRI2AuthMagic2ProcPtr AuthMagic;
DRI2AuthMagicProcPtr LegacyAuthMagic;
+ DRI2AuthMagic2ProcPtr LegacyAuthMagic2;
+ DRI2AuthMagic3ProcPtr AuthMagic;
DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
DRI2SwapLimitValidateProcPtr SwapLimitValidate;
DRI2GetParamProcPtr GetParam;
@@ -1352,7 +1353,7 @@ DRI2Authenticate(ClientPtr client, ScreenPtr pScreen, uint32_t magic)
return FALSE;
primescreen = GetScreenPrime(pScreen, dri2_client->prime_id);
- if ((*ds->AuthMagic)(primescreen, magic))
+ if ((*ds->AuthMagic)(client, primescreen, magic))
return FALSE;
return TRUE;
}
@@ -1457,8 +1458,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
cur_minor = 1;
}
+ if (info->version >= 10) {
+ ds->AuthMagic = info->AuthMagic3;
+ }
if (info->version >= 8) {
- ds->AuthMagic = info->AuthMagic2;
+ ds->LegacyAuthMagic2 = info->AuthMagic2;
}
if (info->version >= 5) {
ds->LegacyAuthMagic = info->AuthMagic;
@@ -1497,7 +1501,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
* If the driver doesn't provide an AuthMagic function
* it relies on the old method (using libdrm) or fails
*/
- if (!ds->LegacyAuthMagic)
+ if (!ds->LegacyAuthMagic2 && !ds->LegacyAuthMagic)
#ifdef WITH_LIBDRM
ds->LegacyAuthMagic = drmAuthMagic;
#else
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 1e7afdd..38b4f58 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -65,6 +65,8 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, uint32_t magic);
+typedef int (*DRI2AuthMagic3ProcPtr) (ClientPtr client,
+ ScreenPtr pScreen, uint32_t magic);
/**
* Schedule a buffer swap
@@ -252,6 +254,9 @@ typedef struct {
DRI2CreateBuffer2ProcPtr CreateBuffer2;
DRI2DestroyBuffer2ProcPtr DestroyBuffer2;
DRI2CopyRegion2ProcPtr CopyRegion2;
+
+ /* added in version 10 */
+ DRI2AuthMagic3ProcPtr AuthMagic3;
} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info);
@@ -268,6 +273,8 @@ extern _X_EXPORT Bool DRI2Connect(ClientPtr client, ScreenPtr pScreen,
extern _X_EXPORT Bool DRI2Authenticate(ClientPtr client, ScreenPtr pScreen, uint32_t magic);
+extern _X_EXPORT void DRI2SendAuthReply(ClientPtr client, Bool status);
+
extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client,
DrawablePtr pDraw,
XID id,
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index e1decec..4ab0186 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -136,11 +136,23 @@ ProcDRI2Connect(ClientPtr client)
return Success;
}
+void
+DRI2SendAuthReply(ClientPtr client, Bool status)
+{
+ xDRI2AuthenticateReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .authenticated = status
+ };
+
+ WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep);
+}
+
static int
ProcDRI2Authenticate(ClientPtr client)
{
REQUEST(xDRI2AuthenticateReq);
- xDRI2AuthenticateReply rep;
DrawablePtr pDraw;
int status;
@@ -149,13 +161,12 @@ ProcDRI2Authenticate(ClientPtr client)
&pDraw, &status))
return status;
- rep = (xDRI2AuthenticateReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .authenticated = DRI2Authenticate(client, pDraw->pScreen, stuff->magic)
- };
- WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep);
+ status = DRI2Authenticate(client, pDraw->pScreen, stuff->magic);
+
+ /* if non-blocking authentication is in progress, then don't send a reply
+ * now but later in the implementation (e.g. drm_handle_authenticated) */
+ if (client->ignoreCount == 0)
+ DRI2SendAuthReply(client, status);
return Success;
}
--
1.8.3.1
More information about the xorg-devel
mailing list