Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmbeddedChannel: make write not auto-flush & websockets: connection closed frame must be flushed #421

Merged
merged 2 commits into from
May 21, 2018

Conversation

weissi
Copy link
Member

@weissi weissi commented May 21, 2018

THIS CONTAINS TWO COMMITS, PLEASE DON'T SQUASH AND MERGE

part 1

EmbeddedChannel: make write not auto-flush
Motivation:

EmbeddedChannel just treated all writes as flushed. That's not a good
idea as all real channels obviously only actually write the bytes when
flushed. This changes that behaviour for EmbeddedChannel.

Modifications:

  • make write only write to a buffer
  • make flush then actually pretend to write the bytes

Result:

  • EmbeddedChannel behaves more realisticly

part 2

websockets: connection closed frame must be flushed
Motivation:

Because EmbeddedChannel used to treat all writes as flushed the test
that tested that we do send out the WebSockets connection close frame
didn't actually test the right thing. Now that EmbeddedChannel behaves
more realisticly, this test actually fails.

This fixes the bug and the test that tests that a WebSockets connection
is successfully torn down after an error occured.

Modifications:

  • use writeAndFlush to send out the connection close frame.

Result:

WebSockets connection actually gets closed on error.

Motivation:

EmbeddedChannel just treated all `write`s as flushed. That's not a good
idea as all real channels obviously only actually write the bytes when
flushed. This changes that behaviour for `EmbeddedChannel`.

Modifications:

- make `write` only write to a buffer
- make `flush` then actually pretend to write the bytes

Result:

- EmbeddedChannel behaves more realisticly
Motivation:

Because EmbeddedChannel used to treat all writes as flushed the test
that tested that we do send out the WebSockets connection close frame
didn't actually test the right thing. Now that EmbeddedChannel behaves
more realisticly, this test actually fails.

This fixes the bug and the test that tests that a WebSockets connection
is successfully torn down after an error occured.

Modifications:

- use `writeAndFlush` to send out the connection close frame.

Result:

WebSockets connection actually gets closed on error.
@weissi weissi changed the title Jw ws close on err EmbeddedChannel: make write not auto-flush & websockets: connection closed frame must be flushed May 21, 2018
@weissi weissi requested review from Lukasa and normanmaurer and removed request for Lukasa May 21, 2018 14:36
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, when the tests go green feel free to merge.

@Lukasa Lukasa added the semver/patch No public API change. label May 21, 2018
@Lukasa Lukasa added this to the 1.7.1 milestone May 21, 2018
@weissi weissi merged commit 5aa140c into apple:master May 21, 2018
@weissi weissi deleted the jw-ws-close-on-err branch May 21, 2018 15:05
Lukasa added a commit to Lukasa/swift-nio-ssl-1 that referenced this pull request May 22, 2018
Motivation:

apple/swift-nio#421 changed the behaviour of EmbeddedChannel to no longer
automatically succeed write promises without flushes. This is a reasonable
behavioural change, but broke a test that was working around but still
implicitly relied on the old behaviour.

Modifications:

Add the missing flushes.

Result:

This test will pass both on NIO master and NIO 1.7.0
weissi pushed a commit to apple/swift-nio-ssl that referenced this pull request May 22, 2018
Motivation:

apple/swift-nio#421 changed the behaviour of EmbeddedChannel to no longer
automatically succeed write promises without flushes. This is a reasonable
behavioural change, but broke a test that was working around but still
implicitly relied on the old behaviour.

Modifications:

Add the missing flushes.

Result:

This test will pass both on NIO master and NIO 1.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants