From fa07f46db9dcc1dccf3a7ff50037f2b81936e452 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 16 Aug 2009 08:43:23 -0400 Subject: [PATCH] Windows: Prevent smb_StartedLock use before initialization 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 Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/afsd_service.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index a1a8034..31adc14 100644 --- a/src/WINNT/afsd/afsd_service.c +++ b/src/WINNT/afsd/afsd_service.c @@ -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; -- 1.9.4