mapleFU commented on code in PR #2461:
URL: https://github.com/apache/kvrocks/pull/2461#discussion_r1701943022


##########
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:
   I don't know whether close the connection in the critical section is really 
a good idea...



-- 
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]

Reply via email to