diff options
author | Adam Jackson <ajax@redhat.com> | 2007-11-01 15:41:11 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2007-11-02 11:54:16 -0400 |
commit | f01e149d1af14ef9ee0e8a6743ab6a08f3bb677c (patch) | |
tree | 6517340e87eb77d6676d63fddbf9c719da23543b /os | |
parent | a2ee5fe0c4e863c7ff4f644e5ac86f2793903103 (diff) |
Move SIGUSR1 notification as late as possible.
If we inherited a signal mask from the parent process that ignores SIGUSR1,
then we will send SIGUSR1 to the parent to indicate when we're ready to
accept connections. Unfortunately, we send this notification way too
early, right after creating the sockets rather than just before entering
the main loop.
Move it to just before Dispatch() so we're not lying quite so much.
Diffstat (limited to 'os')
-rw-r--r-- | os/connection.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/os/connection.c b/os/connection.c index 70551a844..860404f6c 100644 --- a/os/connection.c +++ b/os/connection.c @@ -362,6 +362,52 @@ InitConnectionLimits(void) #endif } +/* + * If SIGUSR1 was set to SIG_IGN when the server started, assume that either + * + * a- The parent process is ignoring SIGUSR1 + * + * or + * + * b- The parent process is expecting a SIGUSR1 + * when the server is ready to accept connections + * + * In the first case, the signal will be harmless, in the second case, + * the signal will be quite useful. + */ +static void +InitParentProcess(void) +{ +#if !defined(WIN32) + OsSigHandlerPtr handler; + handler = OsSignal (SIGUSR1, SIG_IGN); + if ( handler == SIG_IGN) + RunFromSmartParent = TRUE; + OsSignal(SIGUSR1, handler); + ParentProcess = getppid (); +#ifdef __UNIXOS2__ + /* + * fg030505: under OS/2, xinit is not the parent process but + * the "grant parent" process of the server because execvpe() + * presents us an additional process number; + * GetPPID(pid) is part of libemxfix + */ + ParentProcess = GetPPID (ParentProcess); +#endif /* __UNIXOS2__ */ +#endif +} + +void +NotifyParentProcess(void) +{ +#if !defined(WIN32) + if (RunFromSmartParent) { + if (ParentProcess > 1) { + kill (ParentProcess, SIGUSR1); + } + } +#endif +} /***************** * CreateWellKnownSockets @@ -374,7 +420,6 @@ CreateWellKnownSockets(void) int i; int partial; char port[20]; - OsSigHandlerPtr handler; FD_ZERO(&AllSockets); FD_ZERO(&AllClients); @@ -428,33 +473,9 @@ CreateWellKnownSockets(void) OsSignal (SIGTERM, GiveUp); XFD_COPYSET (&WellKnownConnections, &AllSockets); ResetHosts(display); - /* - * Magic: If SIGUSR1 was set to SIG_IGN when - * the server started, assume that either - * - * a- The parent process is ignoring SIGUSR1 - * - * or - * - * b- The parent process is expecting a SIGUSR1 - * when the server is ready to accept connections - * - * In the first case, the signal will be harmless, - * in the second case, the signal will be quite - * useful - */ -#if !defined(WIN32) - handler = OsSignal (SIGUSR1, SIG_IGN); - if ( handler == SIG_IGN) - RunFromSmartParent = TRUE; - OsSignal(SIGUSR1, handler); - ParentProcess = getppid (); - if (RunFromSmartParent) { - if (ParentProcess > 1) { - kill (ParentProcess, SIGUSR1); - } - } -#endif + + InitParentProcess(); + #ifdef XDMCP XdmcpInit (); #endif @@ -504,16 +525,6 @@ ResetWellKnownSockets (void) ResetAuthorization (); ResetHosts(display); /* - * See above in CreateWellKnownSockets about SIGUSR1 - */ -#if !defined(WIN32) - if (RunFromSmartParent) { - if (ParentProcess > 1) { - kill (ParentProcess, SIGUSR1); - } - } -#endif - /* * restart XDMCP */ #ifdef XDMCP |