From a9b8cfa58212afc94b93751b53d93acd848b465d Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Thu, 20 Aug 2015 11:50:38 -0700 Subject: [PATCH] Remove unnecessary use of generics in listeners --- .../Http/Listener.cs | 13 ++++++------- .../Http/ListenerPrimary.cs | 6 +++--- .../Http/ListenerSecondary.cs | 4 ++-- .../Http/PipeListener.cs | 8 ++++---- .../Http/PipeListenerPrimary.cs | 8 ++++---- .../Http/PipeListenerSecondary.cs | 6 +++--- .../Http/TcpListener.cs | 8 ++++---- .../Http/TcpListenerPrimary.cs | 8 ++++---- .../Http/TcpListenerSecondary.cs | 6 +++--- 9 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs index dd0d6f0228..55d8d8dc93 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs @@ -11,10 +11,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Base class for listeners in Kestrel. Listens for incoming connections /// - /// Type of socket used by this listener - public abstract class Listener : ListenerContext, IListener where T : UvStreamHandle + public abstract class Listener : ListenerContext, IListener { - protected T ListenSocket { get; private set; } + protected UvStreamHandle ListenSocket { get; private set; } protected static void ConnectionCallback(UvStreamHandle stream, int status, Exception error, object state) { @@ -24,7 +23,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - ((Listener)state).OnConnection((T)stream, status); + ((Listener)state).OnConnection(stream, status); } } @@ -62,16 +61,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates the socket used to listen for incoming connections /// - protected abstract T CreateListenSocket(string host, int port); + protected abstract UvStreamHandle CreateListenSocket(string host, int port); /// /// Handles an incoming connection /// /// Socket being used to listen on /// Connection status - protected abstract void OnConnection(T listenSocket, int status); + protected abstract void OnConnection(UvStreamHandle listenSocket, int status); - protected virtual void DispatchConnection(T socket) + protected virtual void DispatchConnection(UvStreamHandle socket) { var connection = new Connection(this, socket); connection.Start(); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs index c534affe49..df4fdb09fa 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// A primary listener waits for incoming connections on a specified socket. Incoming /// connections may be passed to a secondary listener to handle. /// - abstract public class ListenerPrimary : Listener, IListenerPrimary where T : UvStreamHandle + abstract public class ListenerPrimary : Listener, IListenerPrimary { UvPipeHandle ListenPipe { get; set; } @@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http _dispatchPipes.Add(dispatchPipe); } - protected override void DispatchConnection(T socket) + protected override void DispatchConnection(UvStreamHandle socket) { var index = _dispatchIndex++ % (_dispatchPipes.Count + 1); if (index == _dispatchPipes.Count) @@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http (write2, status, error, state) => { write2.Dispose(); - ((T)state).Dispose(); + ((UvStreamHandle)state).Dispose(); }, socket); } diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerSecondary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerSecondary.cs index 32c7109553..1ca3c9b193 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerSecondary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerSecondary.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// A secondary listener is delegated requests from a primary listener via a named pipe or /// UNIX domain socket. /// - public abstract class ListenerSecondary : ListenerContext, IListenerSecondary where T : UvStreamHandle + public abstract class ListenerSecondary : ListenerContext, IListenerSecondary { UvPipeHandle DispatchPipe { get; set; } @@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates a socket which can be used to accept an incoming connection /// - protected abstract T CreateAcceptSocket(); + protected abstract UvStreamHandle CreateAcceptSocket(); public void Dispose() { diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListener.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListener.cs index 64e732acaa..15b43c78b6 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListener.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListener.cs @@ -7,9 +7,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking; namespace Microsoft.AspNet.Server.Kestrel.Http { /// - /// Implementation of that uses UNIX domain sockets as its transport. + /// Implementation of that uses UNIX domain sockets as its transport. /// - public class PipeListener : Listener + public class PipeListener : Listener { public PipeListener(IMemoryPool memory) : base(memory) { @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates the socket used to listen for incoming connections /// - protected override UvPipeHandle CreateListenSocket(string host, int port) + protected override UvStreamHandle CreateListenSocket(string host, int port) { var socket = new UvPipeHandle(); socket.Init(Thread.Loop, false); @@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Socket being used to listen on /// Connection status - protected override void OnConnection(UvPipeHandle listenSocket, int status) + protected override void OnConnection(UvStreamHandle listenSocket, int status) { var acceptSocket = new UvPipeHandle(); acceptSocket.Init(Thread.Loop, false); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerPrimary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerPrimary.cs index bcfb705fef..3ee7f501bc 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerPrimary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerPrimary.cs @@ -7,9 +7,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking; namespace Microsoft.AspNet.Server.Kestrel.Http { /// - /// An implementation of using UNIX sockets. + /// An implementation of using UNIX sockets. /// - public class PipeListenerPrimary : ListenerPrimary + public class PipeListenerPrimary : ListenerPrimary { public PipeListenerPrimary(IMemoryPool memory) : base(memory) { @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates the socket used to listen for incoming connections /// - protected override UvPipeHandle CreateListenSocket(string host, int port) + protected override UvStreamHandle CreateListenSocket(string host, int port) { var socket = new UvPipeHandle(); socket.Init(Thread.Loop, false); @@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Socket being used to listen on /// Connection status - protected override void OnConnection(UvPipeHandle listenSocket, int status) + protected override void OnConnection(UvStreamHandle listenSocket, int status) { var acceptSocket = new UvPipeHandle(); acceptSocket.Init(Thread.Loop, false); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerSecondary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerSecondary.cs index 58f6d4d4b6..81d70485bf 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerSecondary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/PipeListenerSecondary.cs @@ -6,9 +6,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking; namespace Microsoft.AspNet.Server.Kestrel.Http { /// - /// An implementation of using UNIX sockets. + /// An implementation of using UNIX sockets. /// - public class PipeListenerSecondary : ListenerSecondary + public class PipeListenerSecondary : ListenerSecondary { public PipeListenerSecondary(IMemoryPool memory) : base(memory) { @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates a socket which can be used to accept an incoming connection /// - protected override UvPipeHandle CreateAcceptSocket() + protected override UvStreamHandle CreateAcceptSocket() { var acceptSocket = new UvPipeHandle(); acceptSocket.Init(Thread.Loop, false); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListener.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListener.cs index 294674b746..54739b725d 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListener.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListener.cs @@ -8,9 +8,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking; namespace Microsoft.AspNet.Server.Kestrel.Http { /// - /// Implementation of that uses TCP sockets as its transport. + /// Implementation of that uses TCP sockets as its transport. /// - public class TcpListener : Listener + public class TcpListener : Listener { public TcpListener(IMemoryPool memory) : base(memory) { @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates the socket used to listen for incoming connections /// - protected override UvTcpHandle CreateListenSocket(string host, int port) + protected override UvStreamHandle CreateListenSocket(string host, int port) { var socket = new UvTcpHandle(); socket.Init(Thread.Loop, Thread.QueueCloseHandle); @@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Socket being used to listen on /// Connection status - protected override void OnConnection(UvTcpHandle listenSocket, int status) + protected override void OnConnection(UvStreamHandle listenSocket, int status) { var acceptSocket = new UvTcpHandle(); acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerPrimary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerPrimary.cs index 8242d7d403..8a9546fdd8 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerPrimary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerPrimary.cs @@ -8,9 +8,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking; namespace Microsoft.AspNet.Server.Kestrel.Http { /// - /// An implementation of using TCP sockets. + /// An implementation of using TCP sockets. /// - public class TcpListenerPrimary : ListenerPrimary + public class TcpListenerPrimary : ListenerPrimary { public TcpListenerPrimary(IMemoryPool memory) : base(memory) { @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates the socket used to listen for incoming connections /// - protected override UvTcpHandle CreateListenSocket(string host, int port) + protected override UvStreamHandle CreateListenSocket(string host, int port) { var socket = new UvTcpHandle(); socket.Init(Thread.Loop, Thread.QueueCloseHandle); @@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Socket being used to listen on /// Connection status - protected override void OnConnection(UvTcpHandle listenSocket, int status) + protected override void OnConnection(UvStreamHandle listenSocket, int status) { var acceptSocket = new UvTcpHandle(); acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerSecondary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerSecondary.cs index c7ec374c64..5e125c0276 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerSecondary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/TcpListenerSecondary.cs @@ -6,9 +6,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking; namespace Microsoft.AspNet.Server.Kestrel.Http { /// - /// An implementation of using TCP sockets. + /// An implementation of using TCP sockets. /// - public class TcpListenerSecondary : ListenerSecondary + public class TcpListenerSecondary : ListenerSecondary { public TcpListenerSecondary(IMemoryPool memory) : base(memory) { @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// Creates a socket which can be used to accept an incoming connection /// - protected override UvTcpHandle CreateAcceptSocket() + protected override UvStreamHandle CreateAcceptSocket() { var acceptSocket = new UvTcpHandle(); acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);