Unverified Commit f5e7d555 authored by Mihai Moldovan's avatar Mihai Moldovan

Merge branch 'sunweaver-pr/various-os-backports' into 3.6.x

parents b7c389b9 565421ba
......@@ -1289,6 +1289,12 @@ TCLIBDIR = TclLibDir
#ifndef ToolkitStringsABIOptions
#define ToolkitStringsABIOptions /**/
#endif
#ifndef HasSetitimer
#define HasSetitimer YES
#endif
#ifndef HasSetitimerDefines
#define HasSetitimerDefines -DHAVE_SETITIMER=1
#endif
#ifndef HasLdRunPath
#define HasLdRunPath NO
#endif
......@@ -1841,6 +1847,7 @@ MODLDCOMBINEFLAGS = ModuleLdCombineFlags
STD_CPP_OPTIONS = StandardCppOptions
STD_CPP_DEFINES = StandardCppOptions StandardCppDefines $(PROJECT_DEFINES)
STD_DEFINES = StandardDefines $(PROJECT_DEFINES)
SETITIMER_DEFINES = HasSetitimerDefines
EXTRA_LOAD_FLAGS = ExtraLoadFlags
EXTRA_LDOPTIONS = ExtraLoadOptions
EXTRA_LIBRARIES = MallocLibraries ExtraLibraries
......@@ -1966,7 +1973,7 @@ MODLDCOMBINEFLAGS = ModuleLdCombineFlags
* LOCAL_LDFLAGS contains client-specific ld flags flags set in Imakefile
*/
ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(INSTALLED_INCLUDES) $(STD_INCLUDES)
ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(MODULE_DEFINES) $(DEFINES) $(EXTRA_DEFINES)
ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(SETITIMER_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(MODULE_DEFINES) $(DEFINES) $(EXTRA_DEFINES)
CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(MODULE_CFLAGS) $(ALLDEFINES)
LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
LDPRELIB = LdPreLib $(INSTALLED_LIBS)
......
......@@ -323,6 +323,15 @@ NXAGENTNXLIBS = -L../../../nxcomp \
-lXcompshad \
-lXrender -lXfixes -lXfont -lXcomposite -lXdmcp \
-lNX_X11 -lXext
#elif defined(OpenBSDArchitecture)
NXAGENTNXLIBS = -L../../../nxcomp \
-L../../../nx-X11/exports/lib \
-L../../../nxcompshad \
-lkvm \
-lXcomp \
-lXcompshad \
-lXrender -lXfixes -lXfont -lXcomposite -lXinerama -lXdmcp \
-lNX_X11 -lXext
#else
NXAGENTNXLIBS = -L../../../nxcomp \
-L../../../nx-X11/exports/lib \
......
......@@ -150,7 +150,6 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
#include <sys/signal.h>
static Bool badSysCall = FALSE;
......@@ -167,7 +166,7 @@ static Bool CheckForShmSyscall()
int shmid = -1;
/* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
oldHandler = signal(SIGSYS, SigSysHandler);
oldHandler = OsSignal(SIGSYS, SigSysHandler);
badSysCall = FALSE;
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
......@@ -182,7 +181,7 @@ static Bool CheckForShmSyscall()
/* Allocation failed */
badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
OsSignal(SIGSYS, oldHandler);
return(!badSysCall);
}
......
......@@ -106,8 +106,6 @@ static Bool badSysCall = FALSE;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
#include <sys/signal.h>
static void
SigSysHandler(
int signo)
......@@ -122,7 +120,7 @@ CheckForShmSyscall(void)
int shmid = -1;
/* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
oldHandler = signal(SIGSYS, SigSysHandler);
oldHandler = OsSignal(SIGSYS, SigSysHandler);
badSysCall = FALSE;
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
......@@ -136,7 +134,7 @@ CheckForShmSyscall(void)
/* Allocation failed */
badSysCall = TRUE;
}
signal(SIGSYS, oldHandler);
OsSignal(SIGSYS, oldHandler);
return (!badSysCall);
}
......@@ -368,7 +366,7 @@ ProcXF86BigfontQueryVersion(
#endif
reply.capabilities =
#ifdef HAS_SHM
(LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
(client->local && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
#else
0
#endif
......@@ -432,7 +430,7 @@ ProcXF86BigfontQueryFont(
#else
switch (client->req_len) {
case 2: /* client with version 1.0 libX11 */
stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
stuff_flags = (client->local && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
break;
case 3: /* client with version 1.1 libX11 */
stuff_flags = stuff->flags;
......
......@@ -112,6 +112,7 @@ int ProcInitialConnection();
#include "inputstr.h"
#include "xkbsrv.h"
#endif
#include "client.h"
#define mskcnt ((MAXCLIENTS + 31) / 32)
#define BITMASK(i) (1U << ((i) & 31))
......@@ -221,7 +222,11 @@ InitSelections()
#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */
#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */
Bool SmartScheduleDisable = FALSE;
#ifdef HAVE_SETITIMER
#define SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE HAVE_SETITIMER
Bool SmartScheduleSignalEnable = SMART_SCHEDULE_DEFAULT_SIGNAL_ENABLE;
#endif
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
......@@ -240,15 +245,13 @@ void InitProcVectors(void);
int
SmartScheduleClient (int *clientReady, int nready)
{
ClientPtr pClient;
int i;
int client;
int bestPrio, best = 0;
ClientPtr pClient, best = NULL;
int bestRobin, robin;
long now = SmartScheduleTime;
long idle;
bestPrio = -0x7fffffff;
bestRobin = 0;
idle = 2 * SmartScheduleSlice;
for (i = 0; i < nready; i++)
......@@ -264,13 +267,19 @@ SmartScheduleClient (int *clientReady, int nready)
pClient->smart_check_tick = now;
/* check priority to select best client */
robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff;
if (pClient->smart_priority > bestPrio ||
(pClient->smart_priority == bestPrio && robin > bestRobin))
robin = (pClient->index -
SmartLastIndex[pClient->smart_priority -
SMART_MIN_PRIORITY]) & 0xff;
/* pick the best client */
if (!best ||
pClient->priority > best->priority ||
(pClient->priority == best->priority &&
(pClient->smart_priority > best->smart_priority ||
(pClient->smart_priority == best->smart_priority && robin > bestRobin))))
{
bestPrio = pClient->smart_priority;
best = pClient;
bestRobin = robin;
best = client;
}
#ifdef SMART_DEBUG
if ((now - SmartLastPrint) >= 5000)
......@@ -284,8 +293,7 @@ SmartScheduleClient (int *clientReady, int nready)
SmartLastPrint = now;
}
#endif
pClient = clients[best];
SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index;
SmartLastIndex[best->smart_priority - SMART_MIN_PRIORITY] = best->index;
/*
* Set current client pointer
*/
......@@ -314,7 +322,7 @@ SmartScheduleClient (int *clientReady, int nready)
{
SmartScheduleSlice = SmartScheduleInterval;
}
return best;
return best->index;
}
#ifndef NXAGENT_SERVER
......@@ -348,7 +356,7 @@ Dispatch(void)
nready = WaitForSomething(clientReady);
if (nready && !SmartScheduleDisable)
if (nready)
{
clientReady[0] = SmartScheduleClient (clientReady, nready);
nready = 1;
......@@ -383,8 +391,7 @@ Dispatch(void)
ProcessInputEvents();
FlushIfCriticalOutputPending();
}
if (!SmartScheduleDisable &&
(SmartScheduleTime - start_tick) >= SmartScheduleSlice)
if ((SmartScheduleTime - start_tick) >= SmartScheduleSlice)
{
/* Penalize clients which consume ticks */
if (client->smart_priority > SMART_MIN_PRIORITY)
......@@ -412,7 +419,10 @@ Dispatch(void)
result = BadLength;
else
result = (* client->requestVector[MAJOROP])(client);
if (!SmartScheduleSignalEnable)
SmartScheduleTime = GetTimeInMillis();
if (result != Success)
{
if (client->noClientException != Success)
......@@ -3551,6 +3561,9 @@ CloseDownClient(register ClientPtr client)
CallCallbacks((&ClientStateCallback), (void *)&clientinfo);
}
FreeClientResources(client);
/* Disable client ID tracking. This must be done after
* ClientStateCallback. */
ReleaseClientIds(client);
if (client->index < nextFreeClientID)
nextFreeClientID = client->index;
clients[client->index] = NullClient;
......@@ -3634,6 +3647,7 @@ void InitClient(ClientPtr client, int i, void * ospriv)
client->smart_start_tick = SmartScheduleTime;
client->smart_stop_tick = SmartScheduleTime;
client->smart_check_tick = SmartScheduleTime;
client->clientIds = NULL;
}
extern int clientPrivateLen;
......@@ -3715,6 +3729,11 @@ ClientPtr NextAvailableClient(void * ospriv)
currentMaxClients++;
while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
nextFreeClientID++;
/* Enable client ID tracking. This must be done before
* ClientStateCallback. */
ReserveClientIds(client);
if (ClientStateCallback)
{
NewClientInfoRec clientinfo;
......@@ -3733,12 +3752,14 @@ ProcInitialConnection(register ClientPtr client)
REQUEST(xReq);
register xConnClientPrefix *prefix;
int whichbyte = 1;
char order;
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
order = prefix->byteOrder;
if (order != 'l' && order != 'B' && order != 'r' && order != 'R')
return (client->noClientException = -1);
if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
(!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) ||
(!(*(char *) &whichbyte) && (order == 'l' || order == 'r')))
{
client->swapped = TRUE;
SwapConnClientPrefix(prefix);
......@@ -3750,6 +3771,10 @@ ProcInitialConnection(register ClientPtr client)
{
swaps(&stuff->length);
}
if (order == 'r' || order == 'R')
{
client->local = FALSE;
}
ResetCurrentRequest(client);
return (client->noClientException);
}
......
......@@ -149,6 +149,8 @@ int defaultColorVisualClass = -1;
int monitorResolution = 0;
char *display;
int displayfd = -1;
Bool explicit_display = FALSE;
CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
int argcGlobal;
......
......@@ -100,6 +100,7 @@ Equipment Corporation.
#include "site.h"
#include "dixfont.h"
#include "extnsionst.h"
#include "client.h"
#ifdef PANORAMIX
#include "panoramiXsrv.h"
#else
......@@ -382,6 +383,7 @@ main(int argc, char *argv[], char *envp[])
InitInput(argc, argv);
if (InitAndStartDevices() != Success)
FatalError("failed to initialize core devices");
ReserveClientIds(serverClient);
InitFonts();
if (loadableFonts) {
......@@ -430,6 +432,8 @@ main(int argc, char *argv[], char *envp[])
FatalError("could not create connection block info");
}
NotifyParentProcess();
Dispatch();
/* Now free up whatever must be freed */
......@@ -470,6 +474,7 @@ main(int argc, char *argv[], char *envp[])
#endif
FreeAuditTimer();
ReleaseClientIds(serverClient);
free(serverClient->devPrivates);
serverClient->devPrivates = NULL;
......
......@@ -669,7 +669,7 @@ static void nxagentDisplayBlockHandler(Display *display, int reason)
nxagentBlocking = 1;
if (SmartScheduleDisable == 1)
if (!SmartScheduleSignalEnable)
{
/*
......
......@@ -116,36 +116,29 @@ Bool nxagentReconnectDisplay(void *p0);
* Deal with the smart scheduler.
*/
#if HAVE_SETITIMER
#define nxagentInitTimer() \
\
SmartScheduleInit();
#define nxagentStopTimer() \
\
if (SmartScheduleTimerStopped == 0) \
{ \
SmartScheduleStopTimer(); \
} \
\
SmartScheduleIdle = 1;
SmartScheduleStopTimer(); \
#define nxagentStartTimer() \
\
if (SmartScheduleTimerStopped == 1) \
{ \
SmartScheduleStartTimer(); \
} \
\
SmartScheduleIdle = 0;
SmartScheduleStartTimer();
#define nxagentDisableTimer() \
\
if (SmartScheduleTimerStopped == 0) \
{ \
SmartScheduleStopTimer(); \
} \
\
SmartScheduleDisable = 1;
SmartScheduleStopTimer(); \
SmartScheduleSignalEnable = FALSE;
#else
#define nxagentInitTimer()
#define nxagentStopTimer()
#define nxagentStartTimer()
#define nxagentDisableTimer()
#endif /* HAVE_SETITIMER */
/*
* File descriptor currently used by
......
......@@ -597,7 +597,7 @@ void nxagentWakeupHandler(void * data, int count, void * mask)
nxagentHandleConnectionStates();
}
if (SmartScheduleDisable == 1)
if (!SmartScheduleSignalEnable)
{
#ifdef DEBUG
......@@ -885,7 +885,7 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask)
nxagentHandleConnectionStates();
}
if (SmartScheduleDisable == 1)
if (!SmartScheduleSignalEnable)
{
#ifdef DEBUG
......@@ -1075,7 +1075,7 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
#endif
}
if (SmartScheduleDisable == 1)
if (!SmartScheduleSignalEnable)
{
/*
......@@ -1150,7 +1150,7 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out)
* the inner dispatch loop forever.
*/
if (SmartScheduleDisable == 1)
if (!SmartScheduleSignalEnable)
{
if (client -> index != nxagentDispatch.client)
......
......@@ -387,7 +387,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
#endif
if (nready && !SmartScheduleDisable)
if (nready)
{
clientReady[0] = SmartScheduleClient (clientReady, nready);
nready = 1;
......@@ -422,8 +422,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
ProcessInputEvents();
FlushIfCriticalOutputPending();
}
if (!SmartScheduleDisable &&
(SmartScheduleTime - start_tick) >= SmartScheduleSlice)
if ((SmartScheduleTime - start_tick) >= SmartScheduleSlice)
{
/* Penalize clients which consume ticks */
if (client->smart_priority > SMART_MIN_PRIORITY)
......@@ -512,6 +511,10 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio
result = (* client->requestVector[MAJOROP])(client);
#endif
if (!SmartScheduleSignalEnable)
SmartScheduleTime = GetTimeInMillis();
if (result != Success)
{
if (client->noClientException != Success)
......
......@@ -178,6 +178,13 @@ different from the user's real uid.
.B \-core
causes the server to generate a core dump on fatal errors.
.TP 8
.B \-displayfd \fIfd\fP
specifies a file descriptor in the launching process. Rather than specify
a display number, the X server will attempt to listen on successively higher
display numbers, and upon finding a free one, will write the port number back
on this file descriptor as a newline-terminated string. The \-pn option is
ignored when using \-displayfd.
.TP 8
.B \-deferglyphs \fIwhichfonts\fP
specifies the types of fonts for which the server should attempt to use
deferred glyph loading. \fIwhichfonts\fP can be all (all fonts),
......@@ -295,10 +302,6 @@ required by the X protocol, which allows the server to exceed the
client's backing store expectations but does not provide a way to tell
the client that it is doing so.
.TP 8
.B \-x \fIextension\fP
loads the specified extension at init.
This is a no-op for most implementations.
.TP 8
.B [+-]xinerama
enables(+) or disables(-) XINERAMA provided via the PanoramiX extension. This is
set to off by default.
......
......@@ -16,6 +16,7 @@ depend::
InstallDriverSDKNonExecFile(XIstubs.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(bstore.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(bstorestr.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(client.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(colormap.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(colormapst.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(cursor.h,$(DRIVERSDKINCLUDEDIR))
......
/*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All
* rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/* Author: Rami Ylimäki <rami.ylimaki@vincit.fi> */
#ifndef CLIENT_H
#define CLIENT_H
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif /* HAVE_DIX_CONFIG_H */
#include <X11/Xfuncproto.h>
#include <sys/types.h>
/* Client IDs. Use GetClientPid, GetClientCmdName and GetClientCmdArgs
* instead of accessing the fields directly. */
typedef struct {
pid_t pid; /* process ID, -1 if not available */
const char *cmdname; /* process name, NULL if not available */
const char *cmdargs; /* process arguments, NULL if not available */
} ClientIdRec, *ClientIdPtr;
struct _Client;
/* Initialize and clean up. */
void ReserveClientIds(struct _Client *client);
void ReleaseClientIds(struct _Client *client);
/* Determine client IDs for caching. Exported on purpose for
* extensions such as SELinux. */
extern _X_EXPORT pid_t DetermineClientPid(struct _Client *client);
extern _X_EXPORT void DetermineClientCmd(pid_t, const char **cmdname,
const char **cmdargs);
/* Query cached client IDs. Exported on purpose for drivers. */
extern _X_EXPORT pid_t GetClientPid(struct _Client *client);
extern _X_EXPORT const char *GetClientCmdName(struct _Client *client);
extern _X_EXPORT const char *GetClientCmdArgs(struct _Client *client);
#endif /* CLIENT_H */
......@@ -24,6 +24,7 @@ SOFTWARE.
#ifndef DIXSTRUCT_H
#define DIXSTRUCT_H
#include "client.h"
#include "dix.h"
#include "resource.h"
#include "cursor.h"
......@@ -94,6 +95,7 @@ typedef struct _Client {
void *requestBuffer;
void *osPrivate; /* for OS layer, including scheduler */
Bool swapped;
Bool local;
ReplySwapPtr pSwapReplyFunc;
XID errorValue;
int sequence;
......@@ -141,6 +143,8 @@ typedef struct _Client {
long smart_start_tick;
long smart_stop_tick;
long smart_check_tick;
ClientIdPtr clientIds;
} ClientRec;
/*
......@@ -150,18 +154,19 @@ extern long SmartScheduleTime;
extern long SmartScheduleInterval;
extern long SmartScheduleSlice;
extern long SmartScheduleMaxSlice;
extern unsigned long SmartScheduleIdleCount;
extern Bool SmartScheduleDisable;
extern Bool SmartScheduleIdle;
extern Bool SmartScheduleTimerStopped;
extern Bool SmartScheduleStartTimer(void);
#ifdef NXAGENT_SERVER
extern Bool SmartScheduleStopTimer(void);
#ifdef HAVE_SETITIMER
#if HAVE_SETITIMER
extern Bool SmartScheduleSignalEnable;
#else
#define SmartScheduleSignalEnable FALSE
#endif
#endif
extern void SmartScheduleStartTimer(void);
extern void SmartScheduleStopTimer(void);
#define SMART_MAX_PRIORITY (20)
#define SMART_MIN_PRIORITY (-20)
extern Bool SmartScheduleInit(void);
extern void SmartScheduleInit(void);
/* This prototype is used pervasively in Xext, dix */
#define DISPATCH_PROC(func) int func(ClientPtr /* client */)
......
......@@ -52,6 +52,8 @@ extern int defaultScreenSaverAllowExposures;
extern int argcGlobal;
extern char **argvGlobal;
extern char *display;
extern int displayfd;
extern Bool explicit_display;
extern int defaultBackingStore;
extern Bool disableBackingStore;
......@@ -76,6 +78,6 @@ extern long maxBigRequestSize;
extern Bool blackRoot;
extern Bool CoreDump;
extern Bool NoListenAll;
#endif /* OPAQUE_H */
......@@ -120,6 +120,8 @@ extern void ResetOsBuffers(void);
extern void InitConnectionLimits(void);
extern void NotifyParentProcess(void);
extern void CreateWellKnownSockets(void);
extern void ResetWellKnownSockets(void);
......@@ -135,10 +137,6 @@ extern char *ClientAuthorized(
unsigned int /*string_n*/,
char* /*auth_string*/);
extern Bool EstablishNewConnections(
ClientPtr /*clientUnused*/,
void * /*closure*/);
extern void CheckConnections(void);
extern void CloseDownConnection(ClientPtr /*client*/);
......@@ -317,10 +315,26 @@ typedef struct sockaddr * sockaddrPtr;
extern int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
extern int LocalClient(ClientPtr /* client */);
extern int LocalClientCred(ClientPtr, int *, int *);
#define LCC_UID_SET (1 << 0)
#define LCC_GID_SET (1 << 1)
#define LCC_PID_SET (1 << 2)
#define LCC_ZID_SET (1 << 3)
typedef struct {
int fieldsSet; /* Bit mask of fields set */
int euid; /* Effective uid */
int egid; /* Primary effective group id */
int nSuppGids; /* Number of supplementary group ids */
int *pSuppGids; /* Array of supplementary group ids */
int pid; /* Process id */
int zoneid; /* Only set on Solaris 10 & later */
} LocalClientCredRec;
extern int GetLocalClientCreds(ClientPtr, LocalClientCredRec **);
extern void FreeLocalClientCreds(LocalClientCredRec *);
extern int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
extern int GetAccessControl(void);
......@@ -506,6 +520,7 @@ typedef enum {
#endif
extern const char *LogInit(const char *fname, const char *backup);
extern void LogSetDisplay(void);
extern void LogClose(void);
extern Bool LogSetParameter(LogParameter param, int value);
extern void LogVWrite(int verb, const char *f, va_list args);
......
......@@ -25,25 +25,31 @@
#include <Server.tmpl>
NULL =
/*
* If you have any extra files to be put into the library, define them here.
*/
ZONEID_DEFINES = -UHAVE_GETZONEID
#if NXLibraries
NX_INCLUDES = -I../../../../nxcomp
NX_DEFINES = -DNX_TRANS_SOCKET \
-DNX_TRANS_AUTH \
-DNX_TRANS_FOPEN \
-DNX_TRANS_SLEEP \
-DNX_TRANS_EXIT \
-DNX_TRANS_WAKEUP=1000
NX_DEFINES = -DNX_TRANS_SOCKET \
-DNX_TRANS_AUTH \
-DNX_TRANS_FOPEN \
-DNX_TRANS_SLEEP \
-DNX_TRANS_EXIT \
-DNX_TRANS_WAKEUP=1000 \
-DNXAGENT_SERVER \
$(NULL)
# -DNX_TRANS_WARN \
# -DNX_TRANS_INFO \
# -DNX_TRANS_TEST \
# -DNX_TRANS_DEBUG \
# -DNX_TRANS_WARN \
# -DNX_TRANS_INFO \
# -DNX_TRANS_TEST \
# -DNX_TRANS_DEBUG \
#endif
......@@ -121,16 +127,53 @@ TMEMCMP_OBJS = timingsafe_memcmp.o
#endif
BOOTSTRAPCFLAGS =
SRCS = WaitFor.c access.c connection.c io.c $(COLOR_SRCS) \
osinit.c utils.c log.c auth.c mitauth.c secauth.c \
$(XDMAUTHSRCS) $(RPCSRCS) xdmcp.c OtherSources \
xstrans.c $(SNPRINTF_SRCS) $(STRLCAT_SRCS) \
$(REALLOCARRAY_SRCS) xprintf.c $(TMEMCMP_SRCS)
OBJS = WaitFor.o access.o connection.o io.o $(COLOR_OBJS) \
osinit.o utils.o log.o auth.o mitauth.o secauth.o \
$(XDMAUTHOBJS) $(RPCOBJS) xdmcp.o OtherObjects \
xstrans.o $(SNPRINTF_OBJS) $(STRLCAT_OBJS) \
$(REALLOCARRAY_OBJS) xprintf.o $(TMEMCMP_OBJS)
SRCS = WaitFor.c \
access.c \
client.c \
connection.c \
io.c \
$(COLOR_SRCS) \
osinit.c \
utils.c \
log.c \
auth.c \
mitauth.c \
secauth.c \
$(XDMAUTHSRCS) \
$(RPCSRCS) \
xdmcp.c \
OtherSources \
xstrans.c \
$(SNPRINTF_SRCS) \
$(STRLCAT_SRCS) \
$(REALLOCARRAY_SRCS) \
xprintf.c \
$(TMEMCMP_SRCS) \
$(NULL)
OBJS = WaitFor.o \
access.o \
client.o \
connection.o \
io.o \
$(COLOR_OBJS) \
osinit.o \
utils.o \
log.o \
auth.o \
mitauth.o \
secauth.o \
$(XDMAUTHOBJS) \
$(RPCOBJS) \
xdmcp.o \
OtherObjects \
xstrans.o \
$(SNPRINTF_OBJS) \
$(STRLCAT_OBJS) \
$(REALLOCARRAY_OBJS) \
xprintf.o \
$(TMEMCMP_OBJS) \
$(NULL)
#if UseMemLeak
MEM_DEFINES = -DMEMBUG
......@@ -143,18 +186,39 @@ BOOTSTRAPCFLAGS =
#endif
XTRANS_DEFINES = -DXTRANS_SEND_FDS=0
DEFINES = $(CONNECTION_FLAGS) $(MEM_DEFINES) \
$(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(OS_DEFINES) \
$(GETPEER_DEFINES) \
$(RANDOM_DEFINES) $(BUGMSG) $(XTRANS_FAILDEFINES) \
$(XTRANS_DEFINES) $(NX_DEFINES)
INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
-I$(SERVERSRC)/Xext -I$(SERVERSRC)/render \
-I$(TOP)/lib/Xau $(NX_INCLUDES) \
`pkg-config --cflags-only-I pixman-1`
DEPEND_DEFINES = $(XDMCP_DEFINES) $(EXT_DEFINES) \
$(TRANS_INCLUDES) $(CONNECTION_FLAGS) $(GETPEER_DEFINES) \
DependDefines
DEFINES = $(CONNECTION_FLAGS) \
$(MEM_DEFINES) \
$(XDMAUTHDEFS) \
$(RPCDEFS) \
$(SIGNAL_DEFINES) \
$(OS_DEFINES) \
$(GETPEER_DEFINES) \
$(RANDOM_DEFINES) \
$(BUGMSG) \
$(XTRANS_FAILDEFINES) \
$(XTRANS_DEFINES) \
$(NX_DEFINES) \
$(NULL)
INCLUDES = -I. \
-I../include \
-I$(XINCLUDESRC) \
-I$(EXTINCSRC) \
-I$(SERVERSRC)/Xext \
-I$(SERVERSRC)/render \
-I$(TOP)/lib/Xau \
$(NX_INCLUDES) \
`pkg-config --cflags-only-I pixman-1` \
$(NULL)
DEPEND_DEFINES = $(XDMCP_DEFINES) \
$(EXT_DEFINES) \
$(TRANS_INCLUDES) \
$(CONNECTION_FLAGS) \
$(GETPEER_DEFINES) \
DependDefines \
$(NULL)
LINTLIBS = ../dix/llib-ldix.ln
#ifdef NEED_ALLOCA_FROM_LIBPW
......@@ -176,7 +240,7 @@ alloca.o: $(PWLIB)
ar x $(PWLIB) alloca.o
#endif /* NEED_ALLOCA_FROM_LIBPW */
SpecialCObjectRule(access,$(ICONFIGFILES),$(XDMCP_DEFINES) $(SOCK_DEFINES) $(IFADDRS_DEFINES))
SpecialCObjectRule(access,$(ICONFIGFILES),$(XDMCP_DEFINES) $(SOCK_DEFINES) $(IFADDRS_DEFINES) $(ZONEID_DEFINES))
SpecialCObjectRule(auth,$(ICONFIGFILES),$(XDMCP_DEFINES))
SpecialCObjectRule(xdmauth,$(ICONFIGFILES),$(XDMCP_DEFINES))
SpecialCObjectRule(xdmcp,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
......
......@@ -213,18 +213,10 @@ WaitForSomething(int *pClientsReady)
ProcessWorkQueue();
if (XFD_ANYSET (&ClientsWithInput))
{
if (!SmartScheduleDisable)
{
someReady = TRUE;
waittime.tv_sec = 0;
waittime.tv_usec = 0;
wt = &waittime;
}
else
{
XFD_COPYSET (&ClientsWithInput, &clientsReadable);
break;
}
someReady = TRUE;
waittime.tv_sec = 0;
waittime.tv_usec = 0;
wt = &waittime;
}
if (someReady)
{
......@@ -247,7 +239,8 @@ WaitForSomething(int *pClientsReady)
}
XFD_COPYSET(&AllSockets, &LastSelectMask);
}
SmartScheduleIdle = TRUE;
SmartScheduleStopTimer ();
BlockHandler((void *)&wt, (void *)&LastSelectMask);
if (NewOutputPending)
FlushAllOutput();
......@@ -387,13 +380,8 @@ WaitForSomething(int *pClientsReady)
i = XTestProcessInputAction (i, &waittime);
}
#endif /* XTESTEXT1 */
if (i >= 0)
{
SmartScheduleIdle = FALSE;
SmartScheduleIdleCount = 0;
if (SmartScheduleTimerStopped)
(void) SmartScheduleStartTimer ();
}
SmartScheduleStartTimer ();
if (i <= 0) /* An error or timeout occurred */
{
#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
......@@ -507,10 +495,6 @@ WaitForSomething(int *pClientsReady)
}
XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
if (XFD_ANYSET(&tmp_set))
QueueWorkProc(EstablishNewConnections, NULL,
(void *)&LastSelectMask);
XFD_ANDSET(&tmp_set, &LastSelectMask, &NotifyReadFds);
if (XFD_ANYSET(&tmp_set) || someNotifyWriteReady)
......@@ -544,17 +528,14 @@ WaitForSomething(int *pClientsReady)
#ifndef WIN32
for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
{
int highest_priority = 0;
while (clientsReadable.fds_bits[i])
{
int client_priority, client_index;
int client_index;
curclient = ffs (clientsReadable.fds_bits[i]) - 1;
client_index = /* raphael: modified */
ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
#else
int highest_priority = 0;
fd_set savedClientsReadable;
XFD_COPYSET(&clientsReadable, &savedClientsReadable);
for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++)
......@@ -564,40 +545,10 @@ WaitForSomething(int *pClientsReady)
curclient = XFD_FD(&savedClientsReadable, i);
client_index = GetConnectionTranslation(curclient);
#endif
#ifdef XSYNC
/* We implement "strict" priorities.
* Only the highest priority client is returned to
* dix. If multiple clients at the same priority are
* ready, they are all returned. This means that an
* aggressive client could take over the server.
* This was not considered a big problem because
* aggressive clients can hose the server in so many
* other ways :)
*/
client_priority = clients[client_index]->priority;
if (nready == 0 || client_priority > highest_priority)
{
/* Either we found the first client, or we found
* a client whose priority is greater than all others
* that have been found so far. Either way, we want
* to initialize the list of clients to contain just
* this client.
*/
pClientsReady[0] = client_index;
highest_priority = client_priority;
nready = 1;
}
/* the following if makes sure that multiple same-priority
* clients get batched together
*/
else if (client_priority == highest_priority)
#endif
{
pClientsReady[nready++] = client_index;
}
pClientsReady[nready++] = client_index;
#ifndef WIN32
clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
}
clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
}
#else
FD_CLR(curclient, &clientsReadable);
#endif
......
......@@ -252,7 +252,14 @@ ReadRequestFromClient(ClientPtr client)
move_header = FALSE;
#endif
gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
if (gotnow < sizeof(xReq))
if (oci->ignoreBytes > 0) {
if (oci->ignoreBytes > oci->size)
needed = oci->size;
else
needed = oci->ignoreBytes;
}
else if (gotnow < sizeof(xReq))
{
/* We don't have an entire xReq yet. Can't tell how big
* the request will be until we get the whole xReq.
......@@ -297,8 +304,13 @@ ReadRequestFromClient(ClientPtr client)
if (needed > MAXBUFSIZE)
{
/* request is too big for us to handle */
YieldControlDeath();
return -1;
/*
* Mark the rest of it as needing to be ignored, and then return
* the full size. Dispatch() will turn it into a BadLength error.
*/
oci->ignoreBytes = needed - gotnow;
oci->lenLastReq = gotnow;
return needed;
}
if ((gotnow == 0) ||
((oci->bufptr - oci->buffer + needed) > oci->size))
......@@ -405,6 +417,29 @@ ReadRequestFromClient(ClientPtr client)
#endif
needed = sizeof(xReq);
}
/* If there are bytes to ignore, ignore them now. */
if (oci->ignoreBytes > 0) {
assert(needed == oci->ignoreBytes || needed == oci->size);
oci->ignoreBytes -= gotnow;
needed = gotnow = 0;
/*
* The _XSERVTransRead call above may return more or fewer bytes than we
* want to ignore. Ignore the smaller of the two sizes.
*/
if (gotnow < needed) {
oci->ignoreBytes -= gotnow;
oci->bufptr += gotnow;
gotnow = 0;
} else {
oci->ignoreBytes -= needed;
oci->bufptr += needed;
gotnow -= needed;
}
needed = 0;
}
oci->lenLastReq = needed;
/*
......@@ -430,24 +465,15 @@ ReadRequestFromClient(ClientPtr client)
FD_SET(fd, &ClientsWithInput);
else
{
if (!SmartScheduleDisable)
FD_CLR(fd, &ClientsWithInput);
else
YieldControlNoInput();
FD_CLR(fd, &ClientsWithInput);
}
}
else
{
if (!gotnow)
AvailableInput = oc;
if (!SmartScheduleDisable)
FD_CLR(fd, &ClientsWithInput);
else
YieldControlNoInput();
FD_CLR(fd, &ClientsWithInput);
}
if (SmartScheduleDisable)
if (++timesThisConnection >= MAX_TIMES_PER)
YieldControl();
#ifdef BIGREQS
if (move_header)
{
......@@ -755,9 +781,6 @@ FlushAllOutput(void)
fd_set newOutputPending;
#endif
if (FlushCallback)
CallCallbacks(&FlushCallback, NULL);
if (!newoutput)
return;
......@@ -958,7 +981,7 @@ WriteToClient (ClientPtr who, int count, const void *__buf)
}
}
#endif
if (oco->count + count + padBytes > oco->size)
if (oco->count == 0 || oco->count + count + padBytes > oco->size)
{
FD_CLR(oc->fd, &OutputPending);
if(!XFD_ANYSET(&OutputPending)) {
......@@ -971,7 +994,11 @@ WriteToClient (ClientPtr who, int count, const void *__buf)
NewOutputPending = TRUE;
FD_SET(oc->fd, &OutputPending);
memmove((char *)oco->buf + oco->count, buf, count);
oco->count += count + padBytes;
oco->count += count;
if (padBytes) {
memset(oco->buf + oco->count, '\0', padBytes);
oco->count += padBytes;
}
return(count);
}
......@@ -1004,6 +1031,13 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
written = 0;
padsize = padlength[extraCount & 3];
notWritten = oco->count + extraCount + padsize;
if (!notWritten)
return 0;
if (FlushCallback)
CallCallbacks(&FlushCallback, who);
todo = notWritten;
while (notWritten) {
long before = written; /* amount of whole thing written */
......@@ -1083,10 +1117,11 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
if (notWritten > oco->size)
{
unsigned char *obuf;
unsigned char *obuf = NULL;
obuf = (unsigned char *)realloc(oco->buf,
notWritten + BUFSIZE);
if (notWritten + BUFSIZE <= INT_MAX) {
obuf = realloc(oco->buf, notWritten + BUFSIZE);
}
if (!obuf)
{
_XSERVTransDisconnect(oc->trans_conn);
......@@ -1173,6 +1208,7 @@ AllocateInputBuffer(void)
oci->bufptr = oci->buffer;
oci->bufcnt = 0;
oci->lenLastReq = 0;
oci->ignoreBytes = 0;
return oci;
}
......@@ -1217,6 +1253,7 @@ FreeOsBuffers(OsCommPtr oc)
oci->bufptr = oci->buffer;
oci->bufcnt = 0;
oci->lenLastReq = 0;
oci->ignoreBytes = 0;
}
}
if ((oco = oc->output))
......
......@@ -179,48 +179,87 @@ static Bool needBuffer = TRUE;
#endif
/*
* LogFilePrep is called to setup files for logging, including getting
* an old file out of the way, but it doesn't actually open the file,
* since it may be used for renaming a file we're already logging to.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static char *
LogFilePrep(const char *fname, const char *backup, const char *idstring)
{
char *logFileName = NULL;
if (asprintf(&logFileName, fname, idstring) == -1)
FatalError("Cannot allocate space for the log file name\n");
if (backup && *backup) {
struct stat buf;
if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
char *suffix;
char *oldLog;
if ((asprintf(&suffix, backup, idstring) == -1) ||
(asprintf(&oldLog, "%s%s", logFileName, suffix) == -1)) {
FatalError("Cannot allocate space for the log file name\n");
}
free(suffix);
if (rename(logFileName, oldLog) == -1) {
FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
logFileName, oldLog);
}
free(oldLog);
}
}
else {
if (remove(logFileName) != 0) {
FatalError("Cannot remove old log file \"%s\": %s\n",
logFileName, strerror(errno));
}
}
return logFileName;
}
#pragma GCC diagnostic pop
/*
* LogInit is called to start logging to a file. It is also called (with
* NULL arguments) when logging to a file is not wanted. It must always be
* called, otherwise log messages will continue to accumulate in a buffer.
*
* %s, if present in the fname or backup strings, is expanded to the display
* string.
* string (or to a string containing the pid if the display is not yet set).
*/
static char *saved_log_fname;
static char *saved_log_backup;
static char *saved_log_tempname;
const char *
LogInit(const char *fname, const char *backup)
{
char *logFileName = NULL;
if (fname && *fname) {
/* malloc() can't be used yet. */
logFileName = malloc(strlen(fname) + strlen(display) + 1);
if (!logFileName)
FatalError("Cannot allocate space for the log file name\n");
sprintf(logFileName, fname, display);
if (backup && *backup) {
struct stat buf;
if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
char *suffix;
char *oldLog;
oldLog = malloc(strlen(logFileName) + strlen(backup) +
strlen(display) + 1);
suffix = malloc(strlen(backup) + strlen(display) + 1);
if (!oldLog || !suffix)
FatalError("Cannot allocate space for the log file name\n");
sprintf(suffix, backup, display);
sprintf(oldLog, "%s%s", logFileName, suffix);
free(suffix);
if (rename(logFileName, oldLog) == -1) {
FatalError("Cannot move old log file (\"%s\" to \"%s\"\n",
logFileName, oldLog);
}
free(oldLog);
}
}
if (displayfd != -1) {
/* Display isn't set yet, so we can't use it in filenames yet. */
char pidstring[32];
snprintf(pidstring, sizeof(pidstring), "pid-%ld",
(unsigned long) getpid());
logFileName = LogFilePrep(fname, backup, pidstring);
saved_log_tempname = logFileName;
/* Save the patterns for use when the display is named. */
saved_log_fname = strdup(fname);
if (backup == NULL)
saved_log_backup = NULL;
else
saved_log_backup = strdup(backup);
} else
logFileName = LogFilePrep(fname, backup, display);
if ((logFile = fopen(logFileName, "w")) == NULL)
FatalError("Cannot open log file \"%s\"\n", logFileName);
setvbuf(logFile, NULL, _IONBF, 0);
......@@ -250,6 +289,36 @@ LogInit(const char *fname, const char *backup)
}
void
LogSetDisplay(void)
{
if (saved_log_fname) {
char *logFileName;
logFileName = LogFilePrep(saved_log_fname, saved_log_backup, display);
if (rename(saved_log_tempname, logFileName) == 0) {
LogMessageVerb(X_PROBED, 0,
"Log file renamed from \"%s\" to \"%s\"\n",
saved_log_tempname, logFileName);
if (strlen(saved_log_tempname) >= strlen(logFileName))
strncpy(saved_log_tempname, logFileName,
strlen(saved_log_tempname));
}
else {
ErrorF("Failed to rename log file \"%s\" to \"%s\": %s\n",
saved_log_tempname, logFileName, strerror(errno));
}
/* free newly allocated string - can't free old one since existing
pointers to it may exist in DDX callers. */
free(logFileName);
free(saved_log_fname);
free(saved_log_backup);
}
}
void
LogClose()
{
if (logFile) {
......
......@@ -52,7 +52,6 @@ SOFTWARE.
#ifndef _OSDEP_H_
#define _OSDEP_H_ 1
#define BOTIMEOUT 200 /* in milliseconds */
#define BUFSIZE 4096
#define BUFWATERMARK 8192
#ifndef MAXBUFSIZE
......@@ -129,6 +128,7 @@ typedef struct _connectionInput {
int bufcnt; /* count of bytes in buffer */
int lenLastReq;
int size;
unsigned int ignoreBytes; /* bytes to ignore before the next request */
} ConnectionInput, *ConnectionInputPtr;
typedef struct _connectionOutput {
......@@ -238,6 +238,9 @@ typedef long int fd_mask;
#define ffs mffs
extern int mffs(fd_mask);
/* in access.c */
extern Bool ComputeLocalClient(ClientPtr client);
/* in auth.c */
extern void GenerateRandomData (int len, char *buf);
......
......@@ -217,9 +217,8 @@ OsInit(void)
* log file name if logging to a file is desired.
*/
LogInit(NULL, NULL);
if (!SmartScheduleDisable)
if (!SmartScheduleInit ())
SmartScheduleDisable = TRUE;
SmartScheduleInit();
OsInitAllocator();
}
......
......@@ -290,7 +290,8 @@ OsSignal(sig, handler)
sigaddset(&act.sa_mask, sig);
act.sa_flags = 0;
act.sa_handler = handler;
sigaction(sig, &act, &oact);
if (sigaction(sig, &act, &oact))
perror("sigaction");
return oact.sa_handler;
#endif
}
......@@ -337,7 +338,7 @@ LockServer(void)
int len;
char port[20];
if (nolock) return;
if (nolock || NoListenAll) return;
/*
* Path names
*/
......@@ -463,7 +464,7 @@ LockServer(void)
void
UnlockServer(void)
{
if (nolock) return;
if (nolock || NoListenAll) return;
if (!StillLocking){
......@@ -621,7 +622,6 @@ void UseMsg(void)
ErrorF("v video blanking for screen-saver\n");
ErrorF("-v screen-saver without video blanking\n");
ErrorF("-wm WhenMapped default backing-store\n");
ErrorF("-x string loads named extension at init time \n");
ErrorF("-maxbigreqsize set maximal bigrequest size \n");
#ifdef PANORAMIX
ErrorF("+xinerama Enable XINERAMA (PanoramiX) extension\n");
......@@ -703,6 +703,7 @@ ProcessCommandLine(int argc, char *argv[])
{
/* initialize display */
display = argv[i];
explicit_display = TRUE;
display++;
if( ! VerifyDisplayName( display ) ) {
ErrorF("Bad display name: %s\n", display);
......@@ -779,6 +780,15 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
else if (strcmp(argv[i], "-displayfd") == 0) {
if (++i < argc) {
displayfd = atoi(argv[i]);
nolock = TRUE;
}
else
UseMsg();
}
#ifdef DPMSExtension
else if ( strcmp( argv[i], "dpms") == 0)
DPMSEnabledSwitch = TRUE;
......@@ -891,6 +901,11 @@ ProcessCommandLine(int argc, char *argv[])
else if ( strcmp( argv[i], "-nolisten") == 0)
{
if(++i < argc) {
#ifdef NXAGENT_SERVER
if (strcmp( argv[i], "ANY" ) == 0)
NoListenAll = TRUE;
else
#endif /* NXAGENT_SERVER */
if (_XSERVTransNoListen(argv[i]))
FatalError ("Failed to disable listen for %s transport",
argv[i]);
......@@ -996,14 +1011,6 @@ ProcessCommandLine(int argc, char *argv[])
noRRXineramaExtension = TRUE;
}
#endif
else if ( strcmp( argv[i], "-x") == 0)
{
if(++i >= argc)
UseMsg();
/* For U**x, which doesn't support dynamic loading, there's nothing
* to do when we see a -x. Either the extension is linked in or
* it isn't */
}
else if ( strcmp( argv[i], "-I") == 0)
{
/* ignore all remaining arguments */
......@@ -1026,10 +1033,12 @@ ProcessCommandLine(int argc, char *argv[])
i = skip - 1;
}
#endif
#if HAVE_SETITIMER
else if ( strcmp( argv[i], "-dumbSched") == 0)
{
SmartScheduleDisable = TRUE;
SmartScheduleSignalEnable = FALSE;
}
#endif
else if ( strcmp( argv[i], "-schedInterval") == 0)
{
if (++i < argc)
......@@ -1353,30 +1362,15 @@ XNFstrdup(const char *s)
return ret;
}
unsigned long SmartScheduleIdleCount;
Bool SmartScheduleIdle;
Bool SmartScheduleTimerStopped;
#ifdef SIGVTALRM
#define SMART_SCHEDULE_POSSIBLE
#endif
#ifdef SMART_SCHEDULE_POSSIBLE
#define SMART_SCHEDULE_SIGNAL SIGALRM
#define SMART_SCHEDULE_TIMER ITIMER_REAL
#endif
#ifdef NX_TRANS_SOCKET
void
SmartScheduleStopTimer (void)
#else
static void
SmartScheduleStopTimer (void)
#endif
{
#ifdef SMART_SCHEDULE_POSSIBLE
#if HAVE_SETITIMER
struct itimerval timer;
if (!SmartScheduleSignalEnable)
return;
#ifdef NX_TRANS_TEST
fprintf(stderr, "SmartScheduleStopTimer: Stopping timer.\n");
#endif
......@@ -1386,96 +1380,101 @@ SmartScheduleStopTimer (void)
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 0;
(void) setitimer (ITIMER_REAL, &timer, 0);
SmartScheduleTimerStopped = TRUE;
#endif
}
Bool
void
SmartScheduleStartTimer (void)
{
#ifdef SMART_SCHEDULE_POSSIBLE
#if HAVE_SETITIMER
struct itimerval timer;
#ifdef NX_TRANS_SOCKET
if (SmartScheduleDisable)
{
return FALSE;
}
#endif
if (!SmartScheduleSignalEnable)
return;
#ifdef NX_TRANS_TEST
fprintf(stderr, "SmartScheduleStartTimer: Starting timer with [%ld] ms.\n",
SmartScheduleInterval);
#endif
SmartScheduleTimerStopped = FALSE;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = SmartScheduleInterval * 1000;
return setitimer (ITIMER_REAL, &timer, 0) >= 0;
setitimer (ITIMER_REAL, &timer, 0);
#endif
return FALSE;
}
#ifdef SMART_SCHEDULE_POSSIBLE
#if HAVE_SETITIMER
static void
SmartScheduleTimer (int sig)
{
int olderrno = errno;
SmartScheduleTime += SmartScheduleInterval;
#ifdef NX_TRANS_TEST
fprintf(stderr, "SmartScheduleTimer: Got timer with time [%ld] ms.\n",
SmartScheduleTime);
#endif
if (SmartScheduleIdle)
{
SmartScheduleStopTimer ();
}
errno = olderrno;
}
#endif
Bool
SmartScheduleInit (void)
int
SmartScheduleEnable (void)
{
#ifdef SMART_SCHEDULE_POSSIBLE
int ret = 0;
struct sigaction act;
if (SmartScheduleDisable)
return TRUE;
if (!SmartScheduleSignalEnable)
return 0;
#ifdef NX_TRANS_TEST
fprintf(stderr, "SmartScheduleInit: Initializing the smart scheduler.\n");
fprintf(stderr, "SmartScheduleEnable: Enabling the smart scheduler.\n");
#endif
bzero ((char *) &act, sizeof(struct sigaction));
memset((char *) &act, 0, sizeof(struct sigaction));
/* Set up the timer signal function */
act.sa_flags = SA_RESTART;
act.sa_handler = SmartScheduleTimer;
sigemptyset (&act.sa_mask);
sigaddset (&act.sa_mask, SMART_SCHEDULE_SIGNAL);
if (sigaction (SMART_SCHEDULE_SIGNAL, &act, 0) < 0)
{
perror ("sigaction for smart scheduler");
return FALSE;
}
/* Set up the virtual timer */
if (!SmartScheduleStartTimer ())
{
perror ("scheduling timer");
return FALSE;
sigaddset (&act.sa_mask, SIGALRM);
ret = sigaction(SIGALRM, &act, 0);
return ret;
}
static int
SmartSchedulePause(void)
{
int ret = 0;
struct sigaction act;
if (!SmartScheduleSignalEnable)
return 0;
#ifdef NX_TRANS_TEST
fprintf(stderr, "SmartSchedulePause: Pausing the smart scheduler.\n");
#endif
memset((char *) &act, 0, sizeof(struct sigaction));
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
ret = sigaction(SIGALRM, &act, 0);
return ret;
}
#endif
void
SmartScheduleInit(void)
{
#if HAVE_SETITIMER
#ifdef NX_TRANS_TEST
fprintf(stderr, "SmartScheduleInit: Initializing the smart scheduler.\n");
#endif
if (SmartScheduleEnable() < 0) {
perror("sigaction for smart scheduler");
SmartScheduleSignalEnable = FALSE;
}
/* stop the timer and wait for WaitForSomething to start it */
SmartScheduleStopTimer ();
return TRUE;
#else
return FALSE;
#endif
}
......@@ -1558,7 +1557,11 @@ System(char *command)
return(1);
#ifdef SIGCHLD
csig = signal(SIGCHLD, SIG_DFL);
csig = OsSignal(SIGCHLD, SIG_DFL);
if (csig == SIG_ERR) {
perror("signal");
return -1;
}
#endif
#ifdef DEBUG
......@@ -1596,7 +1599,10 @@ System(char *command)
#endif
#ifdef SIGCHLD
signal(SIGCHLD, csig);
if (OsSignal(SIGCHLD, csig) == SIG_ERR) {
perror("signal");
return -1;
}
#endif
return p == -1 ? -1 : status;
......@@ -1629,6 +1635,17 @@ Popen(char *command, char *type)
return NULL;
}
/* Ignore the smart scheduler while this is going on */
#if HAVE_SETITIMER
if (SmartSchedulePause() < 0) {
close(pdes[0]);
close(pdes[1]);
free(cur);
perror("signal");
return NULL;
}
#endif
#ifdef NX_TRANS_EXIT
if (OsVendorStartRedirectErrorFProc != NULL) {
OsVendorStartRedirectErrorFProc();
......@@ -1640,6 +1657,10 @@ Popen(char *command, char *type)
close(pdes[0]);
close(pdes[1]);
free(cur);
#if HAVE_SETITIMER
if (SmartScheduleEnable() < 0)
perror("signal");
#endif
#ifdef NX_TRANS_EXIT
if (OsVendorEndRedirectErrorFProc != NULL) {
OsVendorEndRedirectErrorFProc();
......@@ -1714,6 +1735,13 @@ Popen(char *command, char *type)
OsReleaseSignals ();
#endif
#if HAVE_SETITIMER
if (SmartScheduleEnable() < 0) {
perror("signal");
return NULL;
}
#endif
execl("/bin/sh", "sh", "-c", command, (char *)NULL);
_exit(127);
}
......
......@@ -205,8 +205,6 @@ extern void XdmcpDeadSession(char * /*reason*/);
static void timeout(void);
static void restart(void);
static void XdmcpBlockHandler(
void * /*data*/,
struct timeval ** /*wt*/,
......@@ -959,14 +957,6 @@ timeout(void)
send_packet();
}
static void
restart(void)
{
state = XDM_INIT_STATE;
timeOutRtx = 0;
send_packet();
}
int
XdmcpCheckAuthentication (
ARRAY8Ptr Name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment