Windows: Prevent smb_StartedLock use before initialization
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 16 Aug 2009 12:43:23 +0000 (08:43 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Sun, 16 Aug 2009 12:59:49 +0000 (05:59 -0700)
The smb_StartedLock osi_mutex can be obtained before
initialization due to a race if the IP address configuration
is in a state of flux as afsd_service is starting up.
To avoid the problem call cm_InitDaemons() after smb_Init().

This race is the cause of the periodic assertions in some
environments when lock order validation is enabled.

LICENSE MIT

Reviewed-on: http://gerrit.openafs.org/318
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>

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;