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


##########
src/mgmt/rpc/handlers/hostdb/HostDB.cc:
##########
@@ -203,4 +212,18 @@ get_hostdb_status(std::string_view const & /* id 
ATS_UNUSED */, YAML::Node const
   }
   return resp;
 }
+
+swoc::Rv<YAML::Node>
+clear_hostdb(std::string_view const & /* id ATS_UNUSED */, YAML::Node const & 
/* params ATS_UNUSED */)
+{
+  swoc::Rv<YAML::Node> resp;
+  if (hostDBProcessor.cache()->refcountcache == nullptr) {
+    resp.errata().assign(std::error_code{errors::Codes::SERVER}).note("HostDB 
is not initialized");
+    return resp;
+  }

Review Comment:
   The requested guard is already present in the reviewed revision, immediately 
before `hostDBProcessor.clear()`:
   
   ```cpp
   if (hostDBProcessor.cache()->refcountcache == nullptr) {
     resp.errata().assign(std::error_code{errors::Codes::SERVER}).note("HostDB 
is not initialized");
     return resp;
   }
   ```
   
   `HostDBProcessor::cache()` returns the address of the static `hostDB` 
object; the nullable member is `refcountcache`, which this guard checks. This 
matches the initialization check in `get_hostdb_status()`. No code change 
appears necessary for the missing-check finding.



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