Merge branch 'nickcraver/cancellation' into dev

This commit is contained in:
Stephen Halter 2015-11-12 16:15:59 -08:00
commit 983997ab9c
3 changed files with 10 additions and 10 deletions

View File

@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Filter
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token)
{
var segment = new ArraySegment<byte>(buffer, offset, count);
return _output.WriteAsync(segment);
return _output.WriteAsync(segment, cancellationToken: token);
}
public override void Flush()

View File

@ -349,7 +349,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public async Task FlushAsync(CancellationToken cancellationToken)
{
await ProduceStartAndFireOnStarting(immediate: false);
await SocketOutput.WriteAsync(_emptyData, immediate: true);
await SocketOutput.WriteAsync(_emptyData, immediate: true, cancellationToken: cancellationToken);
}
public void Write(ArraySegment<byte> data)

View File

@ -68,14 +68,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{
return ((Task<int>)asyncResult).Result;
}
#endif
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
return _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
}
public Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken, object state)
private Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken, object state)
{
var tcs = new TaskCompletionSource<int>(state);
var task = _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
@ -94,9 +88,15 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{
tcs2.SetResult(task2.Result);
}
}, tcs);
}, tcs, cancellationToken);
return tcs.Task;
}
#endif
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
return _body.ReadAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken);
}
public override void Write(byte[] buffer, int offset, int count)
{