Unverified Commit 74207225 authored by nirbil's avatar nirbil Committed by GitHub

fix buffers returned to pool too early

buffers were returned to the pool before the write operation finished, which lead to corrupted buffers
parent a7d4c61f
...@@ -67,11 +67,15 @@ namespace Titanium.Web.Proxy.Helpers ...@@ -67,11 +67,15 @@ namespace Titanium.Web.Proxy.Helpers
idx += newLineChars; idx += newLineChars;
} }
return stream.WriteAsync(buffer, 0, idx, cancellationToken); return stream.WriteAsync(buffer, 0, idx, cancellationToken).ContinueWith((antecedent) =>
{
bufferPool.ReturnBuffer(buffer);
});
} }
finally catch(Exception ex)
{ {
bufferPool.ReturnBuffer(buffer); bufferPool.ReturnBuffer(buffer);
throw ex;
} }
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment