2005-01-14 Lluis Sanchez Gual <lluis@novell.com>
authorLluis Sanchez <lluis@novell.com>
Fri, 14 Jan 2005 17:29:00 +0000 (17:29 -0000)
committerLluis Sanchez <lluis@novell.com>
Fri, 14 Jan 2005 17:29:00 +0000 (17:29 -0000)
* HttpServerChannel.cs: Use the new RemotingThreadPool to manage threads.
  Fixed some warnings.
* HttpServer.cs: Minor fix.

svn path=/trunk/mcs/; revision=38947

mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/ChangeLog
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServer.cs
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Http/HttpServerChannel.cs

index 0107b17c464122f8ff7ffcd6240424e7f2c6311b..a76114831a85a4ce5d344bd20b68f4b8ddf8ef77 100644 (file)
@@ -1,3 +1,9 @@
+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.
index 3c60866951857254dbd97cae7c37c7cc5496bbd5..ee09b2b84c38d0a92f3276369e72c0b4bb5590c5 100644 (file)
@@ -59,6 +59,11 @@ namespace System.Runtime.Remoting.Channels.Http
                        Sink = sink;
                }
                
+               public void Process ()
+               {
+                       HttpServer.ProcessRequest (this);
+               }
+               
                public Stream InputStream;
                public Stream OutputStream;
                public HttpServerTransportSink Sink;
@@ -66,13 +71,8 @@ namespace System.Runtime.Remoting.Channels.Http
 
        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);
                                
index e069ee8d0ebb12ad73b20509ac3e54b739f2f16d..37c1611a157de1358f36ee5c4562a75e81779dbd 100644 (file)
@@ -74,8 +74,8 @@ namespace System.Runtime.Remoting.Channels.Http
                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()
                {
@@ -184,18 +184,20 @@ namespace System.Runtime.Remoting.Channels.Http
                        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)
                {
-                       _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;
@@ -222,6 +224,7 @@ namespace System.Runtime.Remoting.Channels.Http
                        {
                                _listenerThread.Abort ();
                                _tcpListener.Stop();
+                               threadPool.Free ();
                        }
 
                        _bListening = false;
@@ -302,8 +305,6 @@ namespace System.Runtime.Remoting.Channels.Http
                
                public void AddHookChannelUri (String channelUri)
                {
-                       string [] uris = _channelData.ChannelUris;
-                       
                        string [] newUris = new string[1] { channelUri };
                        _channelData.ChannelUris = newUris;
                        _wantsToListen = false;
@@ -366,7 +367,6 @@ namespace System.Runtime.Remoting.Channels.Http
                        }
                        catch (Exception ex)
                        {
-                               Console.WriteLine (ex);
                        }
                }