Skip to content

Commit 660c3e7

Browse files
committed
Synchronisation hang bugfix
1 parent c3d814f commit 660c3e7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

FileExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public static partial class FileExtensions
2222
{
2323
//adapted from https://github.com/dotnet/runtime/blob/5ddc873d9ea6cd4bc6a935fec3057fe89a6932aa/src/libraries/System.IO.FileSystem/src/System/IO/File.cs
2424

25-
internal const int DefaultBufferSize = 4096;
25+
//internal const int DefaultBufferSize = 4096;
26+
internal const int DefaultBufferSize = 1024 * 1024; //roland
2627

2728
private static Encoding s_UTF8NoBOM;
2829

Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,10 @@ public static bool NeedsUpdate(string fullName)
448448
var converterSaveDate = GetConverterSaveDate(fullName);
449449
var fileTime = GetFileTime(fullName);
450450

451-
if (fileTime > converterSaveDate.AddSeconds(3)) //NB! ignore if the file changed during 3 seconds after converter save //TODO!! config
451+
if (
452+
!Global.Bidirectional //no need to debounce BIDIRECTIONAL file save events when bidirectional save is disabled
453+
|| fileTime > converterSaveDate.AddSeconds(3) //NB! ignore if the file changed during 3 seconds after converter save //TODO!! config
454+
)
452455
{
453456
var otherFullName = GetOtherFullName(fullName);
454457
if (fileTime > GetFileTime(otherFullName)) //NB!

Synchronisation.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define ASYNC
22
using System;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.Threading;
56
using System.Threading.Tasks;
67
using Nito.AsyncEx;
@@ -51,6 +52,9 @@ private void ReleaseLock(string name, AsyncLockWithCount lockEntry, IDisposable
5152

5253
lock (DictionaryAccessMutex)
5354
{
55+
lockEntry.WaiterCount--;
56+
Debug.Assert(lockEntry.WaiterCount >= 0);
57+
5458
if (lockEntry.WaiterCount == 0) //NB!
5559
{
5660
LockQueueDictionary.Remove(name);

0 commit comments

Comments
 (0)