[Mono-bugs] [Bug 78792][Wis] New - HttpListener implementation is subject to extreme threadpool exhaustion

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jul 7 15:54:05 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by grompf at sublimeintervention.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78792

--- shadow/78792	2006-07-07 15:54:04.000000000 -0400
+++ shadow/78792.tmp.13904	2006-07-07 15:54:04.000000000 -0400
@@ -0,0 +1,65 @@
+Bug#: 78792
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: grompf at sublimeintervention.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: HttpListener implementation is subject to extreme threadpool exhaustion
+
+Compile the following testcase:
+
+using System;
+using System.Net;
+
+class T {
+        public static int RequestsHandled = 0;
+        public static void SimpleListenerExample(string[] prefixes)
+        {
+                HttpListener listener = new HttpListener();
+                foreach (string s in prefixes)
+                        listener.Prefixes.Add(s);
+                listener.Start();
+                Console.WriteLine("Listening...");
+
+                listener.BeginGetContext (RequestHandler, listener);
+        }
+
+        public static void RequestHandler (IAsyncResult ar) {
+                Console.WriteLine ("Handling request #{0}...", ++RequestsHandled);
+                HttpListener listener = (HttpListener)ar.AsyncState;
+                listener.BeginGetContext (RequestHandler, listener);
+                HttpListenerContext context = listener.EndGetContext(ar);
+                HttpListenerRequest request = context.Request;
+                HttpListenerResponse response = context.Response;
+                string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
+                byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
+                // Get a response stream and write the response to it.
+                response.ContentLength64 = buffer.Length;
+                System.IO.Stream output = response.OutputStream;
+                output.Write(buffer,0,buffer.Length);
+        }
+
+        static void Main (string [] args) {
+                SimpleListenerExample (new string [] {"http://localhost:8080/index/"});
+                System.Threading.Thread.Sleep (-1);
+        }
+}
+
+In another terminal run:
+ab -n 500 -c 15 http://localhost:8080/index/
+
+Depending on the underlying system threadpool size you will see the httplistener lock up after 
+15-25 concurrent connections (please note concurrency happens because we specifically do not 
+call output.Close ()).  Win32 will exhaust after ~1000 connections.
+
+-g


More information about the mono-bugs mailing list