diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-14 22:12:55 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-14 22:12:55 +0000 |
commit | dbf4d595433ecefeb61f1267ffa515a91c3ab548 (patch) | |
tree | 0e85976e4cd0b77a8fb54a6df54dee94265ac75c /include | |
parent | 9c9386d71e1b317fa39cc251eb6450e14ec5929f (diff) |
Fix module unmapping with culled Module objects
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11875 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/base.h | 4 | ||||
-rw-r--r-- | include/caller.h | 24 | ||||
-rw-r--r-- | include/cull_list.h | 15 | ||||
-rw-r--r-- | include/inspircd.h | 5 | ||||
-rw-r--r-- | include/modules.h | 27 |
5 files changed, 49 insertions, 26 deletions
diff --git a/include/base.h b/include/base.h index 0464f68e2..ed03eeac5 100644 --- a/include/base.h +++ b/include/base.h @@ -55,8 +55,8 @@ class CoreExport refcountbase : public classbase class CoreExport reference_base { protected: - static inline unsigned int inc(refcountbase* v) { return ++(v->refcount); } - static inline unsigned int dec(refcountbase* v) { return --(v->refcount); } + template<typename T> static inline unsigned int inc(T* v) { return ++(v->refcount); } + template<typename T> static inline unsigned int dec(T* v) { return --(v->refcount); } }; template <typename T> diff --git a/include/caller.h b/include/caller.h index 666035752..420f17afb 100644 --- a/include/caller.h +++ b/include/caller.h @@ -47,63 +47,63 @@ * this until you do, as if you get this wrong, this can generate some pretty long * winded and confusing error messages at compile time. */ -template <typename ReturnType> class CoreExport HandlerBase0 +template <typename ReturnType> class CoreExport HandlerBase0 : public classbase { public: virtual ReturnType Call() = 0; virtual ~HandlerBase0() { } }; -template <typename ReturnType, typename Param1> class CoreExport HandlerBase1 +template <typename ReturnType, typename Param1> class CoreExport HandlerBase1 : public classbase { public: virtual ReturnType Call(Param1) = 0; virtual ~HandlerBase1() { } }; -template <typename ReturnType, typename Param1, typename Param2> class CoreExport HandlerBase2 +template <typename ReturnType, typename Param1, typename Param2> class CoreExport HandlerBase2 : public classbase { public: virtual ReturnType Call(Param1, Param2) = 0; virtual ~HandlerBase2() { } }; -template <typename ReturnType, typename Param1, typename Param2, typename Param3> class CoreExport HandlerBase3 +template <typename ReturnType, typename Param1, typename Param2, typename Param3> class CoreExport HandlerBase3 : public classbase { public: virtual ReturnType Call(Param1, Param2, Param3) = 0; virtual ~HandlerBase3() { } }; -template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4> class CoreExport HandlerBase4 +template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4> class CoreExport HandlerBase4 : public classbase { public: virtual ReturnType Call(Param1, Param2, Param3, Param4) = 0; virtual ~HandlerBase4() { } }; -template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5> class CoreExport HandlerBase5 +template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5> class CoreExport HandlerBase5 : public classbase { public: virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5) = 0; virtual ~HandlerBase5() { } }; -template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6> class CoreExport HandlerBase6 +template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6> class CoreExport HandlerBase6 : public classbase { public: virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5, Param6) = 0; virtual ~HandlerBase6() { } }; -template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7> class CoreExport HandlerBase7 +template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7> class CoreExport HandlerBase7 : public classbase { public: virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5, Param6, Param7) = 0; virtual ~HandlerBase7() { } }; -template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7, typename Param8> class CoreExport HandlerBase8 +template <typename ReturnType, typename Param1, typename Param2, typename Param3, typename Param4, typename Param5, typename Param6, typename Param7, typename Param8> class CoreExport HandlerBase8 : public classbase { public: virtual ReturnType Call(Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8) = 0; @@ -120,12 +120,6 @@ template <typename HandlerType> class CoreExport caller { } virtual ~caller() { } - - caller& operator=(HandlerType* newtarget) - { - target = newtarget; - return *this; - } }; template <typename ReturnType> class CoreExport caller0 : public caller< HandlerBase0<ReturnType> > diff --git a/include/cull_list.h b/include/cull_list.h index 2b3ed1391..33e9a7ea6 100644 --- a/include/cull_list.h +++ b/include/cull_list.h @@ -33,5 +33,20 @@ class CoreExport CullList void Apply(); }; +class CoreExport ActionList +{ + std::vector<HandlerBase0<void>*> list; + + public: + /** Adds an item to the list + */ + void AddAction(HandlerBase0<void>* item) { list.push_back(item); } + + /** Runs the items + */ + void Run(); + +}; + #endif diff --git a/include/inspircd.h b/include/inspircd.h index df80ba4bf..4fb28e2d7 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -78,6 +78,8 @@ CoreExport extern InspIRCd* ServerInstance; #include "inspircd_config.h" #include "inspircd_version.h" +#include "caller.h" +#include "cull_list.h" #include "extensible.h" #include "numerics.h" #include "uid.h" @@ -94,7 +96,6 @@ CoreExport extern InspIRCd* ServerInstance; #include "mode.h" #include "socketengine.h" #include "snomasks.h" -#include "cull_list.h" #include "filelogger.h" #include "caller.h" #include "modules.h" @@ -381,6 +382,8 @@ class CoreExport InspIRCd : public classbase /** Global cull list, will be processed on next iteration */ CullList GlobalCulls; + /** Actions that must happen outside of the current call stack */ + ActionList AtomicActions; /**** Functors ****/ diff --git a/include/modules.h b/include/modules.h index 9207a2bd9..151c3fef8 100644 --- a/include/modules.h +++ b/include/modules.h @@ -107,7 +107,7 @@ struct ModResult { /** If you change the module API in any way, increment this value. * This MUST be a pure integer, with no parenthesis */ -#define API_VERSION 133 +#define API_VERSION 134 class ServerConfig; @@ -917,9 +917,8 @@ class CoreExport Module : public Extensible * absolutely neccessary (e.g. a module that extends the features of another * module). * @param mod A pointer to the new module - * @param name The new module's filename */ - virtual void OnLoadModule(Module* mod,const std::string &name); + virtual void OnLoadModule(Module* mod); /** Called whenever a module is unloaded. * mod will contain a pointer to the module, and string will contain its name, @@ -933,7 +932,7 @@ class CoreExport Module : public Extensible * @param mod Pointer to the module being unloaded (still valid) * @param name The filename of the module being unloaded */ - virtual void OnUnloadModule(Module* mod,const std::string &name); + virtual void OnUnloadModule(Module* mod); /** Called once every five seconds for background processing. * This timer can be used to control timed features. Its period is not accurate @@ -1502,6 +1501,9 @@ class CoreExport ModuleManager : public classbase PRIO_STATE_AGAIN, PRIO_STATE_LAST } prioritizationState; + + /** Internal unload module hook */ + bool CanUnload(Module*); public: /** Event handler hooks. @@ -1590,15 +1592,24 @@ class CoreExport ModuleManager : public classbase */ bool Load(const char* filename); - /** Unload a given module file - * @param filename The file to unload - * @return True if the module was unloaded + /** Unload a given module file. Note that the module will not be + * completely gone until the cull list has finished processing. + * + * @return true on success; if false, LastError will give a reason + */ + bool Unload(Module* module); + + /** Run an asynchronous reload of the given module. When the reload is + * complete, the callback will be run with true if the reload succeeded + * and false if it did not. */ - bool Unload(const char* filename); + void Reload(Module* module, HandlerBase1<void, bool>* callback); /** Called by the InspIRCd constructor to load all modules from the config file. */ void LoadAll(); + void UnloadAll(); + void DoSafeUnload(Module*); /** Get the total number of currently loaded modules * @return The number of loaded modules |