Skip to content

Fix infinite loop when a Websocket connection is lost #58

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

Merged
merged 1 commit into from
Nov 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/HTTPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,15 @@ void HTTPConnection::loop() {
HTTPS_LOGD("Calling WS handler, FID=%d", _socket);
_wsHandler->loop();
}

// If the client closed the connection unexpectedly
if (_clientState == CSTATE_CLOSED) {
HTTPS_LOGI("WS lost client, calling onClose, FID=%d", _socket);
_wsHandler->onClose();
}

// If the handler has terminated the connection, clean up and close the socket too
if (_wsHandler->closed()) {
if (_wsHandler->closed() || _clientState == CSTATE_CLOSED) {
HTTPS_LOGI("WS closed, freeing Handler, FID=%d", _socket);
delete _wsHandler;
_wsHandler = nullptr;
Expand Down