(!1893) 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:
		
							parent
							
								
									ca5105ad98
								
							
						
					
					
						commit
						357ec6acb6
					
				|  | @ -3349,7 +3349,6 @@ ProcChangeHosts(ClientPtr client) | ||||||
| int | int | ||||||
| ProcListHosts(ClientPtr client) | ProcListHosts(ClientPtr client) | ||||||
| { | { | ||||||
|     xListHostsReply reply; |  | ||||||
|     int len, nHosts, result; |     int len, nHosts, result; | ||||||
|     BOOL enabled; |     BOOL enabled; | ||||||
|     void *pdata; |     void *pdata; | ||||||
|  | @ -3367,18 +3366,33 @@ ProcListHosts(ClientPtr client) | ||||||
|     if (result != Success) |     if (result != Success) | ||||||
|         return result; |         return result; | ||||||
| 
 | 
 | ||||||
|     reply = (xListHostsReply) { |     xListHostsReply rep = { | ||||||
|         .type = X_Reply, |         .type = X_Reply, | ||||||
|         .enabled = enabled, |         .enabled = enabled, | ||||||
|         .sequenceNumber = client->sequence, |         .sequenceNumber = client->sequence, | ||||||
|         .length = bytes_to_int32(len), |         .length = bytes_to_int32(len), | ||||||
|         .nHosts = nHosts |         .nHosts = nHosts | ||||||
|     }; |     }; | ||||||
|     WriteReplyToClient(client, sizeof(xListHostsReply), &reply); | 
 | ||||||
|     if (nHosts) { |     if (client->swapped) { | ||||||
|         client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend; |         char *bufT = pdata; | ||||||
|         WriteSwappedDataToClient(client, len, 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); |     free(pdata); | ||||||
|     return Success; |     return Success; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -318,31 +318,6 @@ SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply * pRep) | ||||||
|     WriteToClient(pClient, size, 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 | void _X_COLD | ||||||
| SErrorEvent(xError * from, xError * to) | SErrorEvent(xError * from, xError * to) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -825,7 +825,7 @@ ReplySwapPtr ReplySwapVector[256] = { | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     (ReplySwapPtr) SListHostsReply,             /* 110 */ |     ReplyNotSwappd,                             /* 110 */ | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|     ReplyNotSwappd, |     ReplyNotSwappd, | ||||||
|  |  | ||||||
|  | @ -72,14 +72,6 @@ extern void SListExtensionsReply(ClientPtr /* pClient */ , | ||||||
|                                  int /* size */ , |                                  int /* size */ , | ||||||
|                                  xListExtensionsReply * /* pRep */ ); |                                  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 */ , | extern void SErrorEvent(xError * /* from */ , | ||||||
|                         xError * /* to */ ); |                         xError * /* to */ ); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue