Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 8211b54

Browse files
committed
connection perf
1 parent a8e16d4 commit 8211b54

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Titanium.Web.Proxy/RequestHandler.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ await HandleHttpSessionRequest(tcpClient, httpCmd, clientStream, clientStreamRea
186186
private static async Task HandleHttpSessionRequest(TcpClient client, string httpCmd, Stream clientStream,
187187
CustomBinaryReader clientStreamReader, StreamWriter clientStreamWriter, bool isHttps)
188188
{
189+
TcpConnection connection = null;
189190

190191
while (true)
191192
{
@@ -268,7 +269,7 @@ await TcpHelper.SendRaw(clientStream, httpCmd, args.WebSession.Request.RequestHe
268269
}
269270

270271
//construct the web request that we are going to issue on behalf of the client.
271-
var connection = await TcpConnectionManager.GetClient(args.WebSession.Request.RequestUri.Host, args.WebSession.Request.RequestUri.Port, args.IsHttps, version).ConfigureAwait(false);
272+
connection = await TcpConnectionManager.GetClient(args.WebSession.Request.RequestUri.Host, args.WebSession.Request.RequestUri.Port, args.IsHttps, version).ConfigureAwait(false);
272273

273274

274275
args.WebSession.Request.RequestLocked = true;
@@ -342,8 +343,6 @@ await WriteResponseStatus(args.WebSession.Response.HttpVersion, "417",
342343
return;
343344
}
344345

345-
await TcpConnectionManager.ReleaseClient(connection);
346-
347346
// read the next request
348347
httpCmd = await clientStreamReader.ReadLineAsync().ConfigureAwait(false);
349348

@@ -356,6 +355,8 @@ await WriteResponseStatus(args.WebSession.Response.HttpVersion, "417",
356355

357356
}
358357

358+
if (connection!=null)
359+
await TcpConnectionManager.ReleaseClient(connection);
359360
}
360361

361362
private static async Task WriteConnectResponse(StreamWriter clientStreamWriter, Version httpVersion)

0 commit comments

Comments
 (0)