aboutsummaryrefslogtreecommitdiff
path: root/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs
diff options
context:
space:
mode:
authorLibravatar vman <public@vaughnnugent.com>2022-12-15 01:45:03 -0500
committerLibravatar vman <public@vaughnnugent.com>2022-12-15 01:45:03 -0500
commit1f2b3530ebeafa162fe4df41e691c33cb2ff0009 (patch)
tree7f60d7c761cee2df89303c3ef0550743790a63e2 /Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs
parenta0d5a8d40de9806e21e64475e3297a2a84effe22 (diff)
JWK sigs, session cleanup v1
Diffstat (limited to 'Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs')
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs22
1 files changed, 4 insertions, 18 deletions
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs b/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs
index 057e308..5747175 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProvider.cs
@@ -71,9 +71,6 @@ namespace VNLib.Plugins.Essentials.Sessions.VNCache
protected override RemoteSession SessionCtor(string sessionId) => new WebSession(sessionId, Client, BackgroundUpdateTimeout, UpdateSessionId);
-
- private uint _waitingCount;
-
public async ValueTask<SessionHandle> GetSessionAsync(IHttpEvent entity, CancellationToken cancellationToken)
{
//Callback to close the session when the handle is closeed
@@ -92,27 +89,15 @@ namespace VNLib.Plugins.Essentials.Sessions.VNCache
}
//Limit max number of waiting clients
- if (_waitingCount > MaxConnections)
+ if (WaitingConnections > MaxConnections)
{
//Set 503 for temporary unavail
entity.CloseResponse(System.Net.HttpStatusCode.ServiceUnavailable);
return new SessionHandle(null, FileProcessArgs.VirtualSkip, null);
}
- RemoteSession session;
-
- //Inc waiting count
- Interlocked.Increment(ref _waitingCount);
- try
- {
- //Recover the session
- session = await GetSessionAsync(entity, sessionId, cancellationToken);
- }
- finally
- {
- //Dec on exit
- Interlocked.Decrement(ref _waitingCount);
- }
+ //Get session
+ RemoteSession session = await GetSessionAsync(entity, sessionId, cancellationToken);
//If the session is new (not in cache), then overwrite the session id with a new one as user may have specified their own
if (session.IsNew)
@@ -131,6 +116,7 @@ namespace VNLib.Plugins.Essentials.Sessions.VNCache
session.Privilages = 0;
session.SetLoginToken(null);
}
+
return new SessionHandle(session, HandleClosedAsync);
}
catch (OperationCanceledException)