Re: [Mono-dev] HttpListener hangs with r106513

2008-07-03 Thread Gert Driesen
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:/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://*:/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


Re: [Mono-dev] HttpListener hangs with r106513

2008-07-03 Thread Casey Marshall
On Thu, 2008-07-03 at 10:44 +0200, Gert Driesen wrote:
 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.
 

Works fine now, both in the test case and the real app.

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


Re: [Mono-dev] HttpListener hangs with r106513

2008-07-03 Thread Martin Baulig

On Thu, 2008-07-03 at 10:44 +0200, Gert Driesen wrote:

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

Yeah, I run into the same issue yesterday and Miguel and me finally
figured it out.  Closing the output stream did not close the
HttpResponse, so the connection never shut down.

-- 
Martin Baulig - [EMAIL PROTECTED]
Novell GmbH, Düsseldorf
GF: Volker Smid, Djamel Souici; HRB 21108 (AG Düsseldorf)


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