Skip to content

Instantly share code, notes, and snippets.

@lewurm

lewurm/Main.cs Secret

Last active March 28, 2016 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lewurm/2ccc6dd3057979d5564d to your computer and use it in GitHub Desktop.
Save lewurm/2ccc6dd3057979d5564d to your computer and use it in GitHub Desktop.
bug-38708
class MainClass
{
const int THREADS = 0x5;
static volatile bool stopTheWorld = false;
static volatile bool stopped = false;
public static void trigger ()
{
string longstring = "asdflkjasgakjlsdflaksjdfklajsdfalkdjf1337";
while (longstring.Length < 0x10000)
longstring += longstring;
Console.Error.WriteLine ("starting threads...");
Thread[] threads = new Thread[THREADS];
for (int j = 0; j < threads.Length; j++) {
threads [j] = new Thread (delegate () {
HttpClient c = new HttpClient ();
c.Timeout = new TimeSpan(0, 0, /* Resources.Numbers.NetworkTimeoutLength */ 5);
for (int i = 0; i < 0x4ffff; i++) {
while (stopTheWorld)
Thread.Sleep (1);
// 10.0.25.56 runs a http echo service.
var message = new HttpRequestMessage (new HttpMethod ("POST"), "http://10.0.25.56:8080");
message.Content = new StringContent (longstring, System.Text.UTF8Encoding.Default, "application/json");
WebPostMessageReturnResponse (c, message);
}
});
threads [j].Name = "Echo Service " + j;
threads [j].Start ();
}
new Thread (delegate () {
while (!stopped) {
stopTheWorld = false;
Console.Error.WriteLine ("RUN THE WORLD");
Thread.Sleep (1500);
stopTheWorld = true;
Console.Error.WriteLine ("STOP THE WORLD");
Thread.Sleep (400);
}
}).Start ();
for (int j = 0; j < threads.Length; j++) {
Console.WriteLine ("wait for thread " + j);
threads [j].Join ();
}
stopped = true;
Console.WriteLine ("Bye!");
}
private static HttpResponseMessage WebPostMessageReturnResponse(HttpClient httpClient, HttpRequestMessage message)
{
var response = httpClient.SendAsync (message).Result;
if (CheckStatusCode(response.StatusCode) == false) {
Console.Error.WriteLine ("fail: " + response.ToString());
System.Environment.Exit (2);
}
return response;
}
private static bool CheckStatusCode(HttpStatusCode statusCode)
{
if ((int) statusCode < 200 || (int) statusCode >= 300) {
Console.Error.WriteLine ("Got bad http status code from insights api server: " + (int) statusCode);
return false;
}
return true;
}
}
commit 8b15d99c1fda9997240d5b48d617ab508c08770c
Author: Bernhard Urban <bernhard.urban@xamarin.com>
Date: Mon Mar 28 10:42:50 2016 -0700
change this to make repro happen faster
diff --git a/mcs/class/System/System.Net/ServicePointManager.cs b/mcs/class/System/System.Net/ServicePointManager.cs
index abd23e6..f7d29c2 100644
--- a/mcs/class/System/System.Net/ServicePointManager.cs
+++ b/mcs/class/System/System.Net/ServicePointManager.cs
@@ -116,7 +116,7 @@ namespace System.Net
private static ICertificatePolicy policy;
private static int defaultConnectionLimit = DefaultPersistentConnectionLimit;
- private static int maxServicePointIdleTime = 100000; // 100 seconds
+ private static int maxServicePointIdleTime = 20; // 0.02 seconds
private static int maxServicePoints = 0;
private static int dnsRefreshTimeout = 2 * 60 * 1000;
private static bool _checkCRL = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment