mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::server: Add external interface to clear a peer error; w/ console command.
This commit is contained in:
parent
a22e45a9f5
commit
09923ff758
4 changed files with 41 additions and 2 deletions
|
@ -88,7 +88,7 @@ struct ircd::server::peer
|
|||
bool err_has() const;
|
||||
string_view err_msg() const;
|
||||
template<class... A> void err_set(A&&...);
|
||||
void err_clear();
|
||||
bool err_clear();
|
||||
bool err_check();
|
||||
|
||||
// control panel
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace ircd::server
|
|||
size_t peer_unfinished();
|
||||
|
||||
string_view errmsg(const net::hostport &);
|
||||
bool errclear(const net::hostport &);
|
||||
bool exists(const net::hostport &);
|
||||
peer &find(const net::hostport &);
|
||||
peer &get(const net::hostport &);
|
||||
|
|
|
@ -124,6 +124,21 @@ ircd::server::exists(const net::hostport &hostport)
|
|||
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::server::errmsg(const net::hostport &hostport)
|
||||
{
|
||||
|
@ -368,10 +383,12 @@ ircd::server::peer::interrupt()
|
|||
}));
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::server::peer::err_clear()
|
||||
{
|
||||
const auto ret{bool(e)};
|
||||
e.reset(nullptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class... A>
|
||||
|
|
|
@ -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();
|
||||
|
||||
bool
|
||||
|
@ -397,6 +398,9 @@ console_cmd__net_peer(const string_view &line)
|
|||
|
||||
switch(hash(token(line, ' ', 0)))
|
||||
{
|
||||
case hash("clear"):
|
||||
return console_cmd__net_peer__clear(args);
|
||||
|
||||
default:
|
||||
throw bad_command{};
|
||||
}
|
||||
|
@ -404,6 +408,23 @@ console_cmd__net_peer(const string_view &line)
|
|||
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
|
||||
console_cmd__net_peer__default()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue