Commit d037f771 authored by justcoding121's avatar justcoding121

cleanup

parent 4790102c
...@@ -52,14 +52,11 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -52,14 +52,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
Stream.Close(); Stream?.Close();
Stream.Dispose(); Stream?.Dispose();
StreamReader?.Dispose();
TcpClient.LingerState = new LingerOption(true, 0); TcpClient.LingerState = new LingerOption(true, 0);
TcpClient.Client.Shutdown(SocketShutdown.Both);
TcpClient.Client.Close();
TcpClient.Client.Dispose();
TcpClient.Close(); TcpClient.Close();
} }
......
...@@ -629,11 +629,6 @@ namespace Titanium.Web.Proxy ...@@ -629,11 +629,6 @@ namespace Titanium.Web.Proxy
//It helps to avoid eventual deterioration of performance due to TCP port exhaustion //It helps to avoid eventual deterioration of performance due to TCP port exhaustion
//due to default TCP CLOSE_WAIT timeout for 4 minutes //due to default TCP CLOSE_WAIT timeout for 4 minutes
tcpClient.LingerState = new LingerOption(true, 0); tcpClient.LingerState = new LingerOption(true, 0);
//the following 3 lines are unnecessary, tcpClient.Close() calls all of them internally
//tcpClient.Client.Shutdown(SocketShutdown.Both);
//tcpClient.Client.Close();
//tcpClient.Client.Dispose();
tcpClient.Close(); tcpClient.Close();
} }
} }
......
...@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy ...@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy
await Task.WhenAll(handlerTasks); await Task.WhenAll(handlerTasks);
} }
if(args.ReRequest) if (args.ReRequest)
{ {
await HandleHttpSessionRequestInternal(null, args, null, null, true); await HandleHttpSessionRequestInternal(null, args, null, null, true);
return; return;
...@@ -124,7 +124,7 @@ namespace Titanium.Web.Proxy ...@@ -124,7 +124,7 @@ namespace Titanium.Web.Proxy
await args.ProxyClient.ClientStream.FlushAsync(); await args.ProxyClient.ClientStream.FlushAsync();
} }
catch(Exception e) catch (Exception e)
{ {
ExceptionFunc(new ProxyHttpException("Error occured wilst handling session response", e, args)); ExceptionFunc(new ProxyHttpException("Error occured wilst handling session response", e, args));
Dispose(args.ProxyClient.ClientStream, args.ProxyClient.ClientStreamReader, Dispose(args.ProxyClient.ClientStream, args.ProxyClient.ClientStreamReader,
...@@ -231,20 +231,15 @@ namespace Titanium.Web.Proxy ...@@ -231,20 +231,15 @@ namespace Titanium.Web.Proxy
private void Dispose(Stream clientStream, CustomBinaryReader clientStreamReader, private void Dispose(Stream clientStream, CustomBinaryReader clientStreamReader,
StreamWriter clientStreamWriter, IDisposable args) StreamWriter clientStreamWriter, IDisposable args)
{ {
clientStream?.Close();
if (clientStream != null) clientStream?.Dispose();
{
clientStream.Close();
clientStream.Dispose();
}
args?.Dispose();
clientStreamReader?.Dispose(); clientStreamReader?.Dispose();
if (clientStreamWriter == null) return; clientStreamWriter?.Close();
clientStreamWriter.Close(); clientStreamWriter?.Dispose();
clientStreamWriter.Dispose();
args?.Dispose();
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment