internal override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool endStream, CancellationToken cancellationToken = default)
{
ThrowIfDisposed();
+
using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false);
await SendReadOnlyMemoryAsync(buffer, endStream ? QUIC_SEND_FLAGS.FIN : QUIC_SEND_FLAGS.NONE).ConfigureAwait(false);
throw new InvalidOperationException(SR.net_quic_writing_notallowed);
}
+ if (cancellationToken.IsCancellationRequested)
+ {
+ lock (_state)
+ {
+ if (_state.SendState == SendState.None || _state.SendState == SendState.Pending)
+ {
+ _state.SendState = SendState.Aborted;
+ }
+ }
+
+ throw new System.OperationCanceledException(cancellationToken);
+ }
+
// Make sure start has completed
if (!_started)
{
throw new InvalidOperationException(SR.net_quic_reading_notallowed);
}
+ if (cancellationToken.IsCancellationRequested)
+ {
+ lock (_state)
+ {
+ if (_state.ReadState == ReadState.None)
+ {
+ _state.ReadState = ReadState.Aborted;
+ }
+ }
+
+ throw new System.OperationCanceledException(cancellationToken);
+ }
+
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(_state, $"[Stream#{_state.GetHashCode()}] reading into Memory of '{destination.Length}' bytes.");
// TODO: new additions, find out the actual reason for hanging
[ActiveIssue("https://github.com/dotnet/runtime/issues/49157")]
- public override Task ReadWriteAsync_PrecanceledOperations_ThrowsCancellationException() => base.ReadWriteAsync_PrecanceledOperations_ThrowsCancellationException();
- [ActiveIssue("https://github.com/dotnet/runtime/issues/49157")]
public override Task Read_DataStoredAtDesiredOffset(ReadWriteMode mode) => base.Read_DataStoredAtDesiredOffset(mode);
[ActiveIssue("https://github.com/dotnet/runtime/issues/49157")]
public override Task ReadAsync_DuringReadAsync_ThrowsIfUnsupported() => base.ReadAsync_DuringReadAsync_ThrowsIfUnsupported();