-
Notifications
You must be signed in to change notification settings - Fork 70
Fix WebSocket #153
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
Fix WebSocket #153
Conversation
TienHuyIoT
commented
Apr 9, 2025
- Handle client disconnection event properly even if cleanupClients is not called within the main loop.
- Avoid self-deadlock by using recursive mutex.
- Handle client disconnection event properly even if cleanupClients is not called within the main loop. - Avoid self-deadlock by using recursive mutex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/AsyncWebSocket.cpp:877
- Modifications to the _clients vector in _handleDisconnect are not protected by any mutex. Ensure thread safety by protecting access to _clients if concurrent modifications may occur.
void AsyncWebSocket::_handleDisconnect(AsyncWebSocketClient *client) {
src/AsyncWebSocket.cpp:371
- The manual unlocking of the unique_lock before calling _client->close(true) could be error-prone if future changes introduce exceptions between the unlock and the following code. Consider refactoring the unlock logic into a dedicated scope or helper function to ensure exception safety.
lock.unlock();
|
@TienHuyIoT : if ESPAsyncWS cleans up itself, the current |
The cleanupClients() function has a maxClients argument, so I believe the cleanup() method should be used to handle situations where the number of connected clients exceeds the maxClients limit. However, its usage ultimately depends on the specific requirements of the user’s application. |
you are right! I forgot about this part. |
|
@vortigont @me-no-dev : care to have a look please ? |
mathieucarbou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, works fine.
Thanks for the improvement!
|
looks nice! thanks! |