Commit bf4921a0 authored by justcoding121's avatar justcoding121

#231 Fix server count; don't dispose twice

parent fe08a1fb
This diff is collapsed.
...@@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy ...@@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy
/// Called asynchronously when a request was successfully and we received the response /// Called asynchronously when a request was successfully and we received the response
/// </summary> /// </summary>
/// <param name="args"></param> /// <param name="args"></param>
/// <returns>true if no errors</returns> /// <returns>true if client/server connection was terminated (and disposed) </returns>
private async Task<bool> HandleHttpSessionResponse(SessionEventArgs args) private async Task<bool> HandleHttpSessionResponse(SessionEventArgs args)
{ {
try try
...@@ -130,12 +130,12 @@ namespace Titanium.Web.Proxy ...@@ -130,12 +130,12 @@ namespace Titanium.Web.Proxy
Dispose(args.ProxyClient.ClientStream, args.ProxyClient.ClientStreamReader, Dispose(args.ProxyClient.ClientStream, args.ProxyClient.ClientStreamReader,
args.ProxyClient.ClientStreamWriter, args.WebSession.ServerConnection); args.ProxyClient.ClientStreamWriter, args.WebSession.ServerConnection);
return false; return true;
} }
args.Dispose(); args.Dispose();
return true; return false;
} }
/// <summary> /// <summary>
...@@ -233,15 +233,18 @@ namespace Titanium.Web.Proxy ...@@ -233,15 +233,18 @@ namespace Titanium.Web.Proxy
StreamWriter clientStreamWriter, StreamWriter clientStreamWriter,
TcpConnection serverConnection) TcpConnection serverConnection)
{ {
Interlocked.Decrement(ref ServerConnectionCountField);
clientStream?.Close(); clientStream?.Close();
clientStream?.Dispose(); clientStream?.Dispose();
clientStreamReader?.Dispose(); clientStreamReader?.Dispose();
clientStreamWriter?.Dispose(); clientStreamWriter?.Dispose();
serverConnection?.Dispose(); if (serverConnection != null)
{
serverConnection.Dispose();
Interlocked.Decrement(ref ServerConnectionCountField);
}
} }
} }
} }
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