httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-1.3/src/os/win32 service.c
Date Wed, 22 Nov 2000 16:44:51 GMT
wrowe       00/11/22 08:44:51

  Modified:    src/os/win32 service.c
  Log:
    This patch solves two problems.  Under Win2K, the program will no longer
    hang up during logoff or shutdown.  On all Win32, this patch detaches the
    Apache child from the parent's console window, and hides it, such that
    child CGI processes no longer cause window 'flicker' of icon or title
    changes when they are invoked.  They are invoked in the hidden child
    console instead, and there is no apparent affect to the user's console.
  
    This patch has one problem, the AllocConsole() is too async on Win9x, so
    the window may not be succesfully located and hidden, resulting in two
    visible consoles.  Working on that issue now.
  
  Revision  Changes    Path
  1.30      +46 -5     apache-1.3/src/os/win32/service.c
  
  Index: service.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/service.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- service.c	2000/11/22 02:46:28	1.29
  +++ service.c	2000/11/22 16:44:50	1.30
  @@ -343,8 +343,12 @@
    */
   static BOOL CALLBACK EnumttyWindow(HWND wnd, LPARAM retwnd)
   {
  -    char tmp[8];
  -    if (GetClassName(wnd, tmp, sizeof(tmp)) && !strcmp("tty",tmp)) 
  +    char tmp[20], *tty;
  +    if (isWindowsNT())
  +        tty = "ConsoleWindowClass";
  +    else
  +        tty = "tty";
  +    if (GetClassName(wnd, tmp, sizeof(tmp)) && !strcmp(tmp, tty)) 
       {
           DWORD wndproc, thisproc = GetCurrentProcessId();
           GetWindowThreadProcessId(wnd, &wndproc);
  @@ -396,11 +400,27 @@
           die_on_logoff = TRUE;
   
       if (isWindowsNT()) {
  -        /* Apache/NT installs no child console handler, otherwise
  +        if (!is_child_of_service) {
  +            /*
  +             * Console mode Apache/WinNT needs to detach from the parent
  +             * console and create and hide it's own console window.
  +             * Not only is logout and shutdown more stable under W2K,
  +             * but this eliminates the mystery 'flicker' that users see
  +             * when invoking CGI apps (e.g. the titlebar or icon of the
  +             * console window changing to the cgi process's identifiers.)
  +             */
  +            FreeConsole();
  +            AllocConsole();
  +            EnumWindows(EnumttyWindow, (long)(&console_wnd));
  +            if (console_wnd)
  +                ShowWindow(console_wnd, SW_HIDE);
  +        }
  +        /*
  +         * Apache/WinNT installs no child console handler, otherwise
            * logoffs interfere with the service's child process!
            * The child process must have a later shutdown priority
            * than the parent, or the parent cannot shut down the
  -         * child process properly.
  +         * child process properly.  (The parent's default is 0x280.)
            */
           SetProcessShutdownParameters(0x200, 0);
           return;
  @@ -420,11 +440,32 @@
       /* Register this process as a service */
       if (!RegisterServiceProcess(0, 1))
           return;
  +
  +    if (!is_child_of_service) {
  +        /*
  +         * Needs thorough testing, although the idea makes sense;
  +         * Console mode Apache/Win9x might benefit from detaching
  +         * from the parent console, creating and hiding it's own 
  +         * console window.  No noticable difference yet, except
  +         * that the flicker (when executing CGIs) does disappear.
  +         */
  +        FreeConsole();
  +        AllocConsole();
  +    }
   
  -    /* Locate our winoldap process, and tag it as a service process */
       EnumWindows(EnumttyWindow, (long)(&console_wnd));
  +    if (console_wnd && !is_child_of_service)
  +    {
  +        /*
  +         * Hide our newly created child console
  +         */
  +        ShowWindow(console_wnd, SW_HIDE);
  +    }
       if (console_wnd)
       {
  +        /*
  +         * Locate our winoldap process, and tag it as a service process 
  +         */
           HWND console_child = GetWindow(console_wnd, GW_CHILD);
           GetWindowThreadProcessId(console_child, &dos_child_procid);
           if (dos_child_procid)
  
  
  

Mime
View raw message