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

only close websocket once #3231

Merged
merged 1 commit into from
Aug 27, 2024
Merged

only close websocket once #3231

merged 1 commit into from
Aug 27, 2024

Conversation

wiegell
Copy link
Contributor

@wiegell wiegell commented Aug 26, 2024

Fixes #2604

I have:

  • Removed the defer c.close(websocket.CloseAbnormalClosure, "unexpected closure") since c.close() is also triggered via go c.closeOnCancel(ctx) on line 281. This seems to have fixed the dual firing of a supplied closefunction for me, where the exit of the for loop on line 291 would fire the close function twice (via the defer directly, but also via go c.closeOnCancel(ctx) indirectly triggered by the defer). I will however point to line 305 and line 317, where the loop is also exited with explicit closures. I have not run into those lines in the debugger, but i would actually have expected those places to fire c.close() three times before, and now instead two times (probably still too many).
    Let me know if i can add this expected behavior to existing tests.

@coveralls
Copy link

Coverage Status

coverage: 74.454% (-0.04%) from 74.498%
when pulling 2f16898 on wiegell:master
into 256794a on 99designs:master.

@StevenACoffman StevenACoffman merged commit 3e76e7e into 99designs:master Aug 27, 2024
17 checks passed
@StevenACoffman
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding an on-close callback for websockets.
3 participants