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

async channel shutdown #172

Merged
merged 4 commits into from
Aug 6, 2019
Merged

async channel shutdown #172

merged 4 commits into from
Aug 6, 2019

Conversation

TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Aug 6, 2019

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

source/channel.c Outdated Show resolved Hide resolved
source/channel.c Outdated Show resolved Hide resolved
source/channel.c Outdated Show resolved Hide resolved
@graebm graebm merged commit ecea3d0 into awslabs:master Aug 6, 2019
graebm added a commit to awslabs/aws-c-http that referenced this pull request Aug 16, 2024
The bug was introduced in [PR #474](https://github.com/awslabs/aws-c-http/pull/474/files#diff-ee776c7576cfff50a64158d59a6173ab9a0aa373150574aa9987b4f8726b58e3)
  - `is_writing_stopped = true` shouldn't be set directly, there's a helper function `s_stop_writing()` that ensures subsequent calls to `aws_websocket_send_frame()` will fail.

Let's take a whole new approach these channel-shutdown-window-deadlock issues:
- add `s_stop_reading_and_dont_block_shutdown()` function that sets `is_reading_stopped = true`, but also increments the read window so that channel shutdown won't deadlock.
    - Most places that were setting `is_reading_stopped = true` now use this helper instead
- Revamp how `aws_channel_shutdown()` is called. Lots of channel behavior has changed since [this websocket code was written](#48).
  - If on the channel-thread, just call `aws_channel_shutdown()`
      - now that [aws_channel_shutdown()](awslabs/aws-c-io#172) is always async, we don't need to defensively schedule a task to call it
  - If off-thread, use `s_schedule_channel_shutdown_from_offthead()`
      - now that this is only called from `aws_websocket_close()`, or when the refcount goes to zero, we can assume the user is OK if reading stops, and it can call `s_stop_reading_and_dont_block_shutdown()` on the way to shutting down.
- Add the test to verify that send after close should fail

Co-authored-by: Michael Graeb <graebm@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants