aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-09-23 21:54:21 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-09-23 21:54:21 -0400
commit8da9685d9bf3fcd73a775cb7306e4e188cfa214b (patch)
treec7477e48170aa563ddcbec11dafefa1611397199
parentdd9d2aa0a1db1486ed35716e49d006db9c1f55b0 (diff)
feat: scoped spans for forward writer & tests to slndevelop
-rw-r--r--apps/VNLib.WebServer/src/Bootstrap/ReleaseWebserver.cs2
-rw-r--r--lib/Net.Http/src/Core/Request/HttpRequest.cs4
-rw-r--r--lib/Utils/src/Memory/ForwardOnlyWriter.cs26
-rw-r--r--vnlib.core.build.sln20
4 files changed, 35 insertions, 17 deletions
diff --git a/apps/VNLib.WebServer/src/Bootstrap/ReleaseWebserver.cs b/apps/VNLib.WebServer/src/Bootstrap/ReleaseWebserver.cs
index 543cbe5..8f7c0cb 100644
--- a/apps/VNLib.WebServer/src/Bootstrap/ReleaseWebserver.cs
+++ b/apps/VNLib.WebServer/src/Bootstrap/ReleaseWebserver.cs
@@ -166,7 +166,7 @@ namespace VNLib.WebServer.Bootstrap
MaxOpenConnections = gConf.MaxConnections,
MaxUploadsPerRequest = gConf.MaxUploadsPerRequest,
SendTimeout = gConf.SendTimeoutMs,
- ServerLog = logger.AppLog,
+ ServerLog = logger.SysLog,
MemoryPool = memPool,
RequestDebugLog = procArgs.LogHttp ? logger.AppLog : null,
diff --git a/lib/Net.Http/src/Core/Request/HttpRequest.cs b/lib/Net.Http/src/Core/Request/HttpRequest.cs
index cbe6bc0..b20427e 100644
--- a/lib/Net.Http/src/Core/Request/HttpRequest.cs
+++ b/lib/Net.Http/src/Core/Request/HttpRequest.cs
@@ -123,7 +123,7 @@ namespace VNLib.Net.Http.Core
private void FreeUploadBuffers()
{
//Dispose all initialized files, should be much faster than using Array.Clear();
- for (int i = 0; i < _uploads.Length; i++)
+ for (int i = 0; i < maxUploads; i++)
{
_uploads[i].Free();
_uploads[i] = default;
@@ -136,7 +136,7 @@ namespace VNLib.Net.Http.Core
/// Checks if another upload can be added to the request
/// </summary>
/// <returns>A value indicating if another file upload can be added to the array</returns>
- public bool CanAddUpload() => _state.UploadCount < _uploads.Length;
+ public bool CanAddUpload() => _state.UploadCount < maxUploads;
/// <summary>
/// Attempts to obtain a reference to the next available
diff --git a/lib/Utils/src/Memory/ForwardOnlyWriter.cs b/lib/Utils/src/Memory/ForwardOnlyWriter.cs
index 55e3b11..947ae18 100644
--- a/lib/Utils/src/Memory/ForwardOnlyWriter.cs
+++ b/lib/Utils/src/Memory/ForwardOnlyWriter.cs
@@ -82,7 +82,7 @@ namespace VNLib.Utils.Memory
/// </summary>
/// <param name="data">The data sequence to append to the buffer</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
- public void Append<TClass>(ReadOnlySpan<T> data) where TClass : class, T
+ public void Append<TClass>(scoped ReadOnlySpan<T> data) where TClass : class, T
{
//Make sure the current window is large enough to buffer the new string
ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining));
@@ -101,18 +101,18 @@ namespace VNLib.Utils.Memory
/// <typeparam name="TStruct"></typeparam>
/// <param name="data">The data sequence to append to the buffer</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
- public void Append<TStruct>(ReadOnlySpan<TStruct> data) where TStruct : struct, T
+ public void Append<TStruct>(scoped ReadOnlySpan<TStruct> data) where TStruct : struct, T
{
//Make sure the current window is large enough to buffer the new string
ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining));
//write data to window
MemoryUtil.Memmove(
- in MemoryMarshal.GetReference(data),
- 0,
- ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type,
- (nuint)Written,
- (nuint)data.Length
+ src: in MemoryMarshal.GetReference(data),
+ srcOffset: 0,
+ dst: ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type,
+ dstOffset: (nuint)Written,
+ elementCount: (nuint)data.Length
);
//update char position
@@ -127,18 +127,18 @@ namespace VNLib.Utils.Memory
/// <typeparam name="TStruct"></typeparam>
/// <param name="data">The data sequence to append to the buffer</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
- public void AppendSmall<TStruct>(ReadOnlySpan<TStruct> data) where TStruct : struct, T
+ public void AppendSmall<TStruct>(scoped ReadOnlySpan<TStruct> data) where TStruct : struct, T
{
//Make sure the current window is large enough to buffer the new string
ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining));
//write data to window
MemoryUtil.SmallMemmove(
- in MemoryMarshal.GetReference(data),
- 0,
- ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type,
- (nuint)Written,
- (ushort)data.Length
+ src: in MemoryMarshal.GetReference(data),
+ srcOffset: 0,
+ dst: ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type,
+ dstOffset: (nuint)Written,
+ elementCount: (ushort)data.Length
);
//update char position
diff --git a/vnlib.core.build.sln b/vnlib.core.build.sln
index 96ec416..d3781ce 100644
--- a/vnlib.core.build.sln
+++ b/vnlib.core.build.sln
@@ -56,6 +56,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "McMaster.NETCore.Plugins",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{2E02CD05-8D6C-48E3-AC86-B1DC8283B04B}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cryptography", "Cryptography", "{D0A82AB3-967B-4588-89F7-529E20909597}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VNLib.Hashing.PortableTests", "lib\Hashing.Portable\tests\VNLib.Hashing.PortableTests.csproj", "{361D6201-3C0E-498A-8BE4-2749121D3745}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -254,12 +258,24 @@ Global
{5B330B55-D802-45FB-A09F-50654DC9442A}.Release|x64.Build.0 = Release|Any CPU
{5B330B55-D802-45FB-A09F-50654DC9442A}.Release|x86.ActiveCfg = Release|Any CPU
{5B330B55-D802-45FB-A09F-50654DC9442A}.Release|x86.Build.0 = Release|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Debug|x64.Build.0 = Debug|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Debug|x86.Build.0 = Debug|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Release|Any CPU.Build.0 = Release|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Release|x64.ActiveCfg = Release|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Release|x64.Build.0 = Release|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Release|x86.ActiveCfg = Release|Any CPU
+ {361D6201-3C0E-498A-8BE4-2749121D3745}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {A98E6166-C836-4EDE-9B0E-B5B3624EC8FE} = {2E02CD05-8D6C-48E3-AC86-B1DC8283B04B}
+ {A98E6166-C836-4EDE-9B0E-B5B3624EC8FE} = {D0A82AB3-967B-4588-89F7-529E20909597}
{5BB717C4-A2B8-493D-B9CA-8097FD3AB0A4} = {2E02CD05-8D6C-48E3-AC86-B1DC8283B04B}
{A88A4424-1537-4EA1-9B16-920CE450B83E} = {2E02CD05-8D6C-48E3-AC86-B1DC8283B04B}
{05E8CFD3-C678-4A75-8173-2E1C9F86C650} = {2E02CD05-8D6C-48E3-AC86-B1DC8283B04B}
@@ -277,6 +293,8 @@ Global
{45EBB278-46D3-40D3-B358-0EBDC622F377} = {C8AB039C-E368-4C51-920D-06F2CEB2C95A}
{1C87FC71-9BC8-4FC1-8A99-9B9F373D1B3A} = {7FEF3272-325A-4915-AC87-4300E48E0428}
{5B330B55-D802-45FB-A09F-50654DC9442A} = {1DABF62F-1321-4854-A365-17F17B1BB994}
+ {D0A82AB3-967B-4588-89F7-529E20909597} = {2E02CD05-8D6C-48E3-AC86-B1DC8283B04B}
+ {361D6201-3C0E-498A-8BE4-2749121D3745} = {D0A82AB3-967B-4588-89F7-529E20909597}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EA12D69B-8232-40F9-98F8-8A1C73796BFE}