From a9ed5a87902a839a5a135af03db78f113b18bd86 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 1 Jun 2006 22:06:41 +0000 Subject: Kill LBX, too. --- os/Makefile.am | 5 - os/access.c | 6 +- os/connection.c | 212 ++-------------------- os/io.c | 86 +-------- os/lbxio.c | 555 -------------------------------------------------------- os/osdep.h | 26 --- os/utils.c | 5 +- 7 files changed, 17 insertions(+), 878 deletions(-) delete mode 100644 os/lbxio.c (limited to 'os') diff --git a/os/Makefile.am b/os/Makefile.am index c4ebf21a5..d7fd58d28 100644 --- a/os/Makefile.am +++ b/os/Makefile.am @@ -9,7 +9,6 @@ INTERNALMALLOC_SOURCES = xalloc.c XCSECURITY_SOURCES = secauth.c XDMCP_SOURCES = xdmcp.c -LBX_SOURCES = lbxio.c STRLCAT_SOURCES = strlcat.c strlcpy.c XORG_SOURCES = log.c @@ -38,10 +37,6 @@ if XDMCP libos_la_SOURCES += $(XDMCP_SOURCES) endif -if LBX -libos_la_SOURCES += $(LBX_SOURCES) -endif - if NEED_STRLCAT libos_la_SOURCES += $(STRLCAT_SOURCES) endif diff --git a/os/access.c b/os/access.c index 75e6de325..62af2f91f 100644 --- a/os/access.c +++ b/os/access.c @@ -1,5 +1,5 @@ /* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */ -/* $XdotOrg: xserver/xorg/os/access.c,v 1.14 2006/01/07 00:45:17 ajax Exp $ */ +/* $XdotOrg: xserver/xorg/os/access.c,v 1.15 2006/02/15 20:44:13 ajax Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -1391,10 +1391,6 @@ _X_EXPORT Bool LocalClient(ClientPtr client) client->index); return FALSE; } -#endif -#ifdef LBX - if (!((OsCommPtr)client->osPrivate)->trans_conn) - return FALSE; #endif if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn, ¬used, &alen, &from)) diff --git a/os/connection.c b/os/connection.c index 8a7eb872a..21c1ea641 100644 --- a/os/connection.c +++ b/os/connection.c @@ -154,12 +154,6 @@ extern __const__ int _nfiles; #define _SECURITY_SERVER #include #endif -#ifdef LBX -#include "colormapst.h" -#include "propertyst.h" -#include "lbxserve.h" -#include "osdep.h" -#endif #ifdef X_NOT_POSIX #define Pid_t int @@ -300,14 +294,6 @@ int ListenTransCount; static void ErrorConnMax(XtransConnInfo /* trans_conn */); -#ifndef LBX -static -void CloseDownFileDescriptor( - OsCommPtr /*oc*/ -); -#endif - - static XtransConnInfo lookup_trans_conn (int fd) { @@ -564,10 +550,6 @@ AuthAudit (ClientPtr client, Bool letin, char addr[128]; char *out = addr; - if (!((OsCommPtr)client->osPrivate)->trans_conn) { - strcpy(addr, "LBX proxy at "); - out += strlen(addr); - } if (!len) strcpy(out, "local host"); else @@ -654,67 +636,13 @@ ClientAuthorized(ClientPtr client, XID auth_id; char *reason = NULL; XtransConnInfo trans_conn; -#ifdef LBX - int restore_trans_conn = 0; - ClientPtr lbxpc = NULL; -#endif priv = (OsCommPtr)client->osPrivate; trans_conn = priv->trans_conn; -#ifdef LBX - if (!trans_conn) { - /* - * Since trans_conn is NULL, this must be a proxy's client for - * which we have NO address. Therefore, we will temporarily - * set the client's trans_conn to the proxy's trans_conn and - * after CheckAuthorization the client's trans_conn will be - * restored. - * - * If XDM-AUTHORIZATION-1 is being used, CheckAuthorization - * will eventually call XdmAuthorizationValidate and this - * later function may use the client's trans_conn to get the - * client's address. Since a XDM-AUTH-1 auth string includes - * the client's address, this address is compared to the address - * in the client's trans_conn. If the proxy and client are - * on the same host, the comparison will fail; otherwise the - * comparison will fail and the client will not be authorized - * to connect to the server. - * - * The basis for this additional code is to prevent a - * NULL pointer dereference of the client's trans_conn. - * The fundamental problem - the fact that the client's - * trans_conn is NULL - is because the NewClient - * request in version 1.0 of the LBX protocol does not - * send the client's address to the server. When the - * spec is changed and the client's address is sent to - * server in the NewClient request, this additional code - * should be removed. - * - * See defect number XWSog08218 for more information. - */ - lbxpc = LbxProxyClient(priv->proxy); - trans_conn = ((OsCommPtr)lbxpc->osPrivate)->trans_conn; - priv->trans_conn = trans_conn; - restore_trans_conn = 1; - } -#endif - auth_id = CheckAuthorization (proto_n, auth_proto, string_n, auth_string, client, &reason); -#ifdef LBX - if (! priv->trans_conn) { - if (auth_id == (XID) ~0L && !GetAccessControl()) - auth_id = ((OsCommPtr)lbxpc->osPrivate)->auth_id; -#ifdef XCSECURITY - else if (auth_id != (XID) ~0L && !SecuritySameLevel(lbxpc, auth_id)) { - auth_id = (XID) ~0L; - reason = "Client trust level differs from that of LBX Proxy"; - } -#endif - } -#endif if (auth_id == (XID) ~0L) { if ( @@ -725,11 +653,7 @@ ClientAuthorized(ClientPtr client, _XSERVTransGetPeerAddr (trans_conn, &family, &fromlen, &from) != -1) { - if ( -#ifdef LBX - !trans_conn || -#endif - InvalidHost ((struct sockaddr *) from, fromlen, client)) + if (InvalidHost ((struct sockaddr *) from, fromlen, client)) AuthAudit(client, FALSE, (struct sockaddr *) from, fromlen, proto_n, auth_proto, auth_id); else @@ -745,14 +669,6 @@ ClientAuthorized(ClientPtr client, } if (auth_id == (XID) ~0L) { -#ifdef LBX - /* - * Restore client's trans_conn state - */ - if (restore_trans_conn) { - priv->trans_conn = NULL; - } -#endif if (reason) return reason; else @@ -787,34 +703,16 @@ ClientAuthorized(ClientPtr client, * true purpose of the selfhosts list is to see who may change the * access control list. */ -#ifdef LBX - if (restore_trans_conn) { - priv->trans_conn = NULL; - } -#endif return((char *)NULL); } static ClientPtr -#ifdef LBX -AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time, - int (*Flush)( - ClientPtr /*who*/, OsCommPtr /*oc*/, - char * /*extraBuf*/, int /*extraCount*/), - void (*Close)( - ClientPtr /*client*/), - LbxProxyPtr proxy) -#else AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) -#endif { OsCommPtr oc; ClientPtr client; if ( -#ifdef LBX - trans_conn && -#endif #ifndef WIN32 fd >= lastfdesc #else @@ -831,36 +729,25 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) oc->output = (ConnectionOutputPtr)NULL; oc->auth_id = None; oc->conn_time = conn_time; -#ifdef LBX - oc->proxy = proxy; - oc->Flush = Flush; - oc->Close = Close; - oc->largereq = (ConnectionInputPtr) NULL; -#endif if (!(client = NextAvailableClient((pointer)oc))) { xfree (oc); return NullClient; } -#ifdef LBX - if (trans_conn) -#endif - { #if !defined(WIN32) - ConnectionTranslation[fd] = client->index; + ConnectionTranslation[fd] = client->index; #else - SetConnectionTranslation(fd, client->index); + SetConnectionTranslation(fd, client->index); #endif - if (GrabInProgress) - { - FD_SET(fd, &SavedAllClients); - FD_SET(fd, &SavedAllSockets); - } - else - { - FD_SET(fd, &AllClients); - FD_SET(fd, &AllSockets); - } + if (GrabInProgress) + { + FD_SET(fd, &SavedAllClients); + FD_SET(fd, &SavedAllSockets); + } + else + { + FD_SET(fd, &AllClients); + FD_SET(fd, &AllSockets); } #ifdef DEBUG @@ -871,39 +758,6 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) return client; } -#ifdef LBX - -int -ClientConnectionNumber (ClientPtr client) -{ - OsCommPtr oc = (OsCommPtr) client->osPrivate; - - return oc->fd; -} - -ClientPtr -AllocLbxClientConnection (ClientPtr client, LbxProxyPtr proxy) -{ - OsCommPtr oc = (OsCommPtr) client->osPrivate; - - return AllocNewConnection ((XtransConnInfo)NULL, oc->fd, GetTimeInMillis(), - LbxFlushClient, LbxCloseClient, proxy); -} - -void -LbxProxyConnection (ClientPtr client, LbxProxyPtr proxy) -{ - OsCommPtr oc = (OsCommPtr) client->osPrivate; - - FlushClient(client, oc, (char *)NULL, 0); - oc->proxy = proxy; - oc->Flush = LbxFlushClient; - oc->Close = LbxCloseClient; - LbxPrimeInput(client, proxy); -} - -#endif - /***************** * EstablishNewConnections * If anyone is waiting on listened sockets, accept them. @@ -982,12 +836,7 @@ EstablishNewConnections(ClientPtr clientUnused, pointer closure) _XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1); - if (!AllocNewConnection (new_trans_conn, newconn, connect_time -#ifdef LBX - , StandardFlushClient, - CloseDownFileDescriptor, (LbxProxyPtr)NULL -#endif - )) + if (!AllocNewConnection (new_trans_conn, newconn, connect_time)) { ErrorConnMax(new_trans_conn); _XSERVTransClose(new_trans_conn); @@ -1056,27 +905,15 @@ ErrorConnMax(XtransConnInfo trans_conn) * Remove this file descriptor and it's I/O buffers, etc. ************/ -#ifdef LBX -void -CloseDownFileDescriptor(ClientPtr client) -#else static void CloseDownFileDescriptor(OsCommPtr oc) -#endif { -#ifdef LBX - OsCommPtr oc = (OsCommPtr) client->osPrivate; -#endif int connection = oc->fd; if (oc->trans_conn) { _XSERVTransDisconnect(oc->trans_conn); _XSERVTransClose(oc->trans_conn); } -#ifndef LBX - FreeOsBuffers(oc); - xfree(oc); -#endif #ifndef WIN32 ConnectionTranslation[connection] = 0; #else @@ -1171,13 +1008,7 @@ CloseDownConnection(ClientPtr client) #ifdef XDMCP XdmcpCloseDisplay(oc->fd); #endif -#ifndef LBX CloseDownFileDescriptor(oc); -#else - (*oc->Close) (client); - FreeOsBuffers(oc); - xfree(oc); -#endif client->osPrivate = (pointer)NULL; if (auditTrailLevel > 1) AuditF("client %d disconnected\n", client->index); @@ -1266,17 +1097,8 @@ IgnoreClient (ClientPtr client) { OsCommPtr oc = (OsCommPtr)client->osPrivate; int connection = oc->fd; -#ifdef LBX - LbxClientPtr lbxClient = LbxClient(client); -#endif isItTimeToYield = TRUE; -#ifdef LBX - if (lbxClient) { - lbxClient->ignored = TRUE; - return; - } -#endif if (!GrabInProgress || FD_ISSET(connection, &AllClients)) { if (FD_ISSET (connection, &ClientsWithInput)) @@ -1310,14 +1132,6 @@ AttendClient (ClientPtr client) { OsCommPtr oc = (OsCommPtr)client->osPrivate; int connection = oc->fd; -#ifdef LBX - LbxClientPtr lbxClient = LbxClient(client); - - if (lbxClient) { - lbxClient->ignored = FALSE; - return; - } -#endif if (!GrabInProgress || GrabInProgress == client->index || FD_ISSET(connection, &GrabImperviousClients)) { diff --git a/os/io.c b/os/io.c index 867512d55..a9527baa3 100644 --- a/os/io.c +++ b/os/io.c @@ -85,11 +85,6 @@ SOFTWARE. #include "opaque.h" #include "dixstruct.h" #include "misc.h" -#ifdef LBX -#include "colormapst.h" -#include "propertyst.h" -#include "lbxserve.h" -#endif _X_EXPORT CallbackListPtr ReplyCallback; _X_EXPORT CallbackListPtr FlushCallback; @@ -200,25 +195,8 @@ OsCommPtr AvailableInput = (OsCommPtr)NULL; #define YieldControlDeath() \ { timesThisConnection = 0; } -#ifdef hpux_not_tog -#define LBX_NEED_OLD_SYMBOL_FOR_LOADABLES -#endif - -#ifdef LBX -#ifdef LBX_NEED_OLD_SYMBOL_FOR_LOADABLES -#undef ReadRequestFromClient int ReadRequestFromClient(ClientPtr client) -{ - return (*client->readRequest)(client); -} -#endif -int -StandardReadRequestFromClient(ClientPtr client) -#else -int -ReadRequestFromClient(ClientPtr client) -#endif { OsCommPtr oc = (OsCommPtr)client->osPrivate; ConnectionInputPtr oci = oc->input; @@ -368,13 +346,6 @@ ReadRequestFromClient(ClientPtr client) YieldControlDeath(); return -1; } -#ifdef LBX - if (oc->proxy && oc->proxy->compHandle) - result = (*oc->proxy->streamOpts.streamCompRead)(fd, - (unsigned char *)oci->buffer + oci->bufcnt, - oci->size - oci->bufcnt); - else -#endif result = _XSERVTransRead(oc->trans_conn, oci->buffer + oci->bufcnt, oci->size - oci->bufcnt); if (result <= 0) @@ -382,17 +353,7 @@ ReadRequestFromClient(ClientPtr client) if ((result < 0) && ETEST(errno)) { #if defined(SVR4) && defined(i386) && !defined(sun) -#if defined(LBX) && 0 - /* - * For LBX connections, we can get a valid EWOULDBLOCK - * There is probably a better way of distinguishing LBX - * connections, but this works. (DHD) - */ - extern int LbxRead(); - if (oc->Read == LbxRead) -#else if (0) -#endif #endif { YieldControlNoInput(); @@ -610,18 +571,6 @@ ResetCurrentRequest(ClientPtr client) int fd = oc->fd; register xReq *request; int gotnow, needed; -#ifdef LBX - LbxClientPtr lbxClient = LbxClient(client); - - if (lbxClient) { - LbxSetForBlock(lbxClient); - if (!oci) { - AppendFakeRequest(client, - client->requestBuffer, client->req_len << 2); - return; - } - } -#endif if (AvailableInput == oc) AvailableInput = (OsCommPtr)NULL; oci->lenLastReq = 0; @@ -850,11 +799,7 @@ FlushAllOutput(void) if (client->clientGone) continue; oc = (OsCommPtr)client->osPrivate; - if ( -#ifdef LBX - !oc->proxy && -#endif - FD_ISSET(oc->fd, &ClientsWithInput)) + if (FD_ISSET(oc->fd, &ClientsWithInput)) { FD_SET(oc->fd, &OutputPending); /* set the bit again */ NewOutputPending = TRUE; @@ -874,11 +819,7 @@ FlushAllOutput(void) if (client->clientGone) continue; oc = (OsCommPtr)client->osPrivate; - if ( -#ifdef LBX - !oc->proxy && -#endif - FD_ISSET(oc->fd, &ClientsWithInput)) + if (FD_ISSET(oc->fd, &ClientsWithInput)) { FD_SET(oc->fd, &newOutputPending); /* set the bit again */ NewOutputPending = TRUE; @@ -1055,22 +996,8 @@ WriteToClient (ClientPtr who, int count, char *buf) * **********************/ -#ifdef LBX -#ifdef LBX_NEED_OLD_SYMBOL_FOR_LOADABLES -#undef FlushClient -int -FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount) -{ - return (*oc->Flush)(who, oc, extraBuf, extraCount); -} -#endif -int -StandardFlushClient(ClientPtr who, OsCommPtr oc, - char *extraBuf, int extraCount) -#else int FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount) -#endif { ConnectionOutputPtr oco = oc->output; int connection = oc->fd; @@ -1274,9 +1201,6 @@ AllocateOutputBuffer(void) } oco->size = BUFSIZE; oco->count = 0; -#ifdef LBX - oco->nocompress = FALSE; -#endif return oco; } @@ -1318,12 +1242,6 @@ FreeOsBuffers(OsCommPtr oc) oco->count = 0; } } -#ifdef LBX - if ((oci = oc->largereq)) { - xfree(oci->buffer); - xfree(oci); - } -#endif } void diff --git a/os/lbxio.c b/os/lbxio.c deleted file mode 100644 index 97ae958e3..000000000 --- a/os/lbxio.c +++ /dev/null @@ -1,555 +0,0 @@ -/* $XFree86: xc/programs/Xserver/os/lbxio.c,v 3.17 2002/05/31 18:46:06 dawes Exp $ */ -/* - -Copyright 1996, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/*********************************************************** -Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts, -and the Massachusetts Institute of Technology, Cambridge, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or MIT not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $Xorg: lbxio.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#ifndef Lynx -#include -#ifndef __UNIXOS2__ -#include -#endif -#else -#include -#endif -#include -#include -#include "os.h" -#include -#include "osdep.h" -#include "opaque.h" -#include "dixstruct.h" -#include "misc.h" -#include "colormapst.h" -#include "propertyst.h" -#include "lbxserve.h" - -/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX - * systems are broken and return EWOULDBLOCK when they should return EAGAIN - */ -#if defined(EAGAIN) && defined(EWOULDBLOCK) -#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK) -#else -#ifdef EAGAIN -#define ETEST(err) (err == EAGAIN) -#else -#define ETEST(err) (err == EWOULDBLOCK) -#endif -#endif - -#define get_req_len(req,cli) ((cli)->swapped ? \ - lswaps((req)->length) : (req)->length) - -#define YieldControl() \ - { isItTimeToYield = TRUE; \ - timesThisConnection = 0; } -#define YieldControlNoInput() \ - { YieldControl(); \ - FD_CLR(fd, &ClientsWithInput); } - -void -SwitchClientInput (ClientPtr client, Bool pending) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - -#ifndef WIN32 - ConnectionTranslation[oc->fd] = client->index; -#else - SetConnectionTranslation(oc->fd, client->index); -#endif - if (pending) - FD_SET(oc->fd, &ClientsWithInput); - else - YieldControl(); -} - -void -LbxPrimeInput(ClientPtr client, LbxProxyPtr proxy) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - ConnectionInputPtr oci = oc->input; - - if (oci && proxy->compHandle) { - char *extra = oci->bufptr + oci->lenLastReq; - int left = oci->bufcnt + oci->buffer - extra; - - (*proxy->streamOpts.streamCompStuffInput)(oc->fd, - (unsigned char *)extra, - left); - oci->bufcnt -= left; - AvailableInput = oc; - } -} - -void -AvailableClientInput (ClientPtr client) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - - if (FD_ISSET(oc->fd, &AllSockets)) - FD_SET(oc->fd, &ClientsWithInput); -} - -/***************************************************************** - * AppendFakeRequest - * Append a (possibly partial) request in as the last request. - * - **********************/ - -Bool -AppendFakeRequest (ClientPtr client, char *data, int count) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - ConnectionInputPtr oci = oc->input; - int fd = oc->fd; - int gotnow; - - if (!oci) - { - if ((oci = FreeInputs)) - FreeInputs = oci->next; - else if (!(oci = AllocateInputBuffer())) - return FALSE; - oc->input = oci; - } else if (AvailableInput == oc) - AvailableInput = (OsCommPtr)NULL; - /* do not free AvailableInput here, it could be proxy's */ - oci->bufptr += oci->lenLastReq; - oci->lenLastReq = 0; - gotnow = oci->bufcnt + oci->buffer - oci->bufptr; - if ((gotnow + count) > oci->size) - { - char *ibuf; - - ibuf = (char *)xrealloc(oci->buffer, gotnow + count); - if (!ibuf) - return(FALSE); - oci->size = gotnow + count; - oci->buffer = ibuf; - oci->bufptr = ibuf + oci->bufcnt - gotnow; - } - if (oci->bufcnt + count > oci->size) { - memmove(oci->buffer, oci->bufptr, gotnow); - oci->bufcnt = gotnow; - oci->bufptr = oci->buffer; - } - memmove(oci->bufptr + gotnow, data, count); - oci->bufcnt += count; - gotnow += count; - if ((gotnow >= sizeof(xReq)) && - (gotnow >= (int)(get_req_len((xReq *)oci->bufptr, client) << 2))) - FD_SET(fd, &ClientsWithInput); - else - YieldControlNoInput(); - return(TRUE); -} - -static int -LbxWrite(XtransConnInfo trans_conn, LbxProxyPtr proxy, - char *buf, int len) -{ - struct iovec iov; - int n; - int notWritten; - - notWritten = len; - iov.iov_base = buf; - iov.iov_len = len; - while (notWritten) { - errno = 0; - if (proxy->compHandle) - n = (*proxy->streamOpts.streamCompWriteV)(proxy->fd, &iov, 1); - else - n = _XSERVTransWritev(trans_conn, &iov, 1); - if (n >= 0) { - iov.iov_base = (char *)iov.iov_base + n; - notWritten -= n; - iov.iov_len = notWritten; - } - else if (ETEST(errno) -#ifdef SUNSYSV /* check for another brain-damaged OS bug */ - || (errno == 0) -#endif -#ifdef EMSGSIZE /* check for another brain-damaged OS bug */ - || ((errno == EMSGSIZE) && (iov.iov_len == 1)) -#endif - ) - break; -#ifdef EMSGSIZE /* check for another brain-damaged OS bug */ - else if (errno == EMSGSIZE) - iov.iov_len >>= 1; -#endif - else - return -1; - } - return len - notWritten; -} - -static Bool -LbxAppendOutput(LbxProxyPtr proxy, ClientPtr client, ConnectionOutputPtr oco) -{ - ConnectionOutputPtr noco = proxy->olast; - LbxClientPtr lbxClient = LbxClient(client); - - if (!lbxClient) { - xfree(oco->buf); - xfree(oco); - return TRUE; - } - if (noco) - LbxReencodeOutput(client, - (char *)noco->buf, &noco->count, - (char *)oco->buf, &oco->count); - else - LbxReencodeOutput(client, - (char *)NULL, (int *)NULL, - (char *)oco->buf, &oco->count); - if (!oco->count) { - if (oco->size > BUFWATERMARK) - { - xfree(oco->buf); - xfree(oco); - } - else - { - oco->next = FreeOutputs; - FreeOutputs = oco; - } - return TRUE; - } - if ((lbxClient->id != proxy->cur_send_id) && proxy->lbxClients[0]) { - xLbxSwitchEvent *ev; - int n; - - if (!noco || (noco->size - noco->count) < sz_xLbxSwitchEvent) { - if ((noco = FreeOutputs)) - FreeOutputs = noco->next; - else - noco = AllocateOutputBuffer(); - if (!noco) { - MarkClientException(client); - return FALSE; - } - noco->next = NULL; - if (proxy->olast) - proxy->olast->next = noco; - else - proxy->ofirst = noco; - proxy->olast = noco; - } - ev = (xLbxSwitchEvent *) (noco->buf + noco->count); - noco->count += sz_xLbxSwitchEvent; - proxy->cur_send_id = lbxClient->id; - ev->type = LbxEventCode; - ev->lbxType = LbxSwitchEvent; - ev->pad = 0; - ev->client = proxy->cur_send_id; - if (LbxProxyClient(proxy)->swapped) { - swapl(&ev->client, n); - } - } - oco->next = NULL; - if (proxy->olast) - proxy->olast->next = oco; - else - proxy->ofirst = oco; - proxy->olast = oco; - return TRUE; -} - -static int -LbxClientOutput(ClientPtr client, OsCommPtr oc, - char *extraBuf, int extraCount, Bool nocompress) -{ - ConnectionOutputPtr oco; - int len; - - if ((oco = oc->output)) { - oc->output = NULL; - if (!LbxAppendOutput(oc->proxy, client, oco)) - return -1; - } - - if (extraCount) { - NewOutputPending = TRUE; - FD_SET(oc->fd, &OutputPending); - len = (extraCount + 3) & ~3; - if ((oco = FreeOutputs) && (oco->size >= len)) - FreeOutputs = oco->next; - else { - oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput)); - if (!oco) { - MarkClientException(client); - return -1; - } - oco->size = len; - if (oco->size < BUFSIZE) - oco->size = BUFSIZE; - oco->buf = (unsigned char *) xalloc(oco->size); - if (!oco->buf) { - xfree(oco); - MarkClientException(client); - return -1; - } - } - oco->count = len; - oco->nocompress = nocompress; - memmove((char *)oco->buf, extraBuf, extraCount); - if (!nocompress && oco->count < oco->size) - oc->output = oco; - else if (!LbxAppendOutput(oc->proxy, client, oco)) - return -1; - } - return extraCount; -} - -void -LbxForceOutput(LbxProxyPtr proxy) -{ - int i; - LbxClientPtr lbxClient; - OsCommPtr coc; - ConnectionOutputPtr oco; - - for (i = proxy->maxIndex; i >= 0; i--) { /* proxy must be last */ - lbxClient = proxy->lbxClients[i]; - if (!lbxClient) - continue; - coc = (OsCommPtr)lbxClient->client->osPrivate; - if ((oco = coc->output)) { - coc->output = NULL; - LbxAppendOutput(proxy, lbxClient->client, oco); - } - } -} - -int -LbxFlushClient(ClientPtr who, OsCommPtr oc, - char *extraBuf, int extraCount) -{ - LbxProxyPtr proxy; - ConnectionOutputPtr oco; - int n; - XtransConnInfo trans_conn = NULL; - - if (extraBuf) - return LbxClientOutput(who, oc, extraBuf, extraCount, FALSE); - proxy = oc->proxy; - if (!proxy->lbxClients[0]) - return 0; - LbxForceOutput(proxy); - if (!proxy->compHandle) - trans_conn = ((OsCommPtr)LbxProxyClient(proxy)->osPrivate)->trans_conn; - while ((oco = proxy->ofirst)) { - /* XXX bundle up into writev someday */ - if (proxy->compHandle) { - if (oco->nocompress) - (*proxy->streamOpts.streamCompOff)(proxy->fd); - n = LbxWrite(NULL, proxy, (char *)oco->buf, oco->count); - if (oco->nocompress) - (*proxy->streamOpts.streamCompOn)(proxy->fd); - } else - n = LbxWrite(trans_conn, proxy, (char *)oco->buf, oco->count); - if (n < 0) { - ClientPtr pclient = LbxProxyClient(proxy); - if (proxy->compHandle) - trans_conn = ((OsCommPtr)pclient->osPrivate)->trans_conn; - _XSERVTransDisconnect(trans_conn); - _XSERVTransClose(trans_conn); - ((OsCommPtr)pclient->osPrivate)->trans_conn = NULL; - MarkClientException(pclient); - return 0; - } else if (n == oco->count) { - proxy->ofirst = oco->next; - if (!proxy->ofirst) - proxy->olast = NULL; - if (oco->size > BUFWATERMARK) - { - xfree(oco->buf); - xfree(oco); - } - else - { - oco->next = FreeOutputs; - oco->count = 0; - FreeOutputs = oco; - } - } else { - if (n) { - oco->count -= n; - memmove((char *)oco->buf, (char *)oco->buf + n, oco->count); - } - break; - } - } - if ((proxy->compHandle && - (*proxy->streamOpts.streamCompFlush)(proxy->fd)) || - proxy->ofirst) { - FD_SET(proxy->fd, &ClientsWriteBlocked); - AnyClientsWriteBlocked = TRUE; - } - return 0; -} - -int -UncompressedWriteToClient (ClientPtr who, int count, char *buf) -{ - return LbxClientOutput(who, (OsCommPtr)who->osPrivate, buf, count, TRUE); -} - -void -LbxFreeOsBuffers(LbxProxyPtr proxy) -{ - ConnectionOutputPtr oco; - - while ((oco = proxy->ofirst)) { - proxy->ofirst = oco->next; - xfree(oco->buf); - xfree(oco); - } -} - -Bool -AllocateLargeReqBuffer(ClientPtr client, int size) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - ConnectionInputPtr oci; - - if (!(oci = oc->largereq)) { - if ((oci = FreeInputs)) - FreeInputs = oci->next; - else { - oci = (ConnectionInputPtr)xalloc(sizeof(ConnectionInput)); - if (!oci) - return FALSE; - oci->buffer = NULL; - oci->size = 0; - } - } - if (oci->size < size) { - char *ibuf; - - oci->size = size; - if (size < BUFSIZE) - oci->size = BUFSIZE; - if (!(ibuf = (char *)xrealloc(oci->buffer, oci->size))) - { - xfree(oci->buffer); - xfree(oci); - oc->largereq = NULL; - return FALSE; - } - oci->buffer = ibuf; - } - oci->bufptr = oci->buffer; - oci->bufcnt = 0; - oci->lenLastReq = size; - oc->largereq = oci; - return TRUE; -} - -Bool -AddToLargeReqBuffer(ClientPtr client, char *data, int size) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - ConnectionInputPtr oci = oc->largereq; - - if (!oci || (oci->bufcnt + size > oci->lenLastReq)) - return FALSE; - memcpy(oci->buffer + oci->bufcnt, data, size); - oci->bufcnt += size; - return TRUE; -} - -static OsCommRec lbxAvailableInput; - -int -PrepareLargeReqBuffer(ClientPtr client) -{ - OsCommPtr oc = (OsCommPtr)client->osPrivate; - ConnectionInputPtr oci = oc->largereq; - - if (!oci) - return client->req_len << 2; - oc->largereq = NULL; - if (oci->bufcnt != oci->lenLastReq) { - xfree(oci->buffer); - xfree(oci); - return client->req_len << 2; - } - client->requestBuffer = oci->buffer; - client->req_len = oci->lenLastReq >> 2; - oci->bufcnt = 0; - oci->lenLastReq = 0; - if (AvailableInput) - { - ConnectionInputPtr aci = AvailableInput->input; - if (aci->size > BUFWATERMARK) - { - xfree(aci->buffer); - xfree(aci); - } - else - { - aci->next = FreeInputs; - FreeInputs = aci; - } - AvailableInput->input = (ConnectionInputPtr)NULL; - } - lbxAvailableInput.input = oci; - AvailableInput = &lbxAvailableInput; - return client->req_len << 2; -} diff --git a/os/osdep.h b/os/osdep.h index f566ac5d1..259237d37 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -145,9 +145,6 @@ typedef struct _connectionOutput { int size; unsigned char *buf; int count; -#ifdef LBX - Bool nocompress; -#endif } ConnectionOutput, *ConnectionOutputPtr; #ifdef K5AUTH @@ -160,10 +157,6 @@ typedef struct _k5_state { } k5_state; #endif -#ifdef LBX -typedef struct _LbxProxy *OsProxyPtr; -#endif - struct _osComm; #define AuthInitArgs void @@ -204,33 +197,14 @@ typedef struct _osComm { #endif CARD32 conn_time; /* timestamp if not established, else 0 */ struct _XtransConnInfo *trans_conn; /* transport connection object */ -#ifdef LBX - OsProxyPtr proxy; - ConnectionInputPtr largereq; - OsCloseFunc Close; - OsFlushFunc Flush; -#endif } OsCommRec, *OsCommPtr; -#ifdef LBX -#define FlushClient(who, oc, extraBuf, extraCount) \ - (*(oc)->Flush)(who, oc, extraBuf, extraCount) -extern int StandardFlushClient( - ClientPtr /*who*/, - OsCommPtr /*oc*/, - char* /*extraBuf*/, - int /*extraCount*/ -); -extern int LbxFlushClient(ClientPtr /*who*/, OsCommPtr /*oc*/, - char * /*extraBuf*/, int /*extraCount*/); -#else extern int FlushClient( ClientPtr /*who*/, OsCommPtr /*oc*/, char* /*extraBuf*/, int /*extraCount*/ ); -#endif extern void FreeOsBuffers( OsCommPtr /*oc*/ diff --git a/os/utils.c b/os/utils.c index 173013ac1..bfbc367c5 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xserver/xorg/os/utils.c,v 1.24 2006/02/16 07:17:31 keithp Exp $ */ +/* $XdotOrg: xserver/xorg/os/utils.c,v 1.25 2006/03/25 19:52:05 ajax Exp $ */ /* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */ /* @@ -164,9 +164,6 @@ _X_EXPORT Bool noFontCacheExtension = FALSE; #ifdef GLXEXT _X_EXPORT Bool noGlxExtension = FALSE; #endif -#ifdef LBX -_X_EXPORT Bool noLbxExtension = FALSE; -#endif #ifdef SCREENSAVER _X_EXPORT Bool noScreenSaverExtension = FALSE; #endif -- cgit v1.2.3