From 1c42206307f40151ea035adcebee4b3029afa772 Mon Sep 17 00:00:00 2001 From: Jason Volk <jason@zemos.net> Date: Wed, 14 Aug 2019 01:51:38 -0700 Subject: [PATCH] ircd::m::feds: Add an exclude_myself option. --- include/ircd/m/feds.h | 5 +++++ modules/m_feds.cc | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/ircd/m/feds.h b/include/ircd/m/feds.h index 508e17b3e..af2608080 100644 --- a/include/ircd/m/feds.h +++ b/include/ircd/m/feds.h @@ -93,6 +93,11 @@ struct ircd::m::feds::opts /// the user's closure is never invoked and no request is made if a remote /// has a cached error. bool closure_cached_errors {false}; + + /// Whether to skip any loopback queries to my own host. This is false by + /// default, and loopback queries are made for result completeness in the + /// typical use case. + bool exclude_myself {false}; }; enum class ircd::m::feds::op diff --git a/modules/m_feds.cc b/modules/m_feds.cc index b512913b4..8be4d39dd 100644 --- a/modules/m_feds.cc +++ b/modules/m_feds.cc @@ -460,6 +460,9 @@ ircd::m::feds::for_each_in_room(const opts &opts, origins.for_each([&opts, &ret, &closure, &create_closure] (const string_view &origin) { + if(opts.exclude_myself && my_host(origin)) + return; + const auto errmsg { server::errmsg(origin) @@ -498,6 +501,9 @@ ircd::m::feds::for_one(const string_view &origin, const std::function<T (request<T> &, const string_view &origin)> &create_closure) { request_list ret; + if(opts.exclude_myself && my_host(origin)) + return ret; + const auto errmsg { server::errmsg(origin)