Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Christoforides <alexis@thenull.net>2017-12-08 04:00:23 +0300
committerGitHub <noreply@github.com>2017-12-08 04:00:23 +0300
commit7758f54dcf8681c85e34c76b35e437fdc51ec285 (patch)
treea2bd6a13669f50ad181321f5cdc527f9bac17ef4 /mcs/class/System.Web
parentdd34edb9076b05cefd37b53bb8f0fb1b8f1884a3 (diff)
parent1057d0329a2376120a18b37ba21bbc322304aa34 (diff)
Merge pull request #1450 from echampet/session
System.Web.SessionState: simplify sessions retrival polling
Diffstat (limited to 'mcs/class/System.Web')
-rw-r--r--mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs51
1 files changed, 11 insertions, 40 deletions
diff --git a/mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs b/mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs
index 8d85d6482f0..8d9dac0c312 100644
--- a/mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs
+++ b/mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs
@@ -46,21 +46,6 @@ namespace System.Web.SessionState
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SessionStateModule : IHttpModule
{
- class CallbackState
- {
- public readonly HttpContext Context;
- public readonly AutoResetEvent AutoEvent;
- public readonly string SessionId;
- public readonly bool IsReadOnly;
-
- public CallbackState (HttpContext context, AutoResetEvent e, string sessionId, bool isReadOnly) {
- this.Context = context;
- this.AutoEvent = e;
- this.SessionId = sessionId;
- this.IsReadOnly = isReadOnly;
- }
- }
-
internal const string HeaderName = "AspFilterSessionId";
internal const string CookielessFlagName = "_SessionIDManager_IsCookieLess";
@@ -342,36 +327,22 @@ namespace System.Web.SessionState
return item;
}
- void WaitForStoreUnlock (HttpContext context, string sessionId, bool isReadonly) {
- AutoResetEvent are = new AutoResetEvent (false);
- TimerCallback tc = new TimerCallback (StoreUnlockWaitCallback);
- CallbackState cs = new CallbackState (context, are, sessionId, isReadonly);
- using (Timer timer = new Timer (tc, cs, 500, 500)) {
- try {
- are.WaitOne (executionTimeout, false);
+ void WaitForStoreUnlock (HttpContext context, string sessionId, bool isReadOnly) {
+ DateTime dt = DateTime.Now;
+ while ((DateTime.Now - dt) < executionTimeout) {
+ Thread.Sleep(500);
+ storeData = GetStoreData (context, sessionId, isReadOnly);
+ if (storeData == null && storeLocked && (storeLockAge > executionTimeout)) {
+ handler.ReleaseItemExclusive (context, sessionId, storeLockId);
+ return;
}
- catch {
- storeData = null;
+ else if (storeData != null && !storeLocked) {
+ //we have the session
+ return;
}
}
}
- void StoreUnlockWaitCallback (object s) {
- CallbackState state = (CallbackState) s;
-
- SessionStateStoreData item = GetStoreData (state.Context, state.SessionId, state.IsReadOnly);
-
- if (item == null && storeLocked && (storeLockAge > executionTimeout)) {
- handler.ReleaseItemExclusive (state.Context, state.SessionId, storeLockId);
- storeData = null; // Create new state
- state.AutoEvent.Set ();
- }
- else if (item != null && !storeLocked) {
- storeData = item;
- state.AutoEvent.Set ();
- }
- }
-
HttpSessionStateContainer CreateContainer (string sessionId, SessionStateStoreData data, bool isNew, bool isReadOnly) {
if (data == null)
return new HttpSessionStateContainer (