From 6fd56de3b5a023bc465db5f17812f809265e9a49 Mon Sep 17 00:00:00 2001 From: Sanchit Mehta Date: Thu, 10 Dec 2020 17:45:30 -0800 Subject: [PATCH] Test --- Kudu.Core/Deployment/DeploymentStatusFile.cs | 4 ++-- Kudu.Core/Infrastructure/WindowsLockFile.cs | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Kudu.Core/Deployment/DeploymentStatusFile.cs b/Kudu.Core/Deployment/DeploymentStatusFile.cs index 9cc3414a..b92687e5 100644 --- a/Kudu.Core/Deployment/DeploymentStatusFile.cs +++ b/Kudu.Core/Deployment/DeploymentStatusFile.cs @@ -42,7 +42,7 @@ private DeploymentStatusFile(string id, IEnvironment environment, IOperationLock { throw new FileNotFoundException("Status file doesn't exist. Will wait for 1 second and retry"); } - }, 5, 250)); + }, 3, 250)); } public static DeploymentStatusFile Create(string id, IEnvironment environment, IOperationLock statusLock) @@ -74,7 +74,7 @@ public static DeploymentStatusFile Open(string id, IEnvironment environment, IAn { // In case we read status file in middle of a write, attempt to // read it again. Don't fail the status get request - XDocument document = OperationManager.Attempt(() => LoadXmlStatusFile(path), 5, 250); + XDocument document = OperationManager.Attempt(() => LoadXmlStatusFile(path), 3, 250); return new DeploymentStatusFile(id, environment, statusLock, document); } catch (Exception ex) diff --git a/Kudu.Core/Infrastructure/WindowsLockFile.cs b/Kudu.Core/Infrastructure/WindowsLockFile.cs index c82e32fe..93cf61a4 100644 --- a/Kudu.Core/Infrastructure/WindowsLockFile.cs +++ b/Kudu.Core/Infrastructure/WindowsLockFile.cs @@ -139,12 +139,15 @@ public virtual bool IsHeld public virtual bool Lock(string operationName) { - _traceFactory.GetTracer().Trace($"Acquiring lock {_path}"); Stream lockStream = null; try { FileSystemHelpers.EnsureDirectory(Path.GetDirectoryName(_path)); + if (FileSystemHelpers.FileExists(_path)) + { + return false; + } lockStream = FileSystemHelpers.OpenFile(_path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); WriteLockInfo(operationName, lockStream); @@ -153,7 +156,6 @@ public virtual bool Lock(string operationName) _lockStream = lockStream; lockStream = null; - _traceFactory.GetTracer().Trace($"Lock Acquired {_path}"); return true; } catch (UnauthorizedAccessException) @@ -260,7 +262,6 @@ public Task LockAsync(string operationName) public virtual void Release() { - _traceFactory.GetTracer().Trace($"Releasing lock {_path}"); // Normally, this should never be null here, but currently some LiveScmEditorController code calls Release() incorrectly if (_lockStream == null) { @@ -292,7 +293,7 @@ private void DeleteFileSafe() OperationManager.Attempt(() => // throws exception if file is still present TryRemovedLockFile() - , 10, 250); + , 2, 250); } catch (Exception ex) {