Skip to content

Commit

Permalink
Ensures thread safety for client subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
runeharlyk committed Jul 22, 2024
1 parent bf812de commit 8053c42
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/framework/EventSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ void EventSocket::onWSOpen(PsychicWebSocketClient *client)

void EventSocket::onWSClose(PsychicWebSocketClient *client)
{
xSemaphoreTake(clientSubscriptionsMutex, portMAX_DELAY);
for (auto &event_subscriptions : client_subscriptions)
{
event_subscriptions.second.remove(client->socket());
}
xSemaphoreGive(clientSubscriptionsMutex);
ESP_LOGI("EventSocket", "ws[%s][%u] disconnect", client->remoteIP().toString().c_str(), client->socket());
}

Expand Down

0 comments on commit 8053c42

Please sign in to comment.