[Mono-devel-list] Patch for proper cache destruction when HttpRuntime is disposed
Eyal Alaluf
eyala at mainsoft.com
Tue Jul 26 08:19:15 EDT 2005
Hi, Gonzalo & all.
The attached patch disposes the timer thread when the HttpRuntime goes down. It is done only
under TARGET_J2EE for now. My guess is that when the HttpRuntime goes down in Mono it goes
down with the app domain and this disposes the thread. But if not (as is the case for TARGET_J2EE),
the timer thread will keep the application alive since it keeps referencing the cache and
its entries.
Please review and let me know if the patch makes sense in the Mono context as well or it
should stay with '#if TARGET_j2EE'.
Eyal.
-------------- next part --------------
Index: System.Web/ChangeLog
===================================================================
--- System.Web/ChangeLog (revision 47652)
+++ System.Web/ChangeLog (working copy)
@@ -1,3 +1,6 @@
+2005-07-26 Eyal Alalouf <eyala at mainsoft.com>
+ * HttpRuntime.cs: Under TARGET_J2EE dispose the cache as well in Dispose.
+
2005-07-25 Eyal Alalouf <eyala at mainsoft.com>
* HttpContext.cs HttpRuntime.cs HttpApplication.cs: timeout is not supported
in TARGET_J2EE configuration (no Thread.Abort support).
Index: System.Web/HttpRuntime.cs
===================================================================
--- System.Web/HttpRuntime.cs (revision 47652)
+++ System.Web/HttpRuntime.cs (working copy)
@@ -283,6 +283,9 @@
if (queueManager != null)
queueManager.Dispose (); // Send a 503 to all queued requests
queueManager = null;
+#if TARGET_J2EE
+ _cache.Destroy();
+#endif
_cache = null;
HttpApplicationFactory.EndApplication();
}
Index: System.Web.Caching/Cache.cs
===================================================================
--- System.Web.Caching/Cache.cs (revision 47365)
+++ System.Web.Caching/Cache.cs (working copy)
@@ -57,6 +57,14 @@
_objExpires = new CacheExpires (this);
}
+#if TARGET_J2EE
+ internal void Destroy()
+ {
+ _arrEntries = null;
+ _objExpires.Close();
+ }
+#endif
+
private IDictionaryEnumerator CreateEnumerator () {
Hashtable objTable;
Index: System.Web.Caching/CacheExpires.cs
===================================================================
--- System.Web.Caching/CacheExpires.cs (revision 47365)
+++ System.Web.Caching/CacheExpires.cs (working copy)
@@ -75,6 +75,14 @@
_objTimer = new System.Threading.Timer (new System.Threading.TimerCallback (GarbageCleanup), null, 10000, 60000);
}
+#if TARGET_J2EE
+ internal void Close()
+ {
+ _arrBuckets = null;
+ _objTimer.Dispose();
+ }
+#endif
+
/// <summary>
/// Adds a Cache entry to the correct flush bucket.
/// </summary>
Index: System.Web.Caching/ChangeLog
===================================================================
--- System.Web.Caching/ChangeLog (revision 47645)
+++ System.Web.Caching/ChangeLog (working copy)
@@ -1,3 +1,6 @@
+2005-07-26 Eyal Alaluf <eyala at mainsoft.com>
+ * Cache.cs CacheExpires.cs: In TARGET_j2EE dispose the timer thread when done.
+
2005-07-25 Eyal Alaluf <eyala at mainsoft.com>
* ExpiresBuckets.cs: Removed unused field (that if used would lead to
serious runtime errors).
More information about the Mono-devel-list
mailing list