Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d2b534

Browse files
committed
finalizers
1 parent 75ff631 commit 9d2b534

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public void TerminateServerConnection()
684684
HttpClient.CloseServerConnection = true;
685685
}
686686

687-
private bool disposed = false;
687+
private bool disposed;
688688

689689
protected override void Dispose(bool disposing)
690690
{
@@ -701,6 +701,11 @@ protected override void Dispose(bool disposing)
701701

702702
~SessionEventArgs()
703703
{
704+
#if DEBUG
705+
// Finalizer should not be called
706+
System.Diagnostics.Debugger.Break();
707+
#endif
708+
704709
Dispose(false);
705710
}
706711
}

src/Titanium.Web.Proxy/EventArguments/SessionEventArgsBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ public void Dispose()
181181

182182
~SessionEventArgsBase()
183183
{
184+
#if DEBUG
185+
// Finalizer should not be called
186+
System.Diagnostics.Debugger.Break();
187+
#endif
188+
184189
Dispose(false);
185190
}
186191

src/Titanium.Web.Proxy/EventArguments/TunnelConnectEventArgs.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,15 @@ internal void OnDecryptedDataReceived(byte[] buffer, int offset, int count)
7575
ExceptionFunc(new Exception("Exception thrown in user event", ex));
7676
}
7777
}
78+
79+
~TunnelConnectSessionEventArgs()
80+
{
81+
#if DEBUG
82+
// Finalizer should not be called
83+
System.Diagnostics.Debugger.Break();
84+
#endif
85+
86+
Dispose(false);
87+
}
7888
}
7989
}

src/Titanium.Web.Proxy/ExplicitClientHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
3838
Task<TcpServerConnection?>? prefetchConnectionTask = null;
3939
bool closeServerConnection = false;
4040

41+
TunnelConnectSessionEventArgs? connectArgs = null;
42+
4143
try
4244
{
43-
TunnelConnectSessionEventArgs? connectArgs = null;
44-
4545
var method = await HttpHelper.GetMethod(clientStream, BufferPool, cancellationToken);
4646
if (clientStream.IsClosed)
4747
{
@@ -402,6 +402,7 @@ await Http2Helper.SendHttp2(clientStream, connection.Stream,
402402
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
403403

404404
clientStream.Dispose();
405+
connectArgs?.Dispose();
405406
}
406407
}
407408
}

src/Titanium.Web.Proxy/Network/Streams/CopyStream.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public void Dispose()
8888

8989
~CopyStream()
9090
{
91+
#if DEBUG
92+
// Finalizer should not be called
93+
System.Diagnostics.Debugger.Break();
94+
#endif
95+
9196
Dispose(false);
9297
}
9398
}

0 commit comments

Comments
 (0)