Forráskód Böngészése

Adapt to new exception in threadpool behavior.

	Since an exception in the threadpool can kill the application,
	silently ignore it when we know it is not harmful.
Gonzalo Paniagua Javier 15 éve
szülő
commit
eb2a5490f2

+ 5 - 1
mcs/class/Mono.Posix/Mono.Remoting.Channels.Unix/UnixClientTransportSink.cs

@@ -87,7 +87,11 @@ namespace Mono.Remoting.Channels.Unix
 				if (!isOneWay) 
 				{
 					sinkStack.Push (this, connection);
-					ThreadPool.QueueUserWorkItem (new WaitCallback(ReadAsyncUnixMessage), sinkStack);
+					ThreadPool.QueueUserWorkItem (new WaitCallback(data => {
+						try {
+							ReadAsyncUnixMessage (data);
+						} catch {}
+						}), sinkStack);
 				}
 				else
 					connection.Release();

+ 5 - 1
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientTransportSink.cs

@@ -99,7 +99,11 @@ namespace System.Runtime.Remoting.Channels.Tcp
 				if (!isOneWay) 
 				{
 					sinkStack.Push (this, connection);
-					ThreadPool.QueueUserWorkItem (new WaitCallback(ReadAsyncTcpMessage), sinkStack);
+					ThreadPool.QueueUserWorkItem (new WaitCallback(data => {
+						try {
+							ReadAsyncTcpMessage (data);
+						} catch {}
+						}), sinkStack);
 				}
 				else
 					connection.Release();

+ 5 - 1
mcs/class/System.Web/System.Web/HttpRuntime.cs

@@ -154,7 +154,11 @@ namespace System.Web
 			internalCache = new Cache ();
 			internalCache.DependencyCache = internalCache;
 #endif
-			do_RealProcessRequest = new WaitCallback (RealProcessRequest);
+			do_RealProcessRequest = new WaitCallback (state => {
+				try {
+					RealProcessRequest (state);
+				} catch {}
+				});
 		}
 		
 #region AppDomain handling

+ 3 - 1
mcs/class/System.Web/Test/TestMonoWeb/AsyncOperation.cs

@@ -36,7 +36,9 @@ namespace TestMonoWeb
 			// Just for testing..
 			Thread.Sleep(100);
 			_completed = true;
-			_callback(this);
+			try {
+				_callback(this);
+			} catch {}
 		}
 	}
 }

+ 5 - 1
mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs

@@ -35,7 +35,11 @@ namespace MonoTests.SystemWeb.Framework
 		{
 			_done = new AutoResetEvent (false);
 			_doNext = new AutoResetEvent (false);
-			ThreadPool.QueueUserWorkItem (new WaitCallback (AsyncRun), null);
+			ThreadPool.QueueUserWorkItem (new WaitCallback (param => {
+				try {
+					AsyncRun (param);
+				} catch {}
+				}), null);
 		}
 
 		public AppDomain AppDomain

+ 5 - 1
mcs/class/System/System.Net/WebConnection.cs

@@ -100,7 +100,11 @@ namespace System.Net
 			buffer = new byte [4096];
 			readState = ReadState.None;
 			Data = new WebConnectionData ();
-			initConn = new WaitCallback (InitConnection);
+			initConn = new WaitCallback (state => {
+				try {
+					InitConnection (state);
+				} catch {}
+				});
 			queue = group.Queue;
 			abortHelper = new AbortHelper ();
 			abortHelper.Connection = this;

+ 6 - 1
mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs

@@ -267,7 +267,12 @@ namespace System.Runtime.Remoting.Channels
 		public virtual IMessageCtrl AsyncProcessMessage (IMessage reqMsg, IMessageSink replySink) 
 		{
 			AsyncRequest req = new AsyncRequest (reqMsg, replySink);
-			ThreadPool.QueueUserWorkItem (new WaitCallback (SendAsyncMessage), req);
+			ThreadPool.QueueUserWorkItem (new WaitCallback ((data) => {
+				try {
+					SendAsyncMessage (data);
+				} catch {}
+				}
+				), req);
 			return null;
 		}
 		

+ 6 - 1
mcs/class/corlib/System.Runtime.Remoting.Messaging/StackBuilderSink.cs

@@ -62,7 +62,12 @@ namespace System.Runtime.Remoting.Messaging
 		public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
 		{
 			object[] parms = new object[] {msg, replySink};
-			ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteAsyncMessage), parms);
+			ThreadPool.QueueUserWorkItem (new WaitCallback ((data) => {
+				try {
+					ExecuteAsyncMessage (data);
+				} catch {}
+				}
+				), parms);
 			return null;
 		}
 		

+ 5 - 2
mcs/class/corlib/System.Threading/RegisteredWaitHandle.cs

@@ -88,8 +88,11 @@ namespace System.Threading
 
 		private void DoCallBack (object timedOut)
 		{
-			if (_callback != null)
-				_callback (_state, (bool)timedOut); 
+			if (_callback != null) {
+				try {
+					_callback (_state, (bool)timedOut); 
+				} catch {}
+			}
 
 			lock (this) 
 			{

+ 5 - 1
mcs/class/corlib/System.Threading/Timer.cs

@@ -288,7 +288,11 @@ namespace System.Threading
 							list.RemoveAt (i);
 							count--;
 							i--;
-							ThreadPool.QueueUserWorkItem (new WaitCallback (timer.callback), timer.state);
+							ThreadPool.QueueUserWorkItem (new WaitCallback (data => {
+								try {
+									timer.callback (data);
+								} catch {}
+								}), timer.state);
 							long period = timer.period_ms;
 							long due_time = timer.due_time_ms;
 							bool no_more = (period == -1 || ((period == 0 || period == Timeout.Infinite) && due_time != Timeout.Infinite));