diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:22 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:22 +0000 |
commit | 6c29c43354706a933c0bc73a9c800bdfd1a9a827 (patch) | |
tree | 37ab6c9430469a3d73ea08c12cfeda668dcb1a34 /server.c | |
parent | fa5d4a38a4dae7f24cdf3b8650dd931294c0fdc6 (diff) |
XFree86 4.3.0.1xf86-4_3_0_1PRE_xf86-4_3_0_1
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 103 |
1 files changed, 49 insertions, 54 deletions
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/xdm/server.c,v 3.13 2001/12/14 20:01:23 dawes Exp $ */ /* * xdm - display manager daemon @@ -35,6 +36,9 @@ from The Open Group. */ # include "dm.h" +# include "dm_error.h" +# include "dm_socket.h" + # include <X11/Xlib.h> # include <X11/Xos.h> # include <stdio.h> @@ -42,42 +46,38 @@ from The Open Group. # include <errno.h> # include <sys/socket.h> -static receivedUsr1; - -#ifdef X_NOT_STDC_ENV -extern int errno; -#endif +static int receivedUsr1; -static serverPause (); +static int serverPause (unsigned t, int serverPid); static Display *dpy; /* ARGSUSED */ static SIGVAL -CatchUsr1 (n) - int n; +CatchUsr1 (int n) { + int olderrno = errno; + #ifdef SIGNALS_RESET_WHEN_CAUGHT (void) Signal (SIGUSR1, CatchUsr1); #endif Debug ("display manager caught SIGUSR1\n"); ++receivedUsr1; + errno = olderrno; } -char *_SysErrorMsg (n) - int n; +char *_SysErrorMsg (int n) { char *s = strerror(n); return (s ? s : "unknown error"); } -StartServerOnce (d) -struct display *d; +static int +StartServerOnce (struct display *d) { char **f; char **argv; char arg[1024]; - char **parseArgs (); int pid; Debug ("StartServer for %s\n", d->name); @@ -87,6 +87,10 @@ struct display *d; switch (pid = fork ()) { case 0: CleanUpChild (); +#ifdef XDMCP + /* The chooser socket is not closed by CleanUpChild() */ + DestroyWellKnownSockets(); +#endif if (d->authFile) { sprintf (arg, "-auth %s", d->authFile); argv = parseArgs (argv, arg); @@ -123,8 +127,8 @@ struct display *d; return TRUE; } -StartServer (d) -struct display *d; +int +StartServer (struct display *d) { int i; int ret = FALSE; @@ -150,26 +154,22 @@ static int serverPauseRet; /* ARGSUSED */ static SIGVAL -serverPauseAbort (n) - int n; +serverPauseAbort (int n) { Longjmp (pauseAbort, 1); } /* ARGSUSED */ static SIGVAL -serverPauseUsr1 (n) - int n; +serverPauseUsr1 (int n) { Debug ("display manager paused til SIGUSR1\n"); ++receivedUsr1; Longjmp (pauseAbort, 1); } -static -serverPause (t, serverPid) -unsigned t; -int serverPid; +static int +serverPause (unsigned t, int serverPid) { int pid; @@ -203,7 +203,7 @@ int serverPid; #endif /* X_NOT_POSIX */ #endif /* SYSV */ if (pid == serverPid || - pid == -1 && errno == ECHILD) + (pid == -1 && errno == ECHILD)) { Debug ("Server dead\n"); serverPauseRet = 1; @@ -240,8 +240,7 @@ static Jmp_buf openAbort; /* ARGSUSED */ static SIGVAL -abortOpen (n) - int n; +abortOpen (int n) { Longjmp (openAbort, 1); } @@ -252,10 +251,8 @@ abortOpen (n) #include <tiuser.h> #endif -static -GetRemoteAddress (d, fd) - struct display *d; - int fd; +static void +GetRemoteAddress (struct display *d, int fd) { char buf[512]; int len = sizeof (buf); @@ -272,7 +269,7 @@ GetRemoteAddress (d, fd) len = 8; /* lucky for us, t_getname returns something that looks like a sockaddr */ #else - getpeername (fd, (struct sockaddr *) buf, &len); + getpeername (fd, (struct sockaddr *) buf, (void *)&len); #endif d->peerlen = 0; if (len) @@ -290,18 +287,18 @@ GetRemoteAddress (d, fd) #endif /* XDMCP */ static int -openErrorHandler (dpy) - Display *dpy; +openErrorHandler (Display *dpy) { LogError ("IO Error in XOpenDisplay\n"); exit (OPENFAILED_DISPLAY); + /*NOTREACHED*/ + return(0); } int -WaitForServer (d) - struct display *d; +WaitForServer (struct display *d) { - int i; + static int i; for (i = 0; i < (d->openRepeat > 0 ? d->openRepeat : 1); i++) { (void) Signal (SIGALRM, abortOpen); @@ -324,7 +321,7 @@ WaitForServer (d) #endif (void) alarm ((unsigned) 0); (void) Signal (SIGALRM, SIG_DFL); - (void) XSetIOErrorHandler ((int (*)()) 0); + (void) XSetIOErrorHandler ((int (*)(Display *)) 0); Debug ("After XOpenDisplay(%s)\n", d->name); if (dpy) { #ifdef XDMCP @@ -336,7 +333,7 @@ WaitForServer (d) return 1; } else { Debug ("OpenDisplay failed %d (%s) on \"%s\"\n", - errno, _SysErrorMsg (errno), d->name); + errno, strerror (errno), d->name); } Debug ("waiting for server to start %d\n", i); sleep ((unsigned) d->openDelay); @@ -352,8 +349,8 @@ WaitForServer (d) return 0; } -ResetServer (d) - struct display *d; +void +ResetServer (struct display *d) { if (dpy && d->displayType.origin != FromXDMCP) pseudoReset (dpy); @@ -362,37 +359,35 @@ ResetServer (d) static Jmp_buf pingTime; static void -PingLost () +PingLost (void) { Longjmp (pingTime, 1); } /* ARGSUSED */ static int -PingLostIOErr (dpy) - Display *dpy; +PingLostIOErr (Display *dpy) { PingLost(); + return 0; } /* ARGSUSED */ static SIGVAL -PingLostSig (n) - int n; +PingLostSig (int n) { PingLost(); } -PingServer (d, alternateDpy) - struct display *d; - Display *alternateDpy; +int +PingServer (struct display *d, Display *alternateDpy) { - int (*oldError)(); - SIGVAL (*oldSig)(); + int (*oldError)(Display *); + SIGVAL (*oldSig)(int); int oldAlarm; - - if (!alternateDpy) - alternateDpy = dpy; + static Display *aDpy; + + aDpy = (alternateDpy != NULL ? alternateDpy : dpy); oldError = XSetIOErrorHandler (PingLostIOErr); oldAlarm = alarm (0); oldSig = Signal (SIGALRM, PingLostSig); @@ -400,7 +395,7 @@ PingServer (d, alternateDpy) if (!Setjmp (pingTime)) { Debug ("Ping server\n"); - XSync (alternateDpy, 0); + XSync (aDpy, 0); } else { |