0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd::server: Check and clear peer error after timeout.

This commit is contained in:
Jason Volk 2018-03-09 07:42:28 -08:00
parent 81b3916953
commit 7f336200ea
2 changed files with 30 additions and 2 deletions

View file

@ -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();

View file

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