Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
1adcd863
Commit
1adcd863
authored
May 08, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement IDisposable for TcpConnectionFactory
parent
8dae49ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+9
-3
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+1
-0
No files found.
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
1adcd863
...
@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
/// <summary>
/// <summary>
/// A class that manages Tcp Connection to server used by this proxy server.
/// A class that manages Tcp Connection to server used by this proxy server.
/// </summary>
/// </summary>
internal
class
TcpConnectionFactory
internal
class
TcpConnectionFactory
:
IDisposable
{
{
//Tcp server connection pool cache
//Tcp server connection pool cache
private
readonly
ConcurrentDictionary
<
string
,
ConcurrentQueue
<
TcpServerConnection
>>
cache
private
readonly
ConcurrentDictionary
<
string
,
ConcurrentQueue
<
TcpServerConnection
>>
cache
...
@@ -33,6 +33,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -33,6 +33,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
//cache object race operations lock
//cache object race operations lock
private
readonly
SemaphoreSlim
@lock
=
new
SemaphoreSlim
(
1
);
private
readonly
SemaphoreSlim
@lock
=
new
SemaphoreSlim
(
1
);
private
bool
runCleanUpTask
=
true
;
internal
ProxyServer
server
{
get
;
set
;
}
internal
ProxyServer
server
{
get
;
set
;
}
internal
TcpConnectionFactory
(
ProxyServer
server
)
internal
TcpConnectionFactory
(
ProxyServer
server
)
...
@@ -284,8 +286,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -284,8 +286,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
private
async
Task
ClearOutdatedConnections
()
private
async
Task
ClearOutdatedConnections
()
{
{
while
(
runCleanUpTask
)
while
(
true
)
{
{
foreach
(
var
item
in
cache
)
foreach
(
var
item
in
cache
)
{
{
...
@@ -354,5 +355,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
...
@@ -354,5 +355,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
return
true
;
return
true
;
}
}
public
void
Dispose
()
{
runCleanUpTask
=
false
;
}
}
}
}
}
Titanium.Web.Proxy/ProxyServer.cs
View file @
1adcd863
...
@@ -565,6 +565,7 @@ namespace Titanium.Web.Proxy
...
@@ -565,6 +565,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints
.
Clear
();
ProxyEndPoints
.
Clear
();
CertificateManager
?.
StopClearIdleCertificates
();
CertificateManager
?.
StopClearIdleCertificates
();
tcpConnectionFactory
.
Dispose
();
ProxyRunning
=
false
;
ProxyRunning
=
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment