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
4485303b
Commit
4485303b
authored
May 11, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
33d50f32
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+15
-10
No files found.
Titanium.Web.Proxy/RequestHandler.cs
View file @
4485303b
...
@@ -181,12 +181,12 @@ namespace Titanium.Web.Proxy
...
@@ -181,12 +181,12 @@ namespace Titanium.Web.Proxy
continue
;
continue
;
}
}
bool
newConnection
=
false
;
//If prefetch task is available.
//Delay awaiting prefect task as far as possible.
if
(
serverConnection
==
null
&&
prefetchTask
!=
null
)
if
(
serverConnection
==
null
&&
prefetchTask
!=
null
)
{
{
serverConnection
=
await
prefetchTask
;
serverConnection
=
await
prefetchTask
;
newConnection
=
true
;
prefetchTask
=
null
;
}
}
// create a new connection if cache key changes
// create a new connection if cache key changes
...
@@ -197,14 +197,13 @@ namespace Titanium.Web.Proxy
...
@@ -197,14 +197,13 @@ namespace Titanium.Web.Proxy
{
{
await
tcpConnectionFactory
.
Release
(
serverConnection
);
await
tcpConnectionFactory
.
Release
(
serverConnection
);
serverConnection
=
null
;
serverConnection
=
null
;
newConnection
=
true
;
}
}
//create
if
(
serverConnection
==
null
)
if
(
serverConnection
==
null
)
{
{
serverConnection
=
await
getServerConnection
(
args
,
false
,
serverConnection
=
await
getServerConnection
(
args
,
false
,
clientConnection
.
NegotiatedApplicationProtocol
,
cancellationToken
);
clientConnection
.
NegotiatedApplicationProtocol
,
cancellationToken
);
newConnection
=
true
;
}
}
//for connection pool retry fails until cache is exhausted
//for connection pool retry fails until cache is exhausted
...
@@ -229,7 +228,7 @@ namespace Titanium.Web.Proxy
...
@@ -229,7 +228,7 @@ namespace Titanium.Web.Proxy
catch
(
ServerConnectionException
)
catch
(
ServerConnectionException
)
{
{
attempt
++;
attempt
++;
if
(!
newConnection
||
!
EnableConnectionPool
||
attempt
==
MaxCachedConnections
+
1
)
if
(!
EnableConnectionPool
||
attempt
==
MaxCachedConnections
+
1
)
{
{
throw
;
throw
;
}
}
...
@@ -263,13 +262,13 @@ namespace Titanium.Web.Proxy
...
@@ -263,13 +262,13 @@ namespace Titanium.Web.Proxy
throw
new
Exception
(
"Session was terminated by user."
);
throw
new
Exception
(
"Session was terminated by user."
);
}
}
//With connection pool get connection for each HTTP session instead of per client connection.
//Get/release server connection for each HTTP session instead of per client connection.
//That will be more efficient especially when client is holding connection but not using it
//This will be more efficient especially when client is idly holding server connection
//between sessions without using it.
if
(
EnableConnectionPool
)
if
(
EnableConnectionPool
)
{
{
await
tcpConnectionFactory
.
Release
(
serverConnection
);
await
tcpConnectionFactory
.
Release
(
serverConnection
);
serverConnection
=
null
;
serverConnection
=
null
;
prefetchTask
=
null
;
}
}
}
}
...
@@ -295,6 +294,12 @@ namespace Titanium.Web.Proxy
...
@@ -295,6 +294,12 @@ namespace Titanium.Web.Proxy
{
{
await
tcpConnectionFactory
.
Release
(
serverConnection
,
await
tcpConnectionFactory
.
Release
(
serverConnection
,
closeServerConnection
);
closeServerConnection
);
if
(
prefetchTask
!=
null
)
{
await
tcpConnectionFactory
.
Release
(
await
prefetchTask
,
closeServerConnection
);
}
}
}
}
}
...
...
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