mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Make iterators safe in FOREACH_MOD etc macros, so that ModuleManager::Detach() wont screw up the iterator
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8562 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
31aeffb749
commit
ba79ba9fc1
@ -123,9 +123,12 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist;
|
||||
* loaded modules in a readable simple way, e.g.:
|
||||
* 'FOREACH_MOD(I_OnConnect,OnConnect(user));'
|
||||
*/
|
||||
#define FOREACH_MOD(y,x) \
|
||||
for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \
|
||||
{ \
|
||||
#define FOREACH_MOD(y,x) do { \
|
||||
EventHandlerIter safei; \
|
||||
for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \
|
||||
{ \
|
||||
safei = _i; \
|
||||
safei++; \
|
||||
try \
|
||||
{ \
|
||||
(*_i)->x ; \
|
||||
@ -134,7 +137,9 @@ for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i
|
||||
{ \
|
||||
ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
|
||||
} \
|
||||
}
|
||||
_i = safei; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
/**
|
||||
* This #define allows us to call a method in all
|
||||
@ -142,9 +147,12 @@ for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i
|
||||
* an instance pointer to the macro. e.g.:
|
||||
* 'FOREACH_MOD_I(Instance, OnConnect, OnConnect(user));'
|
||||
*/
|
||||
#define FOREACH_MOD_I(z,y,x) \
|
||||
for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \
|
||||
{ \
|
||||
#define FOREACH_MOD_I(z,y,x) do { \
|
||||
EventHandlerIter safei; \
|
||||
for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \
|
||||
{ \
|
||||
safei = _i; \
|
||||
safei++; \
|
||||
try \
|
||||
{ \
|
||||
(*_i)->x ; \
|
||||
@ -153,7 +161,9 @@ for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Module
|
||||
{ \
|
||||
z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
|
||||
} \
|
||||
}
|
||||
_i = safei; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
/**
|
||||
* This define is similar to the one above but returns a result in MOD_RESULT.
|
||||
@ -162,9 +172,12 @@ for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Module
|
||||
*/
|
||||
#define FOREACH_RESULT(y,x) \
|
||||
do { \
|
||||
EventHandlerIter safei; \
|
||||
MOD_RESULT = 0; \
|
||||
for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \
|
||||
{ \
|
||||
safei = _i; \
|
||||
safei++; \
|
||||
try \
|
||||
{ \
|
||||
int res = (*_i)->x ; \
|
||||
@ -177,6 +190,7 @@ do { \
|
||||
{ \
|
||||
ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
|
||||
} \
|
||||
_i = safei; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
@ -188,9 +202,12 @@ do { \
|
||||
*/
|
||||
#define FOREACH_RESULT_I(z,y,x) \
|
||||
do { \
|
||||
EventHandlerIter safei; \
|
||||
MOD_RESULT = 0; \
|
||||
for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \
|
||||
{ \
|
||||
safei = _i; \
|
||||
safei++; \
|
||||
try \
|
||||
{ \
|
||||
int res = (*_i)->x ; \
|
||||
@ -203,6 +220,7 @@ do { \
|
||||
{ \
|
||||
z->Log(DEBUG,"Exception caught: %s",modexcept.GetReason()); \
|
||||
} \
|
||||
_i = safei; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user