Skip to content

Conversation

@TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Aug 15, 2024

The bug was introduced in PR #474

  • 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.
    • If on the channel-thread, just call aws_channel_shutdown()
    • 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

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

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.61%. Comparing base (7db2452) to head (791c582).

Files Patch % Lines
source/websocket.c 90.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #483      +/-   ##
==========================================
+ Coverage   79.55%   79.61%   +0.06%     
==========================================
  Files          27       27              
  Lines       11688    11683       -5     
==========================================
+ Hits         9298     9302       +4     
+ Misses       2390     2381       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -992 to -993
websocket->thread_data.is_reading_stopped = true;
websocket->thread_data.is_writing_stopped = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh man, I totally didn't notice these changes in that other PR.

I'll take over this PR. I'm oncall

…, vs calls from off-thread caused directly by the user
Copy link
Contributor Author

@TingDaoK TingDaoK left a comment

Choose a reason for hiding this comment

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

Cannot approve, but :shipit:

@graebm graebm merged commit 4e74ab1 into main Aug 16, 2024
@graebm graebm deleted the fix-websocket branch August 16, 2024 16:26
graebm added a commit to awslabs/aws-crt-java that referenced this pull request Aug 16, 2024
Update submodules, bringing in this fix: awslabs/aws-c-http#483
```
aws-c-common       v0.9.26 -> v0.9.27
aws-c-event-stream v0.4.2 -> v0.4.3
aws-c-http         v0.8.7 -> v0.8.8
```
graebm added a commit to awslabs/aws-crt-cpp that referenced this pull request Aug 16, 2024
Update submodules, bringing in this fix: awslabs/aws-c-http#483
```
aws-c-common       v0.9.26 -> v0.9.27
aws-c-event-stream v0.4.2 -> v0.4.3
aws-c-http         v0.8.7 -> v0.8.8
```
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.

4 participants