* ServletSessionStateStoreProvider.cs: fixed RemoveItem, uses invalidate
authorVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Wed, 14 Feb 2007 17:12:26 +0000 (17:12 -0000)
committerVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Wed, 14 Feb 2007 17:12:26 +0000 (17:12 -0000)
fixed SetItemExpireCallback to avoid Session_OnEnd call from SessionStateModule
* SessionListener.cs: fixed sessionDestroyed to avoid clearing AppDomain on invalidate call

svn path=/trunk/mcs/; revision=72845

mcs/class/Mainsoft.Web/Mainsoft.Web.SessionState/ServletSessionStateStoreProvider.cs
mcs/class/Mainsoft.Web/Mainsoft.Web.SessionState/SessionListener.cs

index bc20085e4f9984e60293ae253c78d47d27aa8e14..71b4501f51c07611e7d94c4ab83d4d17836e84b1 100755 (executable)
@@ -91,7 +91,7 @@ namespace Mainsoft.Web.SessionState
                }\r
 \r
                public override void RemoveItem (HttpContext context, string id, object lockId, SessionStateStoreData item) {\r
-                       GetSession (context, false).setAttribute (J2EEConsts.SESSION_STATE, null);\r
+                       GetSession (context, false).invalidate ();\r
                }\r
 \r
                public override void ResetItemTimeout (HttpContext context, string id) {\r
@@ -109,7 +109,7 @@ namespace Mainsoft.Web.SessionState
                }\r
 \r
                public override bool SetItemExpireCallback (SessionStateItemExpireCallback expireCallback) {\r
-                       return true;\r
+                       return false; //we call session.invalidate so our session listener will call Session_OnEnd\r
                }\r
 \r
                #endregion\r
index 899cea59fc5519ef9f6aa05b7afe8f58e9841fdd..4917d98bef8127615264224bd24b7da03ff3cbb4 100644 (file)
@@ -40,8 +40,11 @@ namespace Mainsoft.Web.SessionState
                }
 
                public void sessionDestroyed (HttpSessionEvent se) {
-                       AppDomain servletDomain = (AppDomain) se.getSession ().getServletContext ().getAttribute (J2EEConsts.APP_DOMAIN);
-                       vmw.@internal.EnvironmentUtils.setAppDomain (servletDomain);
+                       bool setDomain = vmw.@internal.EnvironmentUtils.getAppDomain () == null;
+                       if (setDomain) {
+                               AppDomain servletDomain = (AppDomain) se.getSession ().getServletContext ().getAttribute (J2EEConsts.APP_DOMAIN);
+                               vmw.@internal.EnvironmentUtils.setAppDomain (servletDomain);
+                       }
                        try {
                                HttpSessionStateContainer container =
                                        ServletSessionStateStoreProvider.CreateContainer (se.getSession ());
@@ -55,7 +58,8 @@ namespace Mainsoft.Web.SessionState
                        }
 #endif
                        finally {
-                               vmw.@internal.EnvironmentUtils.clearAppDomain ();
+                               if (setDomain)
+                                       vmw.@internal.EnvironmentUtils.clearAppDomain ();
                        }
                }
        }