]> granicus.if.org Git - apache/commitdiff
Thanks again, Andrew Braund... a little testing and sleuthing revealed
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 14 Dec 2000 22:24:03 +0000 (22:24 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 14 Dec 2000 22:24:03 +0000 (22:24 +0000)
  we were trying to load kernel32.dll as we unloaded, which is badness.

  Right there, in my face, was the 'won't stay alive on logout' bug.
  Squashed.  So Win95/98 are working as they were in 1.3.14, only better!

  Happy day, time to roll once the remaining showstopper is cleaned up.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87348 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/winnt/Win9xConHook.c

index 0fca85ffcf75b0c03cb9abd10b3be35d4dd5bb79..ea6c35e695cd1ffa62303365912ca41d7b886285 100644 (file)
@@ -496,40 +496,47 @@ static LRESULT CALLBACK ttyConsoleCtrlWndProc(HWND hwnd, UINT msg,
  */
 static LRESULT WINAPI RegisterWindows9xService(BOOL set_service)
 {
-    HINSTANCE hkernel;
-    DWORD (WINAPI *register_service_process)(DWORD, DWORD);
+    static HINSTANCE hkernel;
+    static DWORD (WINAPI *register_service_process)(DWORD, DWORD) = NULL;
     BOOL rv;
 
     if (set_service == is_service)
         return 1;
 
 #ifdef DBG
-            DbgPrintf("R %s proc %8.8x as a service\r\n",
-                      set_service ? "installing" : "removing",
-                      GetCurrentProcessId());
+    DbgPrintf("R %s proc %8.8x as a service\r\n",
+              set_service ? "installing" : "removing",
+              GetCurrentProcessId());
 #endif
 
-    /* Obtain a handle to the kernel library */
-    hkernel = LoadLibrary("KERNEL32.DLL");
-    if (!hkernel)
-        return 0;
+    if (!register_service_process)
+    {
+        /* Obtain a handle to the kernel library */
+        hkernel = LoadLibrary("KERNEL32.DLL");
+        if (!hkernel)
+            return 0;
     
-    /* Find the RegisterServiceProcess function */
-    register_service_process = (DWORD (WINAPI *)(DWORD, DWORD))
-                     GetProcAddress(hkernel, "RegisterServiceProcess");
-    if (register_service_process == NULL) {
-        FreeLibrary(hkernel);
-        return 0;
+        /* Find the RegisterServiceProcess function */
+        register_service_process = (DWORD (WINAPI *)(DWORD, DWORD))
+                         GetProcAddress(hkernel, "RegisterServiceProcess");
+        if (register_service_process == NULL) {
+            FreeLibrary(hkernel);
+            return 0;
+        }
     }
-       
+    
     /* Register this process as a service */
-    rv = register_service_process(0, is_service != FALSE);
+    rv = register_service_process(0, set_service != FALSE);
     if (rv)
         is_service = set_service;
     
-    /* Unload the kernel library */
-    FreeLibrary(hkernel);
-    return rv;
+    if (!is_service)
+    {
+        /* Unload the kernel library */
+        FreeLibrary(hkernel);
+        register_service_process = NULL;
+        return rv;
+    }
 }