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
022b4762
Commit
022b4762
authored
May 14, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache disposal improvement
parent
2b4fd32d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
23 deletions
+39
-23
TcpConnectionFactory.cs
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+39
-23
No files found.
Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
View file @
022b4762
...
...
@@ -55,7 +55,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
$"
{
isHttps
}
-"
);
if
(
applicationProtocols
!=
null
)
{
foreach
(
var
protocol
in
applicationProtocols
.
OrderBy
(
x
=>
x
))
foreach
(
var
protocol
in
applicationProtocols
.
OrderBy
(
x
=>
x
))
{
cacheKeyBuilder
.
Append
(
$"
{
protocol
}
-"
);
}
...
...
@@ -94,9 +94,15 @@ namespace Titanium.Web.Proxy.Network.Tcp
if
(
proxyServer
.
EnableConnectionPool
)
{
try
{
await
@lock
.
WaitAsync
();
if
(
cache
.
TryGetValue
(
cacheKey
,
out
var
existingConnections
))
{
while
(
existingConnections
.
TryDequeue
(
out
var
recentConnection
))
while
(
existingConnections
.
Count
>
0
)
{
if
(
existingConnections
.
TryDequeue
(
out
var
recentConnection
))
{
//+3 seconds for potential delay after getting connection
var
cutOff
=
DateTime
.
Now
.
AddSeconds
(-
1
*
proxyServer
.
ConnectionTimeOutSeconds
+
3
);
...
...
@@ -111,6 +117,12 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
}
}
}
finally
{
@lock
.
Release
();
}
}
var
connection
=
await
createClient
(
remoteHostName
,
remotePort
,
httpVersion
,
isHttps
,
applicationProtocols
,
isConnect
,
proxyServer
,
upStreamEndPoint
,
externalProxy
,
cancellationToken
);
...
...
@@ -181,7 +193,10 @@ namespace Titanium.Web.Proxy.Network.Tcp
foreach
(
var
item
in
cache
)
{
var
queue
=
item
.
Value
;
while
(
queue
.
TryDequeue
(
out
var
connection
))
while
(
queue
.
Count
>
0
)
{
if
(
queue
.
TryDequeue
(
out
var
connection
))
{
var
cutOff
=
DateTime
.
Now
.
AddSeconds
(-
1
*
server
.
ConnectionTimeOutSeconds
);
if
(!
server
.
EnableConnectionPool
...
...
@@ -195,6 +210,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
break
;
}
}
}
try
{
...
...
@@ -220,8 +236,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
}
//cleanup every
ten
seconds by default
await
Task
.
Delay
(
1000
*
10
);
//cleanup every
3
seconds by default
await
Task
.
Delay
(
1000
*
3
);
}
}
...
...
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