httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/winnt mpm_winnt.h service.c
Date Thu, 07 Feb 2002 00:24:12 GMT
wrowe       02/02/06 16:24:12

  Modified:    server/mpm/winnt mpm_winnt.h service.c
  Log:
    Upon advice of the FirstBill, I began looking for exceptions that occur
    only in the service-mode.  SetServiceDescription was borked, now fixed.
    Since we don't use the posix/libc style stderr, I've also pitched that
    code, which was causing an exception.
  
  Revision  Changes    Path
  1.31      +9 -0      httpd-2.0/server/mpm/winnt/mpm_winnt.h
  
  Index: mpm_winnt.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.h,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- mpm_winnt.h	17 Nov 2001 07:54:34 -0000	1.30
  +++ mpm_winnt.h	7 Feb 2002 00:24:12 -0000	1.31
  @@ -147,6 +147,15 @@
               ap_winapi_pfn_##fn = (ap_winapi_fpt_##fn) ap_load_dll_func(lib, #fn, ord);
\
           return (*(ap_winapi_pfn_##fn)) names; }; \
   
  +/* Win2K kernel only */
  +AP_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, ChangeServiceConfig2A, 0, (
  +    SC_HANDLE hService, 
  +    DWORD dwInfoLevel, 
  +    LPVOID lpInfo),
  +    (hService, dwInfoLevel, lpInfo));
  +#undef ChangeServiceConfig2
  +#define ChangeServiceConfig2 ap_winapi_ChangeServiceConfig2A
  +
   /* WinNT kernel only */
   AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, (
       IN HANDLE hFile),
  
  
  
  1.40      +28 -29    httpd-2.0/server/mpm/winnt/service.c
  
  Index: service.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/service.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- service.c	17 Oct 2001 15:51:22 -0000	1.39
  +++ service.c	7 Feb 2002 00:24:12 -0000	1.40
  @@ -413,10 +413,6 @@
    * notify the service control manager of the name change.
    */
   
  -/* ChangeServiceConfig2() prototype:
  - */
  -typedef WINADVAPI BOOL (WINAPI *CSD_T)(SC_HANDLE, DWORD, LPCVOID);
  -
   /* Windows 2000 alone 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.
  @@ -425,8 +421,6 @@
   {
       const char *full_description;
       SC_HANDLE schSCManager;
  -    CSD_T ChangeServiceDescription = NULL;
  -    HANDLE hwin2000scm;
       BOOL ret = 0;
   
       /* Nothing to do if we are a console
  @@ -438,19 +432,22 @@
        */
       full_description = ap_get_server_version();
   
  -    if ((osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
  -     && (hwin2000scm = GetModuleHandle("ADVAPI32.DLL"))
  -     && (ChangeServiceDescription = (CSD_T) GetProcAddress(hwin2000scm, 
  -                                                "ChangeServiceConfig2A"))
  -     && (schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)))
  +    if ((osver.dwPlatformId == VER_PLATFORM_WIN32_NT) 
  +          && (osver.dwMajorVersion > 4) 
  +          && (ChangeServiceConfig2)
  +          && (schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)))
       {    
           SC_HANDLE schService = OpenService(schSCManager, mpm_service_name,
                                                  SERVICE_ALL_ACCESS);
           if (schService) {
  -            if (ChangeServiceDescription(schService,
  -                                         1 /* SERVICE_CONFIG_DESCRIPTION */,
  -                                         &full_description))
  +            /* Cast is necessary, ChangeServiceConfig2 handles multiple
  +             * object types, some volatile, some not.
  +             */
  +            if (ChangeServiceConfig2(schService,
  +                                     1 /* SERVICE_CONFIG_DESCRIPTION */,
  +                                     (LPVOID) &full_description)) {
                   full_description = NULL;
  +            }
               CloseServiceHandle(schService);
           }
           CloseServiceHandle(schSCManager);
  @@ -584,9 +581,13 @@
       HANDLE hPipeReadDup;
       HANDLE thread;
       DWORD  threadid;
  -    SECURITY_ATTRIBUTES sa = {0};  
  +    SECURITY_ATTRIBUTES sa;
       const char *ignored;
   
  +    sa.nLength = sizeof(sa);
  +    sa.bInheritHandle = TRUE;
  +    sa.lpSecurityDescriptor = NULL;
  +
       /* args and service names live in the same pool */
       mpm_service_set_name(mpm_new_argv->pool, &ignored, argv[0]);
   
  @@ -603,9 +604,8 @@
           return;
       }
   
  -    ReportStatusToSCMgr(globdat.ssStatus.dwCurrentState, // service state
  -                        NO_ERROR,              // exit code
  -                        3000);                 // wait hint, 3 seconds more
  +    /* Report status, no errors, and buy 3 more seconds */
  +    ReportStatusToSCMgr(globdat.ssStatus.dwCurrentState, NO_ERROR, 3000);
       
       /* Create a pipe to send stderr messages to the system error log */
       hCurrentProcess = GetCurrentProcess();
  @@ -620,18 +620,17 @@
                                     (LPVOID) hPipeRead, 0, &threadid);
               if (thread)
               {
  -                int fh;
  -                FILE *fl;
                   CloseHandle(thread);
  -            	fflush(stderr);
  -		SetStdHandle(STD_ERROR_HANDLE, hPipeWrite);
  -				
  -                fh = _open_osfhandle((long) STD_ERROR_HANDLE, 
  -                                     _O_WRONLY | _O_BINARY);
  -                dup2(fh, STDERR_FILENO);
  -                fl = _fdopen(STDERR_FILENO, "wcb");
  -                memcpy(stderr, fl, sizeof(FILE));
  -            }
  + 		SetStdHandle(STD_ERROR_HANDLE, hPipeWrite);
  +	
  +/* XXX: To support stderr, we need some code like this.
  + * but not this specific code, turned out to be very buggy.
  + *              fh = _open_osfhandle((long) STD_ERROR_HANDLE, 
  + *                                   _O_WRONLY | _O_BINARY);
  + *              dup2(fh, STDERR_FILENO);
  + *              fl = _fdopen(STDERR_FILENO, "wcb");
  + *              memcpy(stderr, fl, sizeof(FILE));
  + */         }
               else
               {
                   CloseHandle(hPipeRead);
  
  
  

Mime
View raw message