dri3: Allow asynchronous implementation for dri3_open
By passing the client pointer to the dri3_open implementation, we allow the clients to implement the open callback asynchronously. If the client ignore count is positive after returning from dri3_open, we assume that authentication is in progress and doesn't send the reply. The code to send the reply is moved into a helper function, which the implementation can call upon receiving its authenticaion reply. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
4ba7b59446
commit
9ba2084321
|
@ -32,7 +32,8 @@
|
||||||
|
|
||||||
#define DRI3_SCREEN_INFO_VERSION 0
|
#define DRI3_SCREEN_INFO_VERSION 0
|
||||||
|
|
||||||
typedef int (*dri3_open_proc)(ScreenPtr screen,
|
typedef int (*dri3_open_proc)(ClientPtr client,
|
||||||
|
ScreenPtr screen,
|
||||||
RRProviderPtr provider,
|
RRProviderPtr provider,
|
||||||
int *fd);
|
int *fd);
|
||||||
|
|
||||||
|
@ -60,6 +61,9 @@ typedef struct dri3_screen_info {
|
||||||
extern _X_EXPORT Bool
|
extern _X_EXPORT Bool
|
||||||
dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info);
|
dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info);
|
||||||
|
|
||||||
|
extern _X_EXPORT int
|
||||||
|
dri3_send_open_reply(ClientPtr client, int fd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _DRI3_H_ */
|
#endif /* _DRI3_H_ */
|
||||||
|
|
|
@ -55,16 +55,35 @@ proc_dri3_query_version(ClientPtr client)
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
proc_dri3_open(ClientPtr client)
|
dri3_send_open_reply(ClientPtr client, int fd)
|
||||||
{
|
{
|
||||||
REQUEST(xDRI3OpenReq);
|
|
||||||
xDRI3OpenReply rep = {
|
xDRI3OpenReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.nfd = 1,
|
.nfd = 1,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = 0,
|
.length = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (client->swapped) {
|
||||||
|
swaps(&rep.sequenceNumber);
|
||||||
|
swapl(&rep.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WriteFdToClient(client, fd, TRUE) < 0) {
|
||||||
|
close(fd);
|
||||||
|
return BadAlloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteToClient(client, sizeof (rep), &rep);
|
||||||
|
|
||||||
|
return Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
proc_dri3_open(ClientPtr client)
|
||||||
|
{
|
||||||
|
REQUEST(xDRI3OpenReq);
|
||||||
RRProviderPtr provider;
|
RRProviderPtr provider;
|
||||||
DrawablePtr drawable;
|
DrawablePtr drawable;
|
||||||
ScreenPtr screen;
|
ScreenPtr screen;
|
||||||
|
@ -92,17 +111,8 @@ proc_dri3_open(ClientPtr client)
|
||||||
if (status != Success)
|
if (status != Success)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->ignoreCount == 0)
|
||||||
swaps(&rep.sequenceNumber);
|
return dri3_send_open_reply(client, fd);
|
||||||
swapl(&rep.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WriteFdToClient(client, fd, TRUE) < 0) {
|
|
||||||
close(fd);
|
|
||||||
return BadAlloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToClient(client, sizeof (rep), &rep);
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ dri3_open(ClientPtr client, ScreenPtr screen, RRProviderPtr provider, int *fd)
|
||||||
if (!info || !info->open)
|
if (!info || !info->open)
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
|
|
||||||
rc = (*info->open) (screen, provider, fd);
|
rc = (*info->open) (client, screen, provider, fd);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
|
|
@ -608,7 +608,8 @@ glamor_egl_close_screen(ScreenPtr screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
glamor_dri3_open(ScreenPtr screen,
|
glamor_dri3_open(ClientPtr client,
|
||||||
|
ScreenPtr screen,
|
||||||
RRProviderPtr provider,
|
RRProviderPtr provider,
|
||||||
int *fdp)
|
int *fdp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user