Skip to content

Commit

Permalink
Merge pull request #58 from runeharlyk/event-socket-lock
Browse files Browse the repository at this point in the history
Ensure thread safety for client subscriptions
  • Loading branch information
theelims authored Jul 23, 2024
2 parents bf812de + 8053c42 commit b5898d6
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 b5898d6

Please sign in to comment.