LindaSummer commented on code in PR #2461:
URL: https://github.com/apache/kvrocks/pull/2461#discussion_r1703268623
##########
src/server/worker.cc:
##########
@@ -333,18 +338,18 @@ Status Worker::AddConnection(redis::Connection *c) {
redis::Connection *Worker::removeConnection(int fd) {
redis::Connection *conn = nullptr;
- std::unique_lock<std::mutex> lock(conns_mu_);
- auto iter = conns_.find(fd);
- if (iter != conns_.end()) {
- conn = iter->second;
- conns_.erase(iter);
+ std::lock_guard<std::mutex> guard(conns_mu_);
Review Comment:
Hi @mapleFU ,
Thanks for your suggestions.
I agree on your view, if we need to protect the erase action, we should only
lock the erase itself.
Lock the outside scope is an insufficient way.
I have removed the mutex now.
So, we have no more lock here and we all rely on tbb hashmap itself.
Best Regards,
Edward
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]