inspircd

A modular C++ IRC daemon (ircd). https://www.inspircd.org/
Log | Files | Refs | README

commit 87bbf574bde2149daed9f9967f33ceae13250b70
parent d2ebf5083be476d73f468e9f45e369576bd3df2c
Author: Peter Powell <petpow@saberuk.com>
Date:   Thu,  6 Jun 2019 14:14:09 +0100

Only call events on modules which aren't dying.

Diffstat:
Minclude/event.h | 10+++++++++-
Minclude/modules.h | 6++++--
2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/event.h b/include/event.h @@ -122,6 +122,9 @@ class Events::ModuleEventListener : private dynamic_reference_base::CaptureHook prov->subscribers.erase(this); } + /** Retrieves the module which created this listener. */ + const Module* GetModule() const { return prov.creator; } + friend struct ModuleEventProvider::Comp; }; @@ -140,7 +143,9 @@ inline bool Events::ModuleEventProvider::Comp::operator()(Events::ModuleEventLis for (::Events::ModuleEventProvider::SubscriberList::const_iterator _i = _handlers.begin(); _i != _handlers.end(); ++_i) \ { \ listenerclass* _t = static_cast<listenerclass*>(*_i); \ - _t->func params ; \ + const Module* _m = _t->GetModule(); \ + if (_m && !_m->dying) \ + _t->func params ; \ } \ } while (0); @@ -157,6 +162,9 @@ inline bool Events::ModuleEventProvider::Comp::operator()(Events::ModuleEventLis for (::Events::ModuleEventProvider::SubscriberList::const_iterator _i = _handlers.begin(); _i != _handlers.end(); ++_i) \ { \ listenerclass* _t = static_cast<listenerclass*>(*_i); \ + const Module* _m = _t->GetModule(); \ + if (!_m || _m->dying) \ + continue; \ result = _t->func params ; \ if (result != MOD_RES_PASSTHRU) \ break; \ diff --git a/include/modules.h b/include/modules.h @@ -121,7 +121,8 @@ struct ModResult { _next = _i+1; \ try \ { \ - (*_i)->y x ; \ + if (!(*_i)->dying) \ + (*_i)->y x ; \ } \ catch (CoreException& modexcept) \ { \ @@ -144,7 +145,8 @@ do { \ _next = _i+1; \ try \ { \ - v = (*_i)->n args; + if (!(*_i)->dying) \ + v = (*_i)->n args; #define WHILE_EACH_HOOK(n) \ } \