Response headers don't need to be queued before subsequent write

This commit is contained in:
Louis DeJardin 2015-07-17 07:43:06 -07:00 committed by Stephen Halter
parent c0728edda7
commit f6dc72544c
3 changed files with 7 additions and 6 deletions

View File

@ -250,7 +250,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public void Write(ArraySegment<byte> data, Action<Exception, object> callback, object state) public void Write(ArraySegment<byte> data, Action<Exception, object> callback, object state)
{ {
ProduceStart(); ProduceStart(immediate: false);
SocketOutput.Write(data, callback, state); SocketOutput.Write(data, callback, state);
} }
@ -293,7 +293,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
} }
} }
public void ProduceStart() public void ProduceStart(bool immediate = true)
{ {
if (_resultStarted) return; if (_resultStarted) return;
_resultStarted = true; _resultStarted = true;
@ -315,7 +315,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
} }
((IDisposable)x).Dispose(); ((IDisposable)x).Dispose();
}, },
responseHeader.Item2); responseHeader.Item2,
immediate: immediate);
} }
public void ProduceEnd(Exception ex) public void ProduceEnd(Exception ex)

View File

@ -10,6 +10,6 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
/// </summary> /// </summary>
public interface ISocketOutput public interface ISocketOutput
{ {
void Write(ArraySegment<byte> buffer, Action<Exception, object> callback, object state); void Write(ArraySegment<byte> buffer, Action<Exception, object> callback, object state, bool immediate = true);
} }
} }

View File

@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
_callbacksPending = new Queue<CallbackContext>(); _callbacksPending = new Queue<CallbackContext>();
} }
public void Write(ArraySegment<byte> buffer, Action<Exception, object> callback, object state) public void Write(ArraySegment<byte> buffer, Action<Exception, object> callback, object state, bool immediate)
{ {
//TODO: need buffering that works //TODO: need buffering that works
var copy = new byte[buffer.Count]; var copy = new byte[buffer.Count];
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
}); });
} }
if (_writesPending < _maxPendingWrites) if (_writesPending < _maxPendingWrites && immediate)
{ {
ScheduleWrite(); ScheduleWrite();
_writesPending++; _writesPending++;