0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd:Ⓜ️ Wrap all queries into ircd::server through fed suite.

This commit is contained in:
Jason Volk 2020-04-25 19:52:24 -07:00
parent 267e978247
commit 37335a68d7
8 changed files with 44 additions and 33 deletions

View file

@ -39,6 +39,8 @@ try
string_view{node.node_id}, string_view{node.node_id},
}; };
fed::clear_error(node.node_id);
if(opts.cache_warming) if(opts.cache_warming)
if(ircd::uptime() < seconds(cache_warmup_time)) if(ircd::uptime() < seconds(cache_warmup_time))
cache_warming(node, opts); cache_warming(node, opts);

View file

@ -449,7 +449,7 @@ ircd::m::feds::for_each_in_room(const opts &opts,
const auto errant const auto errant
{ {
server::errant(fed::matrix_service(origin)) fed::errant(origin)
}; };
if(opts.closure_cached_errors || !errant) try if(opts.closure_cached_errors || !errant) try
@ -490,7 +490,7 @@ ircd::m::feds::for_one(const string_view &origin,
const auto errant const auto errant
{ {
server::errant(fed::matrix_service(origin)) fed::errant(origin)
}; };
if(opts.closure_cached_errors || !errant) try if(opts.closure_cached_errors || !errant) try

View file

@ -580,7 +580,7 @@ ircd::m::fetch::select_random_origin(request &request)
return false; return false;
// Don't want to use a peer marked with an error by ircd::server // Don't want to use a peer marked with an error by ircd::server
if(ircd::server::errant(fed::matrix_service(origin))) if(fed::errant(origin))
return false; return false;
return true; return true;

View file

@ -72,7 +72,7 @@ try
// If we have an error cached from previously not being able to // If we have an error cached from previously not being able to
// contact this origin we can clear that now that they're alive. // contact this origin we can clear that now that they're alive.
if(request.node_id && server::errclear(fed::matrix_service(request.node_id))) if(request.node_id && fed::errant(request.node_id))
{ {
m::burst::opts opts; m::burst::opts opts;
m::burst::burst m::burst::burst

View file

@ -117,7 +117,7 @@ const
size_t ret{0}; size_t ret{0};
for_each([&ret](const string_view &server) for_each([&ret](const string_view &server)
{ {
ret += server::errant(fed::matrix_service(server)); ret += fed::errant(server);
}); });
return ret; return ret;
@ -132,9 +132,9 @@ const
0 - ssize_t(count_error()) 0 - ssize_t(count_error())
}; };
for_each([&ret](const string_view &hostport) for_each([&ret](const string_view &server)
{ {
ret += bool(server::exists(fed::matrix_service(hostport))); ret += bool(fed::exists(server));
}); });
assert(ret >= 0L); assert(ret >= 0L);

View file

@ -5018,9 +5018,17 @@ console_cmd__peer(opt &out, const string_view &line)
const bool conn(has(line, "conn")); const bool conn(has(line, "conn"));
if(hostport && !all && !active && !conn) if(hostport && !all && !active && !conn)
{ {
char buf[rfc3986::DOMAIN_BUFSIZE];
const auto remote
{
net::service(net::hostport(hostport)) == "matrix"?
m::fed::server(buf, hostport):
m::fed::matrix_service(hostport)
};
auto &peer auto &peer
{ {
server::find(m::fed::matrix_service(hostport)) server::find(remote)
}; };
print_head(); print_head();
@ -5141,14 +5149,22 @@ console_cmd__peer__error__clear(opt &out, const string_view &line)
if(empty(line)) if(empty(line))
return console_cmd__peer__error__clear__all(out, line); return console_cmd__peer__error__clear__all(out, line);
const net::hostport hp const string_view &input
{ {
token(line, ' ', 0) token(line, ' ', 0)
}; };
char buf[rfc3986::DOMAIN_BUFSIZE];
const net::hostport remote
{
service(net::hostport(input)) == "matrix"?
m::fed::server(buf, input):
m::fed::matrix_service(input)
};
const auto cleared const auto cleared
{ {
server::errclear(m::fed::matrix_service(hp)) server::errclear(remote)
}; };
out << std::boolalpha << cleared << std::endl; out << std::boolalpha << cleared << std::endl;
@ -5230,14 +5246,22 @@ try
"hostport" "hostport"
}}; }};
const auto &hostport const auto &hp
{ {
param.at(0) param["hostport"]
};
char buf[rfc3986::DOMAIN_BUFSIZE];
const net::hostport remote
{
service(net::hostport(hp)) == "matrix"?
m::fed::server(buf, hp):
m::fed::matrix_service(hp)
}; };
auto &peer auto &peer
{ {
server::find(hostport) server::find(remote)
}; };
peer.cancel(); peer.cancel();
@ -9474,7 +9498,7 @@ console_cmd__room__origins__random(opt &out, const string_view &line)
const auto ok{[&noerror] const auto ok{[&noerror]
(const string_view &origin) (const string_view &origin)
{ {
if(noerror && server::errant(m::fed::matrix_service(origin))) if(noerror && m::fed::errant(origin))
return false; return false;
return true; return true;

View file

@ -199,7 +199,7 @@ get__query_directory(client &client,
if(my_host(origin)) if(my_host(origin))
return true; return true;
if(server::avail(m::fed::matrix_service(origin))) if(m::fed::avail(origin))
return true; return true;
servers.append(origin); servers.append(origin);

View file

@ -277,12 +277,7 @@ send_to_room(const m::event &event,
if(my_host(origin)) if(my_host(origin))
return; return;
const auto remote if(m::fed::errant(origin))
{
m::fed::matrix_service(origin)
};
if(server::errant(remote))
return; return;
auto it auto it
@ -341,12 +336,7 @@ send_to_user(const m::event &event,
if(my_host(origin)) if(my_host(origin))
return; return;
const auto remote if(m::fed::errant(origin))
{
m::fed::matrix_service(origin)
};
if(server::errant(remote))
return; return;
auto it auto it
@ -389,12 +379,7 @@ send_from_user(const m::event &event,
if(my_host(origin)) if(my_host(origin))
return true; return true;
const auto remote if(m::fed::errant(origin))
{
m::fed::matrix_service(origin)
};
if(server::errant(remote))
return true; return true;
auto it auto it