bryancall commented on code in PR #12717:
URL: https://github.com/apache/trafficserver/pull/12717#discussion_r2879997540


##########
src/proxy/ReverseProxy.cc:
##########
@@ -168,6 +167,65 @@ reloadUrlRewrite()
   }
 }
 
+/**
+ * Helper function to initialize volume_host_rec for a single url_mapping.
+ * This is a no-op if the mapping has no volume string or is already 
initialized.
+ */
+static void
+init_mapping_volume_host_rec(url_mapping &mapping)
+{
+  char errbuf[256];
+
+  if (!mapping.initVolumeHostRec(errbuf, sizeof(errbuf))) {
+    Error("Failed to initialize volume record for @volume=%s: %s", 
mapping.getVolume().c_str(), errbuf);
+  }
+}
+
+static void
+init_store_volume_host_records(UrlRewrite::MappingsStore &store)
+{
+  if (store.hash_lookup) {
+    for (auto &entry : *store.hash_lookup) {
+      UrlMappingPathIndex *path_index = entry.second;
+
+      if (path_index) {
+        path_index->foreach_mapping(init_mapping_volume_host_rec);
+      }
+    }
+  }
+
+  for (UrlRewrite::RegexMapping *reg_map = store.regex_list.head; reg_map; 
reg_map = reg_map->link.next) {
+    if (reg_map->url_map) {
+      init_mapping_volume_host_rec(*reg_map->url_map);
+    }
+  }
+}
+
+// This is called after the cache is initialized, since we may need the 
volume_host_records.
+// Must only be called during startup before any remap reload can occur.
+void
+init_remap_volume_host_records()
+{
+  UrlRewrite *table = rewrite_table;

Review Comment:
   Minor: `UrlRewrite *table = rewrite_table;` is a non-atomic read of a 
pointer that `reloadUrlRewrite()` modifies via `ink_atomic_swap`. The 
startup-only constraint makes this safe in practice, but an atomic load would 
make the intent explicit:
   ```cpp
   UrlRewrite *table = ink_atomic_load(&rewrite_table);
   ```



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