brbzull0 commented on a change in pull request #7874:
URL: https://github.com/apache/trafficserver/pull/7874#discussion_r641588513



##########
File path: iocore/hostdb/I_HostDBProcessor.h
##########
@@ -524,21 +707,150 @@ struct HostDBProcessor : public Processor {
 
 private:
   Action *getby(Continuation *cont, cb_process_result_pfn cb_process_result, 
HostDBHash &hash, Options const &opt);
+};
 
-public:
-  /** Set something.
-      @a aip can carry address and / or port information. If setting just
-      by a port value, the address should be set to INADDR_ANY which is of
-      type IPv4.
-   */
-  void setby(const char *hostname,      ///< Hostname.
-             int len,                   ///< Length of hostname.
-             sockaddr const *aip,       ///< Address and/or port.
-             HostDBApplicationInfo *app ///< I don't know.
-  );
+inline bool
+HostDBRecord::is_srv() const
+{
+  return HostDBType::SRV == record_type;
+}
 
-  void setby_srv(const char *hostname, int len, const char *target, 
HostDBApplicationInfo *app);
-};
+inline char const *
+HostDBRecord::name() const
+{
+  return this->apply_offset<char const>(sizeof(self_type));
+}
+
+inline ts::TextView
+HostDBRecord::name_view() const
+{
+  return {this->name(), ts::TextView::npos};
+}
+
+inline ts_time
+HostDBRecord::expiry_time() const
+{
+  return ip_timestamp + ip_timeout_interval + 
ts_seconds(hostdb_serve_stale_but_revalidate);
+}
+
+inline ts_seconds
+HostDBRecord::ip_interval() const
+{
+  static constexpr ts_seconds ZERO{0};
+  static constexpr ts_seconds MAX{0x7FFFFFFF};
+  return 
std::clamp(std::chrono::duration_cast<ts_seconds>((hostdb_current_interval - 
ip_timestamp)), ZERO, MAX);
+}
+
+inline ts_seconds
+HostDBRecord::ip_time_remaining() const
+{
+  return ip_timeout_interval - this->ip_interval();
+}
+
+inline bool
+HostDBRecord::is_ip_stale() const
+{
+  return ip_timeout_interval >= ts_seconds(2 * hostdb_ip_stale_interval) && 
ip_interval() >= ts_seconds(hostdb_ip_stale_interval);
+}
+
+inline bool
+HostDBRecord::is_ip_timeout() const
+{
+  return ip_interval() >= ip_timeout_interval;
+}
+
+inline bool
+HostDBRecord::is_ip_fail_timeout() const
+{
+  return ip_interval() >= ts_seconds(hostdb_ip_fail_timeout_interval);
+}
+
+inline void
+HostDBRecord::refresh_ip()
+{
+  ip_timestamp = hostdb_current_interval;
+}
+
+inline ts::MemSpan<HostDBInfo>
+HostDBRecord::rr_info()
+{
+  return {this->apply_offset<HostDBInfo>(rr_offset), rr_count};
+}
+
+inline bool
+HostDBRecord::is_failed() const
+{
+  return flags.f.failed_p;
+}
+
+inline void
+HostDBRecord::set_failed()
+{
+  flags.f.failed_p = true;
+}
+
+inline unsigned short
+HostDBRecord::rr_idx() const
+{
+  return _rr_idx % rr_count;
+}
+
+inline unsigned short
+HostDBRecord::rr_idx(unsigned short delta) const
+{
+  return (_rr_idx + delta) % rr_count;
+}
+
+inline int
+HostDBRecord::index_of(HostDBInfo const *target) const
+{
+  return target ? target - this->apply_offset<HostDBInfo>(rr_offset) : -1;
+}
+
+// --
+
+inline bool
+ResolveInfo::set_active(sockaddr const *s)
+{
+  return this->set_active(record->find(s));
+}
+
+inline bool
+ResolveInfo::mark_active_server_alive()

Review comment:
       from the comments:
   ```
   /** Mark the active target as alive.   
    *  
    * @return @c true if the target changed state.   
    */  
    bool mark_active_server_alive();
    ```
    how this function could return true? should the `mark_up()` play a role in 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to