* HttpServerChannel.cs: Use the new RemotingThreadPool to manage threads.
Fixed some warnings.
* HttpServer.cs: Minor fix.
svn path=/trunk/mcs/; revision=38947
+2005-01-14 Lluis Sanchez Gual <lluis@novell.com>
+
+ * HttpServerChannel.cs: Use the new RemotingThreadPool to manage threads.
+ Fixed some warnings.
+ * HttpServer.cs: Minor fix.
+
2004-12-17 Lluis Sanchez Gual <lluis@ximian.com>
* HttpHelper.cs: Removed unused method. Optimized CopyStream method.
2004-12-17 Lluis Sanchez Gual <lluis@ximian.com>
* HttpHelper.cs: Removed unused method. Optimized CopyStream method.
+ public void Process ()
+ {
+ HttpServer.ProcessRequest (this);
+ }
+
public Stream InputStream;
public Stream OutputStream;
public HttpServerTransportSink Sink;
public Stream InputStream;
public Stream OutputStream;
public HttpServerTransportSink Sink;
internal sealed class HttpServer
{
internal sealed class HttpServer
{
- public static void ProcessRequest (object reqInfo)
+ public static void ProcessRequest (RequestArguments reqArg)
- if(reqInfo as RequestArguments == null)
- return;
-
- RequestArguments reqArg = (RequestArguments)reqInfo;
-
//Step (1) Start Reciceve the header
ArrayList Headers = RecieveHeader (reqArg);
//Step (1) Start Reciceve the header
ArrayList Headers = RecieveHeader (reqArg);
private TcpListener _tcpListener;
private Thread _listenerThread;
private bool _bListening = false; // are we listening at the moment?
private TcpListener _tcpListener;
private Thread _listenerThread;
private bool _bListening = false; // are we listening at the moment?
- // to start listening, that will get set here.
- private AutoResetEvent _waitForStartListening = new AutoResetEvent(false);
+
+ RemotingThreadPool threadPool;
public HttpServerChannel() : base()
{
public HttpServerChannel() : base()
{
while(true)
{
Socket socket = _tcpListener.AcceptSocket();
while(true)
{
Socket socket = _tcpListener.AcceptSocket();
- RequestArguments reqArg = new RequestArguments (socket, _transportSink);
- ThreadPool.QueueUserWorkItem (new WaitCallback (HttpServer.ProcessRequest), reqArg);
+ RequestArguments request = new RequestArguments (socket, _transportSink);
+ threadPool.RunThread (new ThreadStart (request.Process));
public void StartListening (Object data)
{
public void StartListening (Object data)
{
- _tcpListener = new TcpListener (_bindToAddr, _port);
+ if (_bListening) return;
+
+ threadPool = RemotingThreadPool.GetSharedPool ();
- if(!_bListening)
- _tcpListener.Start();
+ _tcpListener = new TcpListener (_bindToAddr, _port);
+ _tcpListener.Start();
if (_port == 0) {
_port = ((IPEndPoint)_tcpListener.LocalEndpoint).Port;
if (_port == 0) {
_port = ((IPEndPoint)_tcpListener.LocalEndpoint).Port;
{
_listenerThread.Abort ();
_tcpListener.Stop();
{
_listenerThread.Abort ();
_tcpListener.Stop();
public void AddHookChannelUri (String channelUri)
{
public void AddHookChannelUri (String channelUri)
{
- string [] uris = _channelData.ChannelUris;
-
string [] newUris = new string[1] { channelUri };
_channelData.ChannelUris = newUris;
_wantsToListen = false;
string [] newUris = new string[1] { channelUri };
_channelData.ChannelUris = newUris;
_wantsToListen = false;
- Console.WriteLine (ex);