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

do not try to read from websocket after sending and receiving the clo… #452

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

MichaelSB
Copy link
Contributor

This is a fix for #446

  1. for server-side close (segfault): after handling the close frame from the client in handle_fragment, shutdown the connection and return false to the caller, signalling no further reads should be done
  2. for client-side close (failing read after close, causing error-handler being called): just destroy the connection in do_read if we both sent and received the close frame (according to https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.1)

@The-EDev The-EDev linked an issue Jun 4, 2022 that may be closed by this pull request
@The-EDev
Copy link
Member

The-EDev commented Jun 4, 2022

I'm guessing we're preventing do_read() from running after handling the close frame because the if (has_sent_close_ && has_recv_close_) block references the adaptor which would cause another segfault.

On face value I can't see anything wrong, I"ll test it with the example you provided in #446.

Copy link
Member

@The-EDev The-EDev left a comment

Choose a reason for hiding this comment

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

Everything seems to be alright.

Thank you very much @MichaelSB for finding and fixing this problem, and I'm sorry I couldn't help much with it.

@The-EDev The-EDev merged commit ed87c65 into CrowCpp:master Jun 4, 2022
@MichaelSB
Copy link
Contributor Author

Yes, that's the reason for preventing do_read entirely. Thanks for merging. And don't worry :) I really like crow and trying to fix problems I find is the least I can do.

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.

Websockets cause segfault when closing from server side
2 participants