From: Jeffrey Altman Date: Sun, 16 Aug 2009 12:43:23 +0000 (-0400) Subject: Windows: Prevent smb_StartedLock use before initialization X-Git-Tag: openafs-devel-1_5_62~44 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fa07f46db9dcc1dccf3a7ff50037f2b81936e452;p=packages%2Fo%2Fopenafs.git 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 --- diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index a1a8034b4..31adc14f9 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;