Windows: Prevent smb_StartedLock use before initialization
[openafs.git] / src / WINNT / afsd / afsd_service.c
index a1a8034..31adc14 100644 (file)
@@ -1283,12 +1283,6 @@ afsd_Main(DWORD argc, LPTSTR *argv)
             SetServiceStatus(StatusHandle, &ServiceStatus);
         }
 #endif
-        code = afsd_InitDaemons(&reason);
-        if (code != 0) {
-            afsi_log("afsd_InitDaemons failed: %s (code = %d)", reason, code);
-                       osi_panic(reason, __FILE__, __LINE__);
-        }
-
         /* allow an exit to be called post rx initialization */
         hHookDll = cm_LoadAfsdHookLib();
         if (hHookDll)
@@ -1328,9 +1322,6 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         /* Notify any volume status handlers that the cache manager has started */
         cm_VolStatus_Service_Started();
 
-/* the following ifdef chooses the mode of operation for the service.  to enable
- * a runtime flag (instead of compile-time), pioctl() would need to dynamically
- * determine the mode, in order to use the correct ioctl special-file path. */
         code = afsd_InitSMB(&reason, MessageBox);
         if (code != 0) {
             afsi_log("afsd_InitSMB failed: %s (code = %d)", reason, code);
@@ -1367,6 +1358,12 @@ afsd_Main(DWORD argc, LPTSTR *argv)
 
         MountGlobalDrives();
 
+        code = afsd_InitDaemons(&reason);
+        if (code != 0) {
+            afsi_log("afsd_InitDaemons failed: %s (code = %d)", reason, code);
+                       osi_panic(reason, __FILE__, __LINE__);
+        }
+
 #ifndef NOTSERVICE
         if (bRunningAsService) {
             ServiceStatus.dwCurrentState = SERVICE_RUNNING;