dix: write out X_ListHosts reply directly

No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-04 17:43:57 +02:00
parent 5fd2c1c70a
commit 62687ea1c2
4 changed files with 21 additions and 40 deletions

View File

@ -3349,7 +3349,6 @@ ProcChangeHosts(ClientPtr client)
int
ProcListHosts(ClientPtr client)
{
xListHostsReply reply;
int len, nHosts, result;
BOOL enabled;
void *pdata;
@ -3367,18 +3366,33 @@ ProcListHosts(ClientPtr client)
if (result != Success)
return result;
reply = (xListHostsReply) {
xListHostsReply rep = {
.type = X_Reply,
.enabled = enabled,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(len),
.nHosts = nHosts
};
WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
if (nHosts) {
client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
WriteSwappedDataToClient(client, len, pdata);
if (client->swapped) {
char *bufT = pdata;
char *endbuf = bufT + len;
while (bufT < endbuf) {
xHostEntry *host = (xHostEntry *) bufT;
int l1 = host->length;
swaps(&host->length);
bufT += sizeof(xHostEntry) + pad_to_int32(l1);
}
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.nHosts);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, len, pdata);
free(pdata);
return Success;
}

View File

@ -318,31 +318,6 @@ SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply * pRep)
WriteToClient(pClient, size, pRep);
}
void _X_COLD
SLHostsExtend(ClientPtr pClient, int size, char *buf)
{
char *bufT = buf;
char *endbuf = buf + size;
while (bufT < endbuf) {
xHostEntry *host = (xHostEntry *) bufT;
int len = host->length;
swaps(&host->length);
bufT += sizeof(xHostEntry) + pad_to_int32(len);
}
WriteToClient(pClient, size, buf);
}
void _X_COLD
SListHostsReply(ClientPtr pClient, int size, xListHostsReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->length);
swaps(&pRep->nHosts);
WriteToClient(pClient, size, pRep);
}
void _X_COLD
SErrorEvent(xError * from, xError * to)
{

View File

@ -825,7 +825,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd,
ReplyNotSwappd,
ReplyNotSwappd,
(ReplySwapPtr) SListHostsReply, /* 110 */
ReplyNotSwappd, /* 110 */
ReplyNotSwappd,
ReplyNotSwappd,
ReplyNotSwappd,

View File

@ -72,14 +72,6 @@ extern void SListExtensionsReply(ClientPtr /* pClient */ ,
int /* size */ ,
xListExtensionsReply * /* pRep */ );
extern void SLHostsExtend(ClientPtr /* pClient */ ,
int /* size */ ,
char * /* buf */ );
extern void SListHostsReply(ClientPtr /* pClient */ ,
int /* size */ ,
xListHostsReply * /* pRep */ );
extern void SErrorEvent(xError * /* from */ ,
xError * /* to */ );