Commit d037f771 authored by justcoding121's avatar justcoding121

cleanup

parent 4790102c
......@@ -52,14 +52,11 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// </summary>
public void Dispose()
{
Stream.Close();
Stream.Dispose();
Stream?.Close();
Stream?.Dispose();
StreamReader?.Dispose();
TcpClient.LingerState = new LingerOption(true, 0);
TcpClient.Client.Shutdown(SocketShutdown.Both);
TcpClient.Client.Close();
TcpClient.Client.Dispose();
TcpClient.Close();
}
......
......@@ -629,11 +629,6 @@ namespace Titanium.Web.Proxy
//It helps to avoid eventual deterioration of performance due to TCP port exhaustion
//due to default TCP CLOSE_WAIT timeout for 4 minutes
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();
}
}
......
......@@ -50,7 +50,7 @@ namespace Titanium.Web.Proxy
await Task.WhenAll(handlerTasks);
}
if(args.ReRequest)
if (args.ReRequest)
{
await HandleHttpSessionRequestInternal(null, args, null, null, true);
return;
......@@ -124,7 +124,7 @@ namespace Titanium.Web.Proxy
await args.ProxyClient.ClientStream.FlushAsync();
}
catch(Exception e)
catch (Exception e)
{
ExceptionFunc(new ProxyHttpException("Error occured wilst handling session response", e, args));
Dispose(args.ProxyClient.ClientStream, args.ProxyClient.ClientStreamReader,
......@@ -231,20 +231,15 @@ namespace Titanium.Web.Proxy
private void Dispose(Stream clientStream, CustomBinaryReader clientStreamReader,
StreamWriter clientStreamWriter, IDisposable args)
{
if (clientStream != null)
{
clientStream.Close();
clientStream.Dispose();
}
args?.Dispose();
clientStream?.Close();
clientStream?.Dispose();
clientStreamReader?.Dispose();
if (clientStreamWriter == null) return;
clientStreamWriter.Close();
clientStreamWriter.Dispose();
clientStreamWriter?.Close();
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