Copilot commented on code in PR #12988:
URL: https://github.com/apache/trafficserver/pull/12988#discussion_r2954690336


##########
src/proxy/ReverseProxy.cc:
##########
@@ -68,22 +69,28 @@ int
 init_reverse_proxy()
 {
   ink_assert(rewrite_table.load() == nullptr);
-  reconfig_mutex = new_ProxyMutex();
-  rewrite_table.store(new UrlRewrite());
+  reconfig_mutex      = new_ProxyMutex();
+  auto *initial_table = new UrlRewrite();
 
-  rewrite_table.load()->acquire();
+  initial_table->acquire();
   Note("%s loading ...", ts::filename::REMAP);
-  if (!rewrite_table.load()->load()) {
+  if (!initial_table->load()) {
     Emergency("%s failed to load", ts::filename::REMAP);
   } else {
     Note("%s finished loading", ts::filename::REMAP);
   }
 
+  rewrite_table.store(initial_table, std::memory_order_release);
+
   RecRegisterConfigUpdateCb("proxy.config.url_remap.filename", url_rewrite_CB, 
(void *)FILE_CHANGED);
   RecRegisterConfigUpdateCb("proxy.config.proxy_name", url_rewrite_CB, (void 
*)TSNAME_CHANGED);
   RecRegisterConfigUpdateCb("proxy.config.reverse_proxy.enabled", 
url_rewrite_CB, (void *)REVERSE_CHANGED);
   RecRegisterConfigUpdateCb("proxy.config.http.referer_default_redirect", 
url_rewrite_CB, (void *)HTTP_DEFAULT_REDIRECT_CHANGED);
 
+  if (initial_table->is_valid() && CacheProcessor::IsCacheEnabled() == 
CacheInitState::INITIALIZED) {
+    init_remap_volume_host_records();
+  }
+

Review Comment:
   `init_remap_volume_host_records()` is documented as only being callable 
during startup before any remap reload can occur, but this call currently 
happens after registering the `url_rewrite_CB` config callbacks. If a record 
update arrives immediately after registration, a reload could be scheduled 
while volume host record initialization is walking the mapping stores. Consider 
moving the deferred @volume= initialization block to immediately after 
publishing `rewrite_table` and before registering the config update callbacks 
(or otherwise ensure reload cannot run concurrently here).
   



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