2007-09-07 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Fri, 7 Sep 2007 00:26:12 +0000 (00:26 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Fri, 7 Sep 2007 00:26:12 +0000 (00:26 -0000)
            * SessionInProcHandler.cs: properly clone the
            ApplicationState.SessionObjects at the start of the request and
            use the copy when creating new storage items. That way session
            scope static objects are valid within a single session only. Fixes
            bug #82709

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

mcs/class/System.Web/System.Web.SessionState_2.0/ChangeLog
mcs/class/System.Web/System.Web.SessionState_2.0/SessionInProcHandler.cs

index fcbe62bb63360396133404cf329607e288f5ed4a..29bfb6fee788b6a8e0268e6d76bb05f703922768 100644 (file)
@@ -1,3 +1,11 @@
+2007-09-07  Marek Habersack  <mhabersack@novell.com>
+
+       * SessionInProcHandler.cs: properly clone the
+       ApplicationState.SessionObjects at the start of the request and
+       use the copy when creating new storage items. That way session
+       scope static objects are valid within a single session only. Fixes
+       bug #82709
+
 2007-08-14  Marek Habersack  <mhabersack@novell.com>
 
        * SessionStateServerHandler.cs: remove unused field.
index dcd77e9f151e6a437bfcc705f0a8542a26af7b61..4c8b5cefdf75dc581a9fb0ca04ed29c73b42537e 100644 (file)
@@ -2,7 +2,7 @@
 // System.Web.SessionState.SessionInProcHandler
 //
 // Authors:
-//     Marek Habersack <grendello@gmail.com
+//     Marek Habersack <grendello@gmail.com>
 //
 // (C) 2006 Marek Habersack
 //
@@ -50,12 +50,14 @@ namespace System.Web.SessionState
                public Int32 lockId;
                public int timeout;
                public bool resettingTimeout;
+               public HttpStaticObjectsCollection staticItems;
                
                internal InProcSessionItem ()
                {
                        this.locked = false;
                        this.cookieless = false;
                        this.items = null;
+                       this.staticItems = null;
                        this.lockedTime = DateTime.MinValue;
                        this.expiresAt = DateTime.MinValue;
                        this.rwlock = new ReaderWriterLock ();
@@ -73,12 +75,12 @@ namespace System.Web.SessionState
                CacheItemRemovedCallback removedCB;
                //NameValueCollection privateConfig;
                SessionStateItemExpireCallback expireCallback;
-
+               HttpStaticObjectsCollection staticObjects;
+               
                public override SessionStateStoreData CreateNewStoreData (HttpContext context, int timeout)
                {
                        return new SessionStateStoreData (new SessionStateItemCollection (),
-                                                         HttpApplicationFactory.ApplicationState.SessionObjects,
-                                                         timeout);
+                                                         staticObjects, timeout);
                }
 
                void InsertSessionItem (InProcSessionItem item, int timeout, string id)
@@ -155,8 +157,11 @@ namespace System.Web.SessionState
                                        actions = SessionStateActions.InitializeItem;
                                        item.items = new SessionStateItemCollection ();
                                }
+                               if (item.staticItems == null)
+                                       item.staticItems = staticObjects;
+                               
                                return new SessionStateStoreData (item.items,
-                                                                 HttpApplicationFactory.ApplicationState.SessionObjects,
+                                                                 item.staticItems,
                                                                  item.timeout);
                        } catch {
                                // we want such errors to be passed to the application.
@@ -202,7 +207,7 @@ namespace System.Web.SessionState
                
                public override void InitializeRequest (HttpContext context)
                {
-                       // nothing to do here
+                       staticObjects = HttpApplicationFactory.ApplicationState.SessionObjects.Clone ();
                }
                
                public override void ReleaseItemExclusive (HttpContext context,
@@ -302,6 +307,7 @@ namespace System.Web.SessionState
                                inProcItem.rwlock.AcquireWriterLock (lockAcquireTimeout);
                                inProcItem.locked = false;
                                inProcItem.items = item.Items;
+                               inProcItem.staticItems = item.StaticObjects;
                                InsertSessionItem (inProcItem, item.Timeout, CacheId);
                        } catch {
                                throw;
@@ -344,7 +350,7 @@ namespace System.Web.SessionState
                                        expireCallback (key,
                                                        new SessionStateStoreData (
                                                                item.items,
-                                                               HttpApplicationFactory.ApplicationState.SessionObjects,
+                                                               item.staticItems,
                                                                item.timeout));
                                } else
                                        expireCallback (key, null);