From: Jeffrey Altman Date: Tue, 26 Jan 2010 15:23:03 +0000 (-0500) Subject: Windows: drop cm_Freelance_Lock before call to cm_FreelanceAddMount X-Git-Tag: openafs-devel-1_5_71~13 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=9e4477fbfb212bcaaa6c9324ed992dd769502737;p=packages%2Fo%2Fopenafs.git Windows: drop cm_Freelance_Lock before call to cm_FreelanceAddMount The cm_Freelance_Lock must not be held before calling cm_FreelanceAddMount(). cm_InitLocalMountPoints() was violating this requirement. It is safe to drop the lock because the only time the lock would be dropped is if the "Freelance" registry key does not exist. This should only be true during the initial startup of the application the first time afsd_service.exe executes on the machine. At this point in time there is only one thread that is executing that could be initializing the Freelance mount point list. LICENSE MIT Change-Id: Ib49cf8bc830836c8e08446073e64ccf30086d354 Reviewed-on: http://gerrit.openafs.org/1164 Reviewed-by: Asanka Herath Tested-by: Asanka Herath Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_freelance.c b/src/WINNT/afsd/cm_freelance.c index b117bc704..bef54ed25 100644 --- a/src/WINNT/afsd/cm_freelance.c +++ b/src/WINNT/afsd/cm_freelance.c @@ -141,6 +141,7 @@ void cm_InitFreelance() { lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock", LOCK_HIERARCHY_FREELANCE_GLOBAL); + lock_ObtainMutex(&cm_Freelance_Lock); // yj: first we make a call to cm_initLocalMountPoints // to read all the local mount points from the registry cm_InitLocalMountPoints(); @@ -149,6 +150,7 @@ void cm_InitFreelance() { // a fake root directory based on the local mount points cm_InitFakeRootDir(); // --- end of yj code + lock_ReleaseMutex(&cm_Freelance_Lock); /* Start the registry monitor */ phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceChangeNotifier, @@ -163,7 +165,7 @@ void cm_InitFreelance() { } /* yj: Initialization of the fake root directory */ -/* to be called while holding freelance lock unless during init. */ +/* to be called while holding freelance lock. */ void cm_InitFakeRootDir() { int i, t1, t2; char* currentPos; @@ -453,7 +455,7 @@ int cm_reInitLocalMountPoints() { // yj: open up the registry and read all the local mount // points that are stored there. Part of the initialization // process for the freelance client. -/* to be called while holding freelance lock unless during init. */ +/* to be called while holding freelance lock. */ long cm_InitLocalMountPoints() { FILE *fp; int i; @@ -496,9 +498,11 @@ long cm_InitLocalMountPoints() { rootCellName[0] = '.'; code = cm_GetRootCellName(&rootCellName[1]); if (code == 0) { + lock_ReleaseMutex(&cm_Freelance_Lock); cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL); cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL); cm_FreelanceAddMount(".root", &rootCellName[1], "root.afs.", 1, NULL); + lock_ObtainMutex(&cm_Freelance_Lock); dwMountPoints = 3; } } @@ -693,9 +697,11 @@ long cm_InitLocalMountPoints() { rootCellName[0] = '.'; code = cm_GetRootCellName(&rootCellName[1]); if (code == 0) { + lock_ReleaseMutex(&cm_Freelance_Lock); cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL); cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL); cm_FreelanceAddMount(".root", &rootCellName[1], "root.afs.", 1, NULL); + lock_ObtainMutex(&cm_Freelance_Lock); } return 0; }