bneradt commented on code in PR #10688:
URL: https://github.com/apache/trafficserver/pull/10688#discussion_r1384347144


##########
src/iocore/net/ConnectionTracker.cc:
##########
@@ -161,17 +197,46 @@ ConnectionTracker::obtain_outbound(TxnConfig const 
&txn_cnf, std::string_view fq
   CryptoHash hash;
   CryptoContext().hash_immediate(hash, fqdn.data(), fqdn.size());
   Group::Key key{addr, hash, txn_cnf.server_match};
-  std::lock_guard<std::mutex> lock(_imp._mutex); // Table lock
-  auto loc = _imp._table.find(key);
-  if (loc != _imp._table.end()) {
-    zret._g = loc;
+  std::lock_guard<std::mutex> lock(_outbound_table._mutex); // Table lock
+  auto loc = _outbound_table._table.find(key);
+  if (loc != _outbound_table._table.end()) {
+    zret._g = loc->second;
   } else {
-    zret._g = new Group(key, fqdn, txn_cnf.server_min);
-    _imp._table.insert(zret._g);
+    zret._g = std::make_shared<Group>(Group::DirectionType::OUTBOUND, key, 
fqdn, txn_cnf.server_min);
+    // Note that we must use zret._g's key, not the above key, because Key's
+    // members are references to the Group's members. Thus the above key's
+    // members are invalid after this function.
+    _outbound_table._table.insert(std::make_pair(zret._g->_key, zret._g));
   }
   return zret;
 }
 
+ConnectionTracker::Group::Group(DirectionType direction, Key const &key, 
std::string_view fqdn, int min_keep_alive)
+  : _direction{direction},
+    _hash(key._hash),
+    _match_type(key._match_type),
+    min_keep_alive_conns(min_keep_alive),

Review Comment:
   https://github.com/apache/trafficserver/pull/10738



-- 
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: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to