From 05ebe3b38342ba38ad0f1c418058d5100ca776ab Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 21 Jan 2023 21:43:21 -0500 Subject: Fix FBM session cancel, fix plugin log file names --- .../src/VNLib.Hashing.Portable.csproj | 1 + lib/Net.Http/src/Helpers/ContentType.cs | 2 + lib/Net.Http/src/Helpers/HelperTypes.cs | 68 +++++++++++++++++++++- lib/Net.Http/src/VNLib.Net.Http.csproj | 1 + lib/Net.Messaging.FBM/src/Server/FBMListener.cs | 4 +- .../src/VNLib.Net.Messaging.FBM.csproj | 1 + .../src/VNLib.Net.Rest.Client.csproj | 3 + .../src/VNLib.Net.Transport.SimpleTCP.csproj | 1 + .../src/ServiceDomain.cs | 3 +- .../VNLib.Plugins.Essentials.ServiceStack.csproj | 1 + .../src/Extensions/EssentialHttpEventExtensions.cs | 7 +++ .../src/Extensions/RedirectType.cs | 24 +++++++- .../src/VNLib.Plugins.Essentials.csproj | 1 + lib/Plugins.PluginBase/src/PluginBase.cs | 1 + .../src/VNLib.Plugins.PluginBase.csproj | 1 + .../src/VNLib.Plugins.Runtime.csproj | 1 + lib/Plugins/src/VNLib.Plugins.csproj | 1 + lib/Utils/src/ERRNO.cs | 25 +++++++- lib/Utils/src/Memory/MemoryUtil.cs | 9 +-- lib/Utils/src/VNLib.Utils.csproj | 1 + lib/WinRpMalloc/src/WinRpMalloc.vcxproj | 19 ++---- 21 files changed, 149 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj b/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj index 9494521..ada0908 100644 --- a/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj +++ b/lib/Hashing.Portable/src/VNLib.Hashing.Portable.csproj @@ -12,6 +12,7 @@ VNLib.Hashing True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Net.Http/src/Helpers/ContentType.cs b/lib/Net.Http/src/Helpers/ContentType.cs index ce7b7ce..6c215a7 100644 --- a/lib/Net.Http/src/Helpers/ContentType.cs +++ b/lib/Net.Http/src/Helpers/ContentType.cs @@ -22,6 +22,8 @@ * along with this program. If not, see https://www.gnu.org/licenses/. */ +#pragma warning disable CS1591 + namespace VNLib.Net.Http { /// diff --git a/lib/Net.Http/src/Helpers/HelperTypes.cs b/lib/Net.Http/src/Helpers/HelperTypes.cs index a8aeb1f..d9db604 100644 --- a/lib/Net.Http/src/Helpers/HelperTypes.cs +++ b/lib/Net.Http/src/Helpers/HelperTypes.cs @@ -32,26 +32,73 @@ namespace VNLib.Net.Http [Flags] public enum HttpMethod { + /// + /// default/no method found + /// None, + /// + /// Http GET request method + /// GET = 0x01, + /// + /// Http POST request method + /// POST = 0x02, + /// + /// Http PUT request method + /// PUT = 0x04, + /// + /// Http OPTIONS request method + /// OPTIONS = 0x08, + /// + /// Http HEAD request method + /// HEAD = 0x10, + /// + /// Http MERGE request method + /// MERGE = 0x20, + /// + /// Http COPY request method + /// COPY = 0x40, + /// + /// Http DELETE request method + /// DELETE = 0x80, + /// + /// Http PATCH request method + /// PATCH = 0x100, + /// + /// Http TRACE request method + /// TRACE = 0x200, + /// + /// Http MOVE request method + /// MOVE = 0x400, - LOCK = 0x800 + /// + /// Http LOCK request method + /// + LOCK = 0x800, + /// + /// Http UNLOCK request method + /// + UNLOCK = 0x1000 } + /// /// HTTP protocol version /// [Flags] public enum HttpVersion { + /// + /// Enum empty type + /// None, /// /// Http Version 1 @@ -74,17 +121,36 @@ namespace VNLib.Net.Http /// Http3 = 0x0A } + /// /// HTTP response entity cache flags /// [Flags] public enum CacheType { + /// + /// default cache type + /// None = 0x00, + /// + /// Set the cache header to 'No-Cache' + /// NoCache = 0x01, + /// + /// Sets the cache type private varibale + /// Private = 0x02, + /// + /// sets the cache type to public + /// Public = 0x04, + /// + /// Sets the nocache to no-store + /// NoStore = 0x08, + /// + /// Sets the must-revalidate cache flag + /// Revalidate = 0x10 } diff --git a/lib/Net.Http/src/VNLib.Net.Http.csproj b/lib/Net.Http/src/VNLib.Net.Http.csproj index 30e698c..3bbd73d 100644 --- a/lib/Net.Http/src/VNLib.Net.Http.csproj +++ b/lib/Net.Http/src/VNLib.Net.Http.csproj @@ -20,6 +20,7 @@ outside of the VNLib ecosystem are required. The VNLib.Plugins and VNLib.Plugins latest-all True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Net.Messaging.FBM/src/Server/FBMListener.cs b/lib/Net.Messaging.FBM/src/Server/FBMListener.cs index 6cca2a9..1388774 100644 --- a/lib/Net.Messaging.FBM/src/Server/FBMListener.cs +++ b/lib/Net.Messaging.FBM/src/Server/FBMListener.cs @@ -155,9 +155,7 @@ namespace VNLib.Net.Messaging.FBM.Server //No more contexts in use, dispose internals if (Cancellation.IsCancellationRequested && current == 0) { - ResponseLock.Dispose(); - Cancellation.Dispose(); - CtxStore.Dispose(); + CleanupInternal(); } } } diff --git a/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj b/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj index b1b501a..ca15fa3 100644 --- a/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj +++ b/lib/Net.Messaging.FBM/src/VNLib.Net.Messaging.FBM.csproj @@ -11,6 +11,7 @@ True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk True + false diff --git a/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj b/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj index 42cc536..117855e 100644 --- a/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj +++ b/lib/Net.Rest.Client/src/VNLib.Net.Rest.Client.csproj @@ -11,6 +11,9 @@ VNLib.Net.Rest.Client True latest-all + True + \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj b/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj index 7a476da..ef2b0cb 100644 --- a/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj +++ b/lib/Net.Transport.SimpleTCP/src/VNLib.Net.Transport.SimpleTCP.csproj @@ -13,6 +13,7 @@ simple high performance TCP servers with or without TLS security. VNLib.Net.Transport.SimpleTCP True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Plugins.Essentials.ServiceStack/src/ServiceDomain.cs b/lib/Plugins.Essentials.ServiceStack/src/ServiceDomain.cs index 0d3d83d..7b06e70 100644 --- a/lib/Plugins.Essentials.ServiceStack/src/ServiceDomain.cs +++ b/lib/Plugins.Essentials.ServiceStack/src/ServiceDomain.cs @@ -35,7 +35,6 @@ using VNLib.Plugins.Runtime; using VNLib.Plugins.Essentials.Content; using VNLib.Plugins.Essentials.Sessions; - namespace VNLib.Plugins.Essentials.ServiceStack { /// @@ -187,7 +186,9 @@ namespace VNLib.Plugins.Essentials.ServiceStack try { sw.Start(); + await plugin.InitLoaderAsync(); + //Listen for reload events to remove and re-add endpoints plugin.Reloaded += OnPluginReloaded; diff --git a/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj b/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj index 6f93d5d..3fa262f 100644 --- a/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj +++ b/lib/Plugins.Essentials.ServiceStack/src/VNLib.Plugins.Essentials.ServiceStack.csproj @@ -13,6 +13,7 @@ latest-all True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs b/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs index 9458487..4fd77a6 100644 --- a/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs +++ b/lib/Plugins.Essentials/src/Extensions/EssentialHttpEventExtensions.cs @@ -428,9 +428,16 @@ namespace VNLib.Plugins.Essentials.Extensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Redirect(this IHttpEvent ev, RedirectType type, Uri location) { + + if(type == RedirectType.None) + { + throw new ArgumentException("Invalid redirect type of none", nameof(type)); + } + //Encode the string for propery http url formatting and set the location header ev.Server.Headers[HttpResponseHeader.Location] = location.ToString(); ev.Server.SetNoCache(); + //Set redirect the ressponse redirect code type ev.CloseResponse((HttpStatusCode)type); } diff --git a/lib/Plugins.Essentials/src/Extensions/RedirectType.cs b/lib/Plugins.Essentials/src/Extensions/RedirectType.cs index eff4d38..4c9f025 100644 --- a/lib/Plugins.Essentials/src/Extensions/RedirectType.cs +++ b/lib/Plugins.Essentials/src/Extensions/RedirectType.cs @@ -31,7 +31,29 @@ namespace VNLib.Plugins.Essentials.Extensions /// public enum RedirectType { + /// + /// NOT-USED + /// None, - Moved = 301, Found = 302, SeeOther = 303, Temporary = 307, Permanent = 308 + /// + /// Sets the HTTP 301 response code for a "moved" redirect + /// + Moved = 301, + /// + /// Sets the HTTP 302 response code for a "Found" redirect + /// + Found = 302, + /// + /// Sets the HTTP 303 response code for a "SeeOther" redirect + /// + SeeOther = 303, + /// + /// Sets the HTTP 307 response code for a "Temporary" redirect + /// + Temporary = 307, + /// + /// Sets the HTTP 308 response code for a "Permanent" redirect + /// + Permanent = 308 } } \ No newline at end of file diff --git a/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj b/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj index 8d09067..e6b24aa 100644 --- a/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj +++ b/lib/Plugins.Essentials/src/VNLib.Plugins.Essentials.csproj @@ -19,6 +19,7 @@ True True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Plugins.PluginBase/src/PluginBase.cs b/lib/Plugins.PluginBase/src/PluginBase.cs index 105deab..a291e77 100644 --- a/lib/Plugins.PluginBase/src/PluginBase.cs +++ b/lib/Plugins.PluginBase/src/PluginBase.cs @@ -210,6 +210,7 @@ namespace VNLib.Plugins //Default if not set filePath ??= Path.Combine(Environment.CurrentDirectory, $"{PluginName}.txt"); + template ??= LogTemplate; //Configure the log file writer logConfig.WriteTo.File(filePath, diff --git a/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj b/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj index 7d6485a..3293018 100644 --- a/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj +++ b/lib/Plugins.PluginBase/src/VNLib.Plugins.PluginBase.csproj @@ -10,6 +10,7 @@ True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj b/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj index fa57c9e..9b77b22 100644 --- a/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj +++ b/lib/Plugins.Runtime/src/VNLib.Plugins.Runtime.csproj @@ -15,6 +15,7 @@ that export the VNLib.Plugin.IPlugin interface. latest-all True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Plugins/src/VNLib.Plugins.csproj b/lib/Plugins/src/VNLib.Plugins.csproj index 76d292f..37811ac 100644 --- a/lib/Plugins/src/VNLib.Plugins.csproj +++ b/lib/Plugins/src/VNLib.Plugins.csproj @@ -19,6 +19,7 @@ with the VNLib.Plugins.Runtime loader library. latest-all True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/Utils/src/ERRNO.cs b/lib/Utils/src/ERRNO.cs index 972aa49..03ebd17 100644 --- a/lib/Utils/src/ERRNO.cs +++ b/lib/Utils/src/ERRNO.cs @@ -123,15 +123,37 @@ namespace VNLib.Utils public readonly override bool Equals(object? obj) => obj is ERRNO other && Equals(other); public readonly override int GetHashCode() => ErrorCode.GetHashCode(); + /// + /// Attempts to parse the value of the character sequence as a new error code + /// + /// The character sequence value to parse + /// The value + /// True if the value was successfully parsed, false othwerwise + public static bool TryParse(ReadOnlySpan value, out ERRNO result) + { + result = 0; + if (nint.TryParse(value, out nint res)) + { + result = new ERRNO(res); + return true; + } + return false; + } + /// /// The integer error value of the current instance in radix 10 /// - /// + /// The radix 10 formatted error code public readonly override string ToString() { //Return the string of the error code number return ErrorCode.ToString(); } + /// + /// Formats the internal nint error code as a string in specified format + /// + /// The format to use + /// The formatted error code public readonly string ToString(string format) { //Return the string of the error code number @@ -143,6 +165,7 @@ namespace VNLib.Utils { return ErrorCode.TryFormat(destination, out charsWritten, format, provider); } + /// public readonly string ToString(string format, IFormatProvider formatProvider) { diff --git a/lib/Utils/src/Memory/MemoryUtil.cs b/lib/Utils/src/Memory/MemoryUtil.cs index c20d956..56ccb7e 100644 --- a/lib/Utils/src/Memory/MemoryUtil.cs +++ b/lib/Utils/src/Memory/MemoryUtil.cs @@ -88,11 +88,11 @@ namespace VNLib.Utils.Memory private static Lazy InitHeapInternal() { //Get env for heap diag - bool enableDiag = Environment.GetEnvironmentVariable(SHARED_HEAP_ENABLE_DIAGNOISTICS_ENV) == "1"; - - Trace.WriteIf(enableDiag, "Shared heap diagnostics enabled"); + _ = ERRNO.TryParse(Environment.GetEnvironmentVariable(SHARED_HEAP_ENABLE_DIAGNOISTICS_ENV), out ERRNO diagEnable); + + Trace.WriteIf(diagEnable, "Shared heap diagnostics enabled"); - Lazy heap = new (() => InitHeapInternal(true, enableDiag), LazyThreadSafetyMode.PublicationOnly); + Lazy heap = new (() => InitHeapInternal(true, diagEnable), LazyThreadSafetyMode.PublicationOnly); //Cleanup the heap on process exit AppDomain.CurrentDomain.DomainUnload += DomainUnloaded; @@ -505,6 +505,7 @@ namespace VNLib.Utils.Memory /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static nuint ByteCount(nuint elementCount) => checked(elementCount * (nuint)Unsafe.SizeOf()); + /// /// Gets the byte multiple of the length parameter /// diff --git a/lib/Utils/src/VNLib.Utils.csproj b/lib/Utils/src/VNLib.Utils.csproj index b14ab27..d326325 100644 --- a/lib/Utils/src/VNLib.Utils.csproj +++ b/lib/Utils/src/VNLib.Utils.csproj @@ -16,6 +16,7 @@ latest-all True \\vaughnnugent.com\Internal\Folder Redirection\vman\Documents\Programming\Software\StrongNameingKey.snk + false diff --git a/lib/WinRpMalloc/src/WinRpMalloc.vcxproj b/lib/WinRpMalloc/src/WinRpMalloc.vcxproj index b39deed..70c9d87 100644 --- a/lib/WinRpMalloc/src/WinRpMalloc.vcxproj +++ b/lib/WinRpMalloc/src/WinRpMalloc.vcxproj @@ -1,5 +1,8 @@ + + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\ + Debug @@ -23,7 +26,7 @@ Win32Proj {f5bfb8aa-a436-4a8d-94bc-9eff3ad8aa1d} WinRpMalloc - 10.0 + 10.0.20348.0 @@ -57,18 +60,6 @@ - - - - - - - - - - - - true @@ -131,7 +122,6 @@ StdCall true Speed - false true Default false @@ -140,7 +130,6 @@ true - %(AdditionalLibraryDirectories) true -- cgit