diff --git a/include/ircd/m/feds.h b/include/ircd/m/feds.h index 59cf26ceb..6b187bb55 100644 --- a/include/ircd/m/feds.h +++ b/include/ircd/m/feds.h @@ -143,6 +143,11 @@ struct ircd::m::feds::opts /// typical use case. bool exclude_myself {false}; + /// Whether to iterate the query targets first to perform prelinks. This is + /// an asynchronous operation which may perform server name resolution and + /// link estab. The main request loop will then have fewer hazards. + bool prelink {true}; + // Default construction is inline by member; this is defined to impose // noexcept over `milliseconds timeout` which we guarantee won't throw. opts() noexcept {} diff --git a/matrix/feds.cc b/matrix/feds.cc index c725194fe..57aa1487d 100644 --- a/matrix/feds.cc +++ b/matrix/feds.cc @@ -441,6 +441,18 @@ ircd::m::feds::for_each_in_room(const opts &opts, opts.room_id }; + // Prelink loop + if(opts.prelink) + origins.for_each([&opts] + (const string_view &origin) + { + if(opts.exclude_myself && my_host(origin)) + return; + + fed::prelink(origin); + }); + + // Request loop origins.for_each([&opts, &ret, &closure, &create_closure] (const string_view &origin) {