mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd::server: Check and clear peer error after timeout.
This commit is contained in:
parent
81b3916953
commit
7f336200ea
2 changed files with 30 additions and 2 deletions
|
@ -20,6 +20,7 @@ struct ircd::server::peer
|
|||
|
||||
static conf::item<size_t> link_min_default;
|
||||
static conf::item<size_t> link_max_default;
|
||||
static conf::item<seconds> error_clear_default;
|
||||
|
||||
net::remote remote;
|
||||
std::list<link> links;
|
||||
|
@ -84,6 +85,7 @@ struct ircd::server::peer
|
|||
string_view err_msg() const;
|
||||
template<class... A> void err_set(A&&...);
|
||||
void err_clear();
|
||||
bool err_check();
|
||||
|
||||
// control panel
|
||||
void interrupt();
|
||||
|
|
|
@ -363,14 +363,40 @@ const
|
|||
return bool(e);
|
||||
}
|
||||
|
||||
decltype(ircd::server::peer::error_clear_default)
|
||||
ircd::server::peer::error_clear_default
|
||||
{
|
||||
{ "name", "ircd.server.peer.error.clear_default" },
|
||||
{ "default", 305L }
|
||||
};
|
||||
|
||||
bool
|
||||
ircd::server::peer::err_check()
|
||||
{
|
||||
if(!ready)
|
||||
return false;
|
||||
|
||||
if(!e)
|
||||
return true;
|
||||
|
||||
//TODO: The specific error type should be switched and finer
|
||||
//TODO: timeouts should be used depending on the error: i.e
|
||||
//TODO: NXDOMAIN vs. temporary conn timeout, etc.
|
||||
if(e->etime + seconds(error_clear_default) > now<steady_point>())
|
||||
return false;
|
||||
|
||||
err_clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ircd::server::peer::submit(request &request)
|
||||
try
|
||||
{
|
||||
if(unlikely(!ready || !server::ready))
|
||||
if(!err_check() || unlikely(!server::ready))
|
||||
throw unavailable
|
||||
{
|
||||
"Peer is unable to take any requests."
|
||||
"Peer is unable to take any requests: %s", err_msg()
|
||||
};
|
||||
|
||||
link *const ret
|
||||
|
|
Loading…
Reference in a new issue