diff --git a/include/ircd/m/hook.h b/include/ircd/m/hook.h
index 09a924448..a7224c9b3 100644
--- a/include/ircd/m/hook.h
+++ b/include/ircd/m/hook.h
@@ -41,6 +41,7 @@ struct ircd::m::hook::base
bool registered {false};
size_t matchers {0};
size_t calls {0};
+ size_t calling {0};
string_view site_name() const;
site *find_site() const;
@@ -62,6 +63,8 @@ struct ircd::m::hook::base::site
std::set hooks;
size_t matchers {0};
bool exceptions {true};
+ size_t calls {0};
+ size_t calling {0};
friend class base;
string_view name() const;
@@ -154,7 +157,15 @@ ircd::m::hook::site::call(hook &hfn,
data d)
try
{
+ // stats for site
+ ++calls;
+ const scope_count site_calling{calling};
+
+ // stats for hook
++hfn.calls;
+ const scope_count hook_calling{hfn.calling};
+
+ // call hook
hfn.function(event, d);
}
catch(const std::exception &e)
diff --git a/ircd/m.cc b/ircd/m.cc
index d9cdd0cf5..1d9512e7f 100644
--- a/ircd/m.cc
+++ b/ircd/m.cc
@@ -5555,6 +5555,8 @@ noexcept
auto *const site(find_site());
assert(site != nullptr);
+ assert(site->calling == 0);
+ assert(calling == 0);
site->del(*this);
}
@@ -5773,7 +5775,15 @@ ircd::m::hook::site::call(hook &hfn,
const event &event)
try
{
+ // stats for site
+ ++calls;
+ const scope_count site_calling{calling};
+
+ // stats for hook
++hfn.calls;
+ const scope_count hook_calling{hfn.calling};
+
+ // call hook
hfn.function(event);
}
catch(const std::exception &e)