Hey Casey,

Miguel prepared a fix for this issue (committed by Martin in r107127), and
I've added a unit test based on your repro.

Gert

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Casey
Marshall
Sent: woensdag 25 juni 2008 1:05
To: mono-devel
Subject: [Mono-dev] HttpListener hangs with r106513

I've noticed that it recent SVN mono snapshots (r106513) using
HttpListener and WebRequest in the same process hangs. This doesn't hang
with 1.9.1, and didn't with less recent snapshots.

I haven't tried having the client and server in different processes, and
don't know if it reproduces there.

Test case:


using System;
using System.IO;
using System.Net;
using System.Threading;

class simplehttp
{
        public static void Main(string[] argv)
        {
                simplehttp sh = new simplehttp();
                Thread srv = new Thread(new ThreadStart(sh.ServerMain));
                srv.Name = "HttpServer";
                srv.Start();

                for (;;)
                {
                        HttpWebRequest req = (HttpWebRequest)
WebRequest.Create ("http://localhost:8888/foobar/";);
                        req.ServicePoint.Expect100Continue = false;
                        req.ServicePoint.UseNagleAlgorithm = false;
                        req.Method = "POST";
                        StreamWriter w = new
StreamWriter(req.GetRequestStream());
                        w.WriteLine("Hello, server!");
                        w.Close();

                        HttpWebResponse resp = (HttpWebResponse)
req.GetResponse();
                        StreamReader r = new
StreamReader(resp.GetResponseStream());
                        System.Console.WriteLine("client reads: {0}",
r.ReadToEnd());
                        r.Close();
                }
        }

        private void ServerMain()
        {
                HttpListener listener = new HttpListener();
                listener.Prefixes.Add("http://*:8888/foobar/";);
                listener.Start();
                while (true)
                {
                        HttpListenerContext ctx = listener.GetContext();
                        ThreadPool.QueueUserWorkItem(new
WaitCallback(HandleConnection), ctx);
                }
        }

        private void HandleConnection(object state)
        {
                HttpListenerContext ctx = (HttpListenerContext) state;
                HttpListenerRequest req = ctx.Request;
                StreamReader r = new StreamReader(req.InputStream);
                System.Console.WriteLine ("server reads {0}",
r.ReadToEnd());

                HttpListenerResponse resp = ctx.Response;
                StreamWriter o = new StreamWriter(resp.OutputStream);
                o.WriteLine("Hello, world!");
                o.Close();
        }
}

Thanks.
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to