Skip to content

Commit

Permalink
Make sure removeClient() actually removes the same object
Browse files Browse the repository at this point in the history
  • Loading branch information
halfgaar committed May 22, 2024
1 parent 4fb6bf8 commit 023c030
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion threaddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,15 @@ void ThreadData::removeClient(std::shared_ptr<Client> client)
// This function is only for same-thread calling.
assert(pthread_self() == thread.native_handle());

if (!client)
return;

client->markAsDisconnecting();

std::lock_guard<std::mutex> lck(clients_by_fd_mutex);
clients_by_fd.erase(client->getFd());
auto pos = clients_by_fd.find(client->getFd());
if (pos != clients_by_fd.end() && pos->second == client)
clients_by_fd.erase(pos);
}

void ThreadData::queueDoKeepAliveCheck()
Expand Down

0 comments on commit 023c030

Please sign in to comment.