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.h service.c
Date Thu, 16 Nov 2000 23:14:25 GMT
wrowe       00/11/16 15:14:25

  Modified:    src/main http_main.c
               src/os/win32 service.h service.c
  Log:
    This is (hopefully) the final patch to get Win95/98/NT/2K working.
    We will see if it works as advertised... this patch tags the Win9x
    Console process as a 'service' to avoid it being shut down between
    logoffs.  However, the console is its own process, so I'm not holding
    my breath.  Also fix a minor typo in the last service.c patch.
  
  Revision  Changes    Path
  1.515     +2 -2      apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.514
  retrieving revision 1.515
  diff -u -r1.514 -r1.515
  --- http_main.c	2000/11/16 22:18:27	1.514
  +++ http_main.c	2000/11/16 23:14:23	1.515
  @@ -7016,8 +7016,8 @@
   	if (!exit_event || !start_mutex)
   	    exit(-1);
   #ifdef WIN32
  -    if (child && isWindowsNT())
  -        FreeConsole();
  +        if (child)
  +            ap_prepare_child_console();
   #endif
   	worker_main();
   	ap_destroy_mutex(start_mutex);
  
  
  
  1.10      +1 -0      apache-1.3/src/os/win32/service.h
  
  Index: service.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/service.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- service.h	2000/07/03 14:50:52	1.9
  +++ service.h	2000/11/16 23:14:24	1.10
  @@ -16,6 +16,7 @@
   extern int real_exit_code;
   void hold_console_open_on_error(void);
   
  +void ap_prepare_child_console(void);
   int service_main(int (*main_fn)(int, char **), int argc, char **argv);
   int service95_main(int (*main_fn)(int, char **), int argc, char **argv,
   		   char *display_name);
  
  
  
  1.27      +38 -2     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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- service.c	2000/11/16 22:20:25	1.26
  +++ service.c	2000/11/16 23:14:24	1.27
  @@ -223,7 +223,8 @@
   
   void stop_service_monitor(void)
   {
  -    PostThreadMessage(monitor_thread_id, WM_QUIT, 0, 0);
  +    if (monitor_thread_id)
  +        PostThreadMessage(monitor_thread_id, WM_QUIT, 0, 0);
   
       /* When the service quits, remove it from the 
          system service table */
  @@ -233,6 +234,41 @@
       FreeLibrary(monitor_hkernel);
   }
   
  +/*
  + * The WinNT child can simply free its console.
  + * Win9x children cannot loose the console since 16bit cgi processes
  + * will hang if they are not launched from a 32bit console app.
  + * Instead, mark the Win9x child as a service process and let the
  + * parent process clean it up as necessary.
  + */
  +void ap_prepare_child_console(void)
  +{
  +    if (isWindowsNT()) {
  +        FreeConsole();
  +        return;
  +    }
  +
  +    /* Obtain a handle to the kernel library */
  +    monitor_hkernel = LoadLibrary("KERNEL32.DLL");
  +    if (!monitor_hkernel)
  +        return;
  +    
  +    /* Find the RegisterServiceProcess function */
  +    RegisterServiceProcess = (DWORD (WINAPI *)(DWORD, DWORD))
  +                   GetProcAddress(monitor_hkernel, "RegisterServiceProcess");
  +    if (RegisterServiceProcess == NULL)
  +        return;
  +	
  +    /* Register this process as a service */
  +    if (!RegisterServiceProcess((DWORD)NULL, 1))
  +        return;
  +
  +    /* Borrowing stop_service_monitor, but there is no monitor thread */
  +    monitor_thread_id = 0;
  +
  +    atexit(stop_service_monitor);
  +}
  +
   int service95_main(int (*main_fn)(int, char **), int argc, char **argv, 
   		   char *display_name)
   {
  @@ -968,7 +1004,7 @@
                           printf("The %s service has %s.\n", display_name, 
                                  past[action]);
                           strcpy(sig, "start");
  -                        return status;
  +                        return success;
                       }
                       
                       ap_start_restart(1);
  
  
  

Mime
View raw message