aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-11-01 21:33:13 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-11-01 21:33:13 +0100
commit7e042ee6b79a0dba97ef94c32ed809334893ad91 (patch)
tree168c9a2bd8313e7a83c607a956c744f9f7a012bf
parentinstaller: use newer 3.11 stable branch of WiX (diff)
downloadwireguard-windows-7e042ee6b79a0dba97ef94c32ed809334893ad91.tar.xz
wireguard-windows-7e042ee6b79a0dba97ef94c32ed809334893ad91.zip
embeddable-dll-service: acquire pointer reference before atomic incrementHEADmaster
-rw-r--r--embeddable-dll-service/csharp/Ringlogger.cs11
1 files changed, 9 insertions, 2 deletions
diff --git a/embeddable-dll-service/csharp/Ringlogger.cs b/embeddable-dll-service/csharp/Ringlogger.cs
index c265142c..d0957926 100644
--- a/embeddable-dll-service/csharp/Ringlogger.cs
+++ b/embeddable-dll-service/csharp/Ringlogger.cs
@@ -116,12 +116,19 @@ namespace Tunnel
get => _view.ReadUInt32(offsetNextIndex);
set => _view.Write(offsetNextIndex, value);
}
- public unsafe UInt32 InsertNextIndex() => (UInt32)Interlocked.Increment(ref Unsafe.AsRef<Int32>((_view.SafeMemoryMappedViewHandle.DangerousGetHandle() + offsetNextIndex).ToPointer()));
+ public unsafe UInt32 InsertNextIndex()
+ {
+ byte* pointer = null;
+ _view.SafeMemoryMappedViewHandle.AcquirePointer(ref pointer);
+ var ret = (UInt32)Interlocked.Increment(ref Unsafe.AsRef<Int32>(pointer + offsetNextIndex));
+ _view.SafeMemoryMappedViewHandle.ReleasePointer();
+ return ret;
+ }
public UInt32 LineCount => maxLines;
public Line this[UInt32 i] => new Line(_view, i % maxLines);
- public void Clear() => _view.WriteArray(0, new byte[Log.Bytes], 0, Log.Bytes);
+ public void Clear() => _view.WriteArray(0, new byte[Bytes], 0, Bytes);
}
private readonly Log _log;