Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion include/iocore/hostdb/HostDBProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,24 @@ HostDBInfo::is_alive()
return this->last_fail_time() == TS_TIME_ZERO;
}

/**
Check if this HostDBInfo is currently marked DOWN (true) or UP (false). Returns true while within the `fail_window` period after
`last_failure`. Once `fail_window` expires, the host is treated as UP and this function returns false.
|<-- fail_window -->|
----------------+-------------------+-----------------> time
UP | DOWN | UP
(is_down=false) | (is_down=true) | (is_down=false)
| |
^ ^
\ \
last_failure last_failure + fail_window
*/
inline bool
HostDBInfo::is_down(ts_time now, ts_seconds fail_window)
{
auto last_fail = this->last_fail_time();
return (last_fail != TS_TIME_ZERO) && (last_fail + fail_window < now);
return (last_fail != TS_TIME_ZERO) && (now <= last_fail + fail_window);
}

inline bool
Expand Down