From 4035c838c1508af0aa7e767a97431a692958ce1c Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 12 May 2024 16:55:32 -0400 Subject: perf: Utils + http perf mods --- .../src/Middleware/MiddlewareController.cs | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/Plugins.Essentials/src/Middleware') diff --git a/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs b/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs index 2ce62b3..c3a85c9 100644 --- a/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs +++ b/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs @@ -33,12 +33,20 @@ namespace VNLib.Plugins.Essentials.Middleware public async ValueTask ProcessAsync(HttpEntity entity) { + /* + * Loops through the current linkedlist of the current middleware chain. The + * chain should remain unmodified after GetCurrentHead() is called. + * + * Middleware will return a Continue routine to move to the next middleware + * node. All other routines mean the processor has responded to the client + * itself and must exit control and move to response. + */ + LinkedListNode? mwNode = _chain.GetCurrentHead(); //Loop through nodes while (mwNode != null) { - //Invoke mw handler on our event entity.EventArgs = await mwNode.ValueRef.ProcessAsync(entity); switch (entity.EventArgs.Routine) @@ -60,9 +68,14 @@ namespace VNLib.Plugins.Essentials.Middleware public void PostProcess(HttpEntity entity) { - LinkedListNode? mwNode = _chain.GetCurrentHead(); + /* + * Middleware nodes may be allowed to inspect, or modify the return + * event arguments as the server may not have responded to the client + * yet. + */ - //Loop through nodes + LinkedListNode? mwNode = _chain.GetCurrentHead(); + while (mwNode != null) { //Invoke mw handler on our event @@ -72,6 +85,4 @@ namespace VNLib.Plugins.Essentials.Middleware } } } - - -} \ No newline at end of file +} -- cgit