Created
January 24, 2013 17:26
-
-
Save knocte/4625414 to your computer and use it in GitHub Desktop.
possible solution to http://stackoverflow.com/questions/14461044/concurrency-issue-with-aws-simple-email-service-on-mono/14476243 ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs | |
index 4922fb3..bd505f3 100644 | |
--- a/mcs/class/System/System.Net/WebConnection.cs | |
+++ b/mcs/class/System/System.Net/WebConnection.cs | |
@@ -58,6 +58,7 @@ namespace System.Net | |
object socketLock = new object (); | |
WebExceptionStatus status; | |
WaitCallback initConn; | |
+ Action<HttpWebRequest> initConnDelegate; | |
bool keepAlive; | |
byte [] buffer; | |
static AsyncCallback readDoneDelegate = new AsyncCallback (ReadDone); | |
@@ -109,11 +110,12 @@ namespace System.Net | |
this.sPoint = sPoint; | |
buffer = new byte [4096]; | |
Data = new WebConnectionData (); | |
- initConn = new WaitCallback (state => { | |
+ initConnDelegate = state => { | |
try { | |
InitConnection (state); | |
} catch {} | |
- }); | |
+ }; | |
+ initConn = new WaitCallback (state => initConnDelegate ((HttpWebRequest)state)); | |
queue = group.Queue; | |
abortHelper = new AbortHelper (); | |
abortHelper.Connection = this; | |
@@ -787,7 +789,12 @@ namespace System.Net | |
if (!busy) { | |
busy = true; | |
status = WebExceptionStatus.Success; | |
- ThreadPool.QueueUserWorkItem (initConn, request); | |
+ | |
+ string managed = Environment.GetEnvironmentVariable ("MONO_DISABLE_WEBCONNECTION_THREADPOOL"); | |
+ if (managed == null) | |
+ ThreadPool.QueueUserWorkItem (initConn, request); | |
+ else | |
+ initConnDelegate(request); | |
} else { | |
lock (queue) { | |
#if MONOTOUCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment