Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Nerdbank.Streams/MultiplexingStream.Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ private void InitializeOwnPipes()

var writerRelay = new Pipe();
Pipe? readerRelay = this.BackpressureSupportEnabled
? new Pipe(new PipeOptions(pauseWriterThreshold: this.localWindowSize.Value + 1)) // +1 prevents pause when remote window is exactly filled
? new Pipe(new PipeOptions(pauseWriterThreshold: this.localWindowSize.Value + 1, resumeWriterThreshold: this.localWindowSize.Value)) // +1 prevents pause when remote window is exactly filled
: new Pipe();
this.mxStreamIOReader = writerRelay.Reader;
this.mxStreamIOWriter = readerRelay.Writer;
Expand Down
23 changes: 23 additions & 0 deletions test/Nerdbank.Streams.Tests/MultiplexingStreamV2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,29 @@ public async Task Backpressure_ExistingPipe()
await writeTask;
}

[Fact]
public async Task AcceptChannelAsync_SmallReceivingWindowSize()
{
const int offeredWindowSize = 16;
const int acceptedWindowSize = 64;

Task<MultiplexingStream.Channel> offeredChannelTask = this.mx1.OfferChannelAsync(
"small-window",
new MultiplexingStream.ChannelOptions { ChannelReceivingWindowSize = offeredWindowSize },
this.TimeoutToken);
Task<MultiplexingStream.Channel> acceptedChannelTask = this.mx2.AcceptChannelAsync(
"small-window",
new MultiplexingStream.ChannelOptions { ChannelReceivingWindowSize = acceptedWindowSize },
this.TimeoutToken);

MultiplexingStream.Channel[] channels = await WhenAllSucceedOrAnyFail(offeredChannelTask, acceptedChannelTask).WithCancellation(this.TimeoutToken);

await this.TransmitAndVerifyAsync(channels[0].AsStream(), channels[1].AsStream(), new byte[] { 1, 2, 3 });
await this.TransmitAndVerifyAsync(channels[1].AsStream(), channels[0].AsStream(), new byte[] { 4, 5, 6 });

await CompleteChannelsAsync(channels);
}

[Fact]
public async Task Backpressure_CopyToAsync()
{
Expand Down
Loading