LindaSummer commented on code in PR #2461:
URL: https://github.com/apache/kvrocks/pull/2461#discussion_r1701977622
##########
src/server/worker.cc:
##########
@@ -76,17 +77,22 @@ Worker::Worker(Server *srv, Config *config) : srv(srv),
base_(event_base_new())
}
Worker::~Worker() {
- std::vector<redis::Connection *> conns;
- conns.reserve(conns_.size() + monitor_conns_.size());
-
- for (const auto &iter : conns_) {
- conns.emplace_back(iter.second);
- }
- for (const auto &iter : monitor_conns_) {
- conns.emplace_back(iter.second);
+ {
+ std::lock_guard<std::mutex> guard(conns_mu_);
+ for (const auto &iter : conns_) {
+ if (ConnMap::accessor accessor; conns_.find(accessor, iter.first)) {
+ accessor->second->Close();
Review Comment:
Hi @mapleFU ,
Sorry for putting time-costly tasks into a critical section.
I will make this action only manipulate with the container and leave
`Close()` action outside the critical section.
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]