Hello,

Most of the time, Application_End in global.asax is called multiple
times for a single ending application. The problem is in
HttpApplicationFactory.OnFileChanged: the lock guards the method against
multiple _concurrent_ shutdowns only. It can still execute multiple
times sequentially (FileSystemWatcher emits multiple events when
global.asax is changed).

The attached patch fixes that.

Please review.

- Juraj
Index: HttpApplicationFactory.cs
===================================================================
--- HttpApplicationFactory.cs	(revision 75126)
+++ HttpApplicationFactory.cs	(working copy)
@@ -77,6 +77,7 @@
 		Hashtable app_event_handlers;
 		static ArrayList watchers = new ArrayList();
 		static object watchers_lock = new object();
+		static bool app_shutdown = false;
 		Stack available = new Stack ();
 		Stack available_for_end = new Stack ();
 		
@@ -539,6 +540,10 @@
 	        static void OnFileChanged(object sender, FileSystemEventArgs args)
 	        {
 	        	lock (watchers_lock) {
+				if(app_shutdown)
+					return;
+				app_shutdown = true;
+
 				// Disable event raising to avoid concurrent restarts
 				foreach (FileSystemWatcher watcher in watchers) {
 					watcher.EnableRaisingEvents = false;
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to