0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd:Ⓜ️:fed: Another attempt at well-known expired-entry fallback.

This commit is contained in:
Jason Volk 2020-05-01 21:24:41 -07:00
parent 4e9664ebce
commit 1a1826bded

View file

@ -1782,6 +1782,34 @@ try
return delegated; return delegated;
} }
// Conditions for valid expired cache hit w/ failure to reacquire.
const bool fallback
{
valid
&& expired
&& cached != delegated
&& origin == delegated
&& now<system_point>() < expires + seconds(well_known_cache_max)
};
if(fallback)
{
char tmbuf[48];
log::debug
{
well_known_log, "%s found in cache delegated to %s event_idx:%u expired %s",
origin,
cached,
event_idx,
timef(tmbuf, expires, localtime),
};
return string_view
{
data(buf), move(buf, cached)
};
}
// Any time the well-known result is the same as the origin (that // Any time the well-known result is the same as the origin (that
// includes legitimate errors where fetch_well_known() returns the // includes legitimate errors where fetch_well_known() returns the
// origin to default) we consider that an error and use the error // origin to default) we consider that an error and use the error