0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 16:34:13 +01:00

ircd::server: Add external interface to clear a peer error; w/ console command.

This commit is contained in:
Jason Volk 2018-03-12 14:06:12 -07:00
parent a22e45a9f5
commit 09923ff758
4 changed files with 41 additions and 2 deletions

View file

@ -88,7 +88,7 @@ struct ircd::server::peer
bool err_has() const; bool err_has() const;
string_view err_msg() const; string_view err_msg() const;
template<class... A> void err_set(A&&...); template<class... A> void err_set(A&&...);
void err_clear(); bool err_clear();
bool err_check(); bool err_check();
// control panel // control panel

View file

@ -37,6 +37,7 @@ namespace ircd::server
size_t peer_unfinished(); size_t peer_unfinished();
string_view errmsg(const net::hostport &); string_view errmsg(const net::hostport &);
bool errclear(const net::hostport &);
bool exists(const net::hostport &); bool exists(const net::hostport &);
peer &find(const net::hostport &); peer &find(const net::hostport &);
peer &get(const net::hostport &); peer &get(const net::hostport &);

View file

@ -124,6 +124,21 @@ ircd::server::exists(const net::hostport &hostport)
return peers.find(host(hostport)) != end(peers); return peers.find(host(hostport)) != end(peers);
} }
bool
ircd::server::errclear(const net::hostport &hostport)
{
const auto it
{
peers.find(host(hostport))
};
if(it == end(peers))
return false;
auto &peer(*it->second);
return peer.err_clear();
}
ircd::string_view ircd::string_view
ircd::server::errmsg(const net::hostport &hostport) ircd::server::errmsg(const net::hostport &hostport)
{ {
@ -368,10 +383,12 @@ ircd::server::peer::interrupt()
})); }));
} }
void bool
ircd::server::peer::err_clear() ircd::server::peer::err_clear()
{ {
const auto ret{bool(e)};
e.reset(nullptr); e.reset(nullptr);
return ret;
} }
template<class... A> template<class... A>

View file

@ -382,6 +382,7 @@ console_cmd__net(const string_view &line)
} }
} }
static bool console_cmd__net_peer__clear(const string_view &line);
static bool console_cmd__net_peer__default(); static bool console_cmd__net_peer__default();
bool bool
@ -397,6 +398,9 @@ console_cmd__net_peer(const string_view &line)
switch(hash(token(line, ' ', 0))) switch(hash(token(line, ' ', 0)))
{ {
case hash("clear"):
return console_cmd__net_peer__clear(args);
default: default:
throw bad_command{}; throw bad_command{};
} }
@ -404,6 +408,23 @@ console_cmd__net_peer(const string_view &line)
return true; return true;
} }
bool
console_cmd__net_peer__clear(const string_view &line)
{
const net::hostport hp
{
token(line, ' ', 0)
};
const auto cleared
{
server::errclear(hp)
};
out << std::boolalpha << cleared << std::endl;
return true;
}
bool bool
console_cmd__net_peer__default() console_cmd__net_peer__default()
{ {