Skip to content

Commit dfeb068

Browse files
committed
Deadlock bugfix
1 parent 660c3e7 commit dfeb068

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ private static async Task OnRenamedAsync(IRenamedFileSystemEvent rfse, Cancellat
594594
//NB! if file is renamed to cs~ or resx~ then that means there will be yet another write to same file, so lets skip this event here
595595
if (!rfse.FileSystemInfo.FullName.EndsWith("~"))
596596
{
597-
using (await Global.FileOperationLocks.LockAsync(rfse.FileSystemInfo.FullName, rfse.PreviousFileSystemInfo.FullName, context.Token))
597+
//using (await Global.FileOperationLocks.LockAsync(rfse.FileSystemInfo.FullName, rfse.PreviousFileSystemInfo.FullName, context.Token)) //comment-out: prevent deadlock
598598
{
599599
await FileUpdated(rfse.FileSystemInfo.FullName, context);
600600
await FileDeleted(rfse.PreviousFileSystemInfo.FullName, context);

Synchronisation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public void Dispose()
112112
//NB! in order to avoid deadlocks, always take the locks in deterministic order
113113
names.Sort(StringComparer.InvariantCultureIgnoreCase);
114114

115-
var releaser1 = await Global.FileOperationLocks.LockAsync(names[0], cancellationToken);
116-
var releaser2 = name1 != name2 ? await Global.FileOperationLocks.LockAsync(names[1], cancellationToken) : null;
115+
var releaser1 = await this.LockAsync(names[0], cancellationToken);
116+
var releaser2 = name1 != name2 ? await this.LockAsync(names[1], cancellationToken) : null;
117117

118118
return new MultiLockDictReleaser(releaser1, releaser2);
119119
}

0 commit comments

Comments
 (0)