From: Oliver Kurth Date: Mon, 23 Oct 2017 21:21:19 +0000 (-0700) Subject: hosted file locking: An upper bound on creating the lock directory X-Git-Tag: stable-10.3.0~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa4c5b9eac9e2899aef8f6a831e121152adc075b;p=thirdparty%2Fopen-vm-tools.git hosted file locking: An upper bound on creating the lock directory There is currently no upper bound on how long we wait to enter a hosted file lock (create lock directory and the direct entry (the "D")). Fix this. --- diff --git a/open-vm-tools/lib/file/fileLockPrimitive.c b/open-vm-tools/lib/file/fileLockPrimitive.c index 3e534a310..e58377164 100644 --- a/open-vm-tools/lib/file/fileLockPrimitive.c +++ b/open-vm-tools/lib/file/fileLockPrimitive.c @@ -1259,8 +1259,8 @@ FileLockCreateEntryDirectory(const char *lockDir, // IN: char **memberFilePath, // OUT: char **memberName) // OUT: { - int err = 0; - uint32 randomNumber = 0; + int err; + VmTimeType startTimeMsec; ASSERT(lockDir != NULL); @@ -1270,10 +1270,13 @@ FileLockCreateEntryDirectory(const char *lockDir, // IN: *memberName = NULL; /* Fun at the races */ + startTimeMsec = Hostinfo_SystemTimerMS(); while (TRUE) { char *temp; FileData fileData; + VmTimeType ageMsec; + uint32 randomNumber; err = FileAttributesRobust(lockDir, &fileData); if (err == 0) { @@ -1393,6 +1396,21 @@ FileLockCreateEntryDirectory(const char *lockDir, // IN: *entryFilePath = NULL; *memberFilePath = NULL; *memberName = NULL; + + /* + * If we've been trying to get the locking started for a unacceptable + * amount of time, bail. Something is seriously wrong, probably the + * file system or networking. Nothing we can do about it. + */ + + ageMsec = Hostinfo_SystemTimerMS() - startTimeMsec; + + if (ageMsec > FILELOCK_PROGRESS_DEARTH) { + Warning(LGPFX" %s lack of progress on '%s'\n", __FUNCTION__, lockDir); + + err = EBUSY; + break; + } } if (err != 0) {