2005-05-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 27 May 2005 05:10:21 +0000 (05:10 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 27 May 2005 05:10:21 +0000 (05:10 -0000)
* RemoteStateServer.cs:
* HttpSessionState.cs:
* SessionSQLServerHandler.cs:
* SessionInProcHandler.cs:
* SessionStateServerHandler.cs: remove abandoned sessions in the
ReleseRequest state. Fixes bug #75051.

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

mcs/class/System.Web/System.Web.SessionState/ChangeLog
mcs/class/System.Web/System.Web.SessionState/HttpSessionState.cs
mcs/class/System.Web/System.Web.SessionState/RemoteStateServer.cs
mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.cs
mcs/class/System.Web/System.Web.SessionState/SessionSQLServerHandler.cs
mcs/class/System.Web/System.Web.SessionState/SessionStateServerHandler.cs

index e5c1b1dd9166d443ed6bdee8dc17a26e8f17723c..f9b520340f8311b32ca2751fb7d1693bc233e9fd 100644 (file)
@@ -1,3 +1,12 @@
+2005-05-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * RemoteStateServer.cs:
+       * HttpSessionState.cs:
+       * SessionSQLServerHandler.cs:
+       * SessionInProcHandler.cs:
+       * SessionStateServerHandler.cs: remove abandoned sessions in the 
+       ReleseRequest state. Fixes bug #75051.
+
 2005-04-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * SessionSQLServerHandler.cs:
index 03fcacbb118a33b1361e171c4f17f940ae179f35..901c923401c59ee981a9deae1ece6a5af87d4fa3 100644 (file)
@@ -46,7 +46,7 @@ public sealed class HttpSessionState : ICollection, IEnumerable
        private bool _isCookieless;
        private SessionStateMode _mode;
        private bool _isReadonly;
-       private bool _abandoned;
+       internal bool _abandoned;
 
        internal HttpSessionState (string id,
                                   SessionDictionary dict,
index a35b84e198e008916ed7b5ebdbe40d5478b549b5..2eccf50af8fbe892bdd8797ddcb1bccd43d63711 100644 (file)
@@ -70,6 +70,11 @@ namespace System.Web.SessionState {
                        item.Touch ();
                        return item;
                }
+
+               internal void Remove (string id)
+               {
+                       table.Remove (id);
+               }
        }
 }
 
index e0a327f822811ab385c71a2188de3fc282113677..800a5ca70e2305bc50cdc9487499b50efcd3a03a 100644 (file)
@@ -50,7 +50,14 @@ namespace System.Web.SessionState
                        this.config = config;
                }
 
-               public void UpdateHandler (HttpContext context, SessionStateModule module) { }
+               public void UpdateHandler (HttpContext context, SessionStateModule module)
+               {
+                       HttpSessionState session = context.Session;
+                       if (session == null || session.IsReadOnly || !session._abandoned)
+                               return;
+
+                       HttpRuntime.Cache.Remove ("@@@InProc@" + session.SessionID);
+               }
 
                public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module,
                                                        bool required, bool read_only, ref bool isNew)
index 7b6ba2a4c4baace3e38c3bc6acad1a30aeb05c9f..46abec917c3fef24d4d00f73860d4c680d5e2e89 100644 (file)
@@ -81,13 +81,17 @@ namespace System.Web.SessionState {
 
                public void UpdateHandler (HttpContext context, SessionStateModule module)
                {
-                       if (context.Session == null || context.Session.IsReadOnly)
+                       HttpSessionState session = context.Session;
+                       if (session == null || session.IsReadOnly)
                                return;
 
-                       string id = context.Session.SessionID;
-                       SessionDictionary dict = context.Session.SessionDictionary;
-
-                       UpdateSession (id, dict);
+                       string id = session.SessionID;
+                       if (!session._abandoned) {
+                               SessionDictionary dict = session.SessionDictionary;
+                               UpdateSession (id, dict);
+                       } else {
+                               DeleteSession (id);
+                       }
                }
 
                public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module,
@@ -218,6 +222,18 @@ namespace System.Web.SessionState {
                        command.ExecuteNonQuery ();
                }
 
+               private void DeleteSession (string id)
+               {
+                       IDbCommand command = cnc.CreateCommand ();
+                       IDataParameterCollection param;
+
+                       string update = "DELETE FROM ASPStateTempSessions WHERE SessionId = :SessionID";
+                       command.CommandText = update;
+                       param = command.Parameters;
+                       param.Add (CreateParam (command, DbType.String, ":SessionID", id));
+                       command.ExecuteNonQuery ();
+               }
+
                private IDataParameter CreateParam (IDbCommand command, DbType type,
                                string name, object value)
                {
index deda72d2b8e653cd60e6b0a48a94635e5f835928..936879dce6c1de7a40c2c9ab682a4603572fa3fc 100644 (file)
@@ -60,13 +60,18 @@ namespace System.Web.SessionState {
 
                public void UpdateHandler (HttpContext context, SessionStateModule module)
                {
-                       if (context.Session == null || context.Session.IsReadOnly)
+                       HttpSessionState session = context.Session;
+                       if (session == null || session.IsReadOnly)
                                return;
                        
-                       string id = context.Session.SessionID;
-                       SessionDictionary dict = context.Session.SessionDictionary;
-                       HttpStaticObjectsCollection sobjs = context.Session.StaticObjects;
-                       state_server.Update (id, dict.ToByteArray (), sobjs.ToByteArray ());
+                       string id = session.SessionID;
+                       if (!session._abandoned) {
+                               SessionDictionary dict = session.SessionDictionary;
+                               HttpStaticObjectsCollection sobjs = session.StaticObjects;
+                               state_server.Update (id, dict.ToByteArray (), sobjs.ToByteArray ());
+                       } else {
+                               state_server.Remove (id);
+                       }
                }
 
                public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module,