httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apache-1.3/src/os/win32 service.c
Date Tue, 27 Feb 2001 06:39:32 GMT
wrowe       01/02/26 22:39:32

  Modified:    src      CHANGES
               src/os/win32 service.c
  Log:
    Add the Win32 service 'description', of our running server_version.
  
  Revision  Changes    Path
  1.1662    +10 -7     apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1661
  retrieving revision 1.1662
  diff -u -r1.1661 -r1.1662
  --- CHANGES	2001/02/27 03:59:52	1.1661
  +++ CHANGES	2001/02/27 06:39:31	1.1662
  @@ -1,13 +1,16 @@
   Changes with Apache 1.3.20
   
  -  *) Introduce NUL device pipes for stdin and stdout for the parent Win32
  -  *) Added a new API for NetWare to allow Apache the chance to unimport
  -     module symbols before it shuts down.
  -	   void ap_os_dso_unsym(void *handle, const char *symname)
  -	 This is necessary so that Apache on NetWare can shutdown cleanly
  -	 in an error condition such as a failure while reading the .CONF
  -	 file. [Brad Nicholes <BNICHOLES@novell.com>]
  +  *) Set the Win32 service description in the Services control panel to 
  +     the server_version string from Apache and the loaded modules.
  +     [William Rowe]
  +
  +  *) Added a new API for NetWare, ap_os_dso_unsym(), to allow Apache the 
  +     chance to unimport module symbols before it shuts down.  This is 
  +     necessary so that Apache on NetWare can shutdown cleanly in an error
  +     condition such as a failure while reading the httpd.conf file.
  +     [Brad Nicholes <BNICHOLES@novell.com>]
   
  +  *) Introduce NUL device pipes for stdin and stdout for the parent Win32
        service process.  This solves bugs such as PR7198 that report 
        "dup2(stdin) failed" when trying to use piped logs.  [William Rowe]
   
  
  
  
  1.46      +41 -1     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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- service.c	2001/02/26 20:33:53	1.45
  +++ service.c	2001/02/27 06:39:32	1.46
  @@ -646,6 +646,9 @@
   
       atexit(service_main_fn_terminate);
   
  +    /* Grab it or lose it */
  +    globdat.name = argv[0];
  +
       ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, NULL,
                "Hooked up the Service Error Event Logger.");
   
  @@ -661,7 +664,7 @@
       argc += 2;
   
       /* Use the name of the service as the error log marker */
  -    ap_server_argv0 = globdat.name = argv[0];
  +	ap_server_argv0 = globdat.name;
   
       globdat.exit_status = globdat.main_fn( argc, argv );
   }
  @@ -729,8 +732,42 @@
   }
   
   
  +typedef WINADVAPI BOOL (*CSD_T)(SC_HANDLE, DWORD, LPCVOID);
  +    
  +/* Windows 2000 only supports ChangeServiceConfig2 in order to
  + * register our server_version string... so we need some fixups
  + * to avoid binding to that function if we are on WinNT/9x
  + */
  +void ReportDescriptionToSCM()
  +{
  +    const char *full_description = ap_get_server_version();
  +    SC_HANDLE schSCManager;
  +    CSD_T ChangeServiceDescription;    
  +    HANDLE hwin2000scm = LoadLibrary("ADVAPI32.DLL");
  +    if (!hwin2000scm) 
  +        return;
  +    ChangeServiceDescription = (CSD_T) GetProcAddress(hwin2000scm, 
  +                                                      "ChangeServiceConfig2A");
  +    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  +    if (schSCManager) {
  +        SC_HANDLE schService = OpenService(schSCManager, globdat.name,
  +                                           SERVICE_ALL_ACCESS);
  +        if (schService) {
  +            /* In advapi32 -only- on Win2000 */
  +            ChangeServiceDescription(schService,
  +                                     SERVICE_CONFIG_DESCRIPTION,
  +                                     &full_description);
  +            CloseServiceHandle(schService);
  +        }
  +        CloseServiceHandle(schSCManager);
  +    }
  +    FreeLibrary(hwin2000scm);
  +}
  +
  +
   int ReportStatusToSCMgr(int currentState, int exitCode, int waitHint)
   {
  +    static int onceStarted = 1;
       static int firstTime = 1;
       static int checkPoint = 1;
       int rv;
  @@ -768,6 +805,9 @@
   
           rv = SetServiceStatus(globdat.hServiceStatus, &globdat.ssStatus);
   
  +        if (currentState == SERVICE_RUNNING && onceStarted) {
  +            onceStarted = 0;
  +        }
       }
       return(1);
   }
  
  
  

Mime
View raw message