summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-02 03:15:46 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-02 03:15:46 +0000
commit8456cf5ccd44911f4e56538fe0880dd7fc7cd96d (patch)
tree3e1f96b94cc86506a615d8b39131ff6ea7c1b64c /include
parent87d031609bb8b7d2cd186d8f24bcb853fd93798c (diff)
Fix valgrind issues and crashes on exit
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11794 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/commands/cmd_whowas.h2
-rw-r--r--include/dynamic.h29
-rw-r--r--include/inspircd.h6
-rw-r--r--include/modules.h18
-rw-r--r--include/users.h2
5 files changed, 19 insertions, 38 deletions
diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h
index 99d12cca4..12c9eae9a 100644
--- a/include/commands/cmd_whowas.h
+++ b/include/commands/cmd_whowas.h
@@ -108,7 +108,7 @@ class WhoWasGroup : public classbase
std::string ident;
/** Server name
*/
- const char* server;
+ std::string server;
/** Fullname (GECOS)
*/
std::string gecos;
diff --git a/include/dynamic.h b/include/dynamic.h
index ec09675e0..fe150716e 100644
--- a/include/dynamic.h
+++ b/include/dynamic.h
@@ -89,25 +89,21 @@ class CoreExport FindSymbolException : public CoreException
virtual ~FindSymbolException() throw() {};
};
+class Module;
/** This is the highest-level class of the DLLFactory system used to load InspIRCd modules and commands.
* All the dirty mucking around with dl*() is done by DLLManager, all this does it put a pretty shell on
* it and make it nice to use to load modules and core commands. This class is quite specialised for these
* two uses and it may not be useful more generally -- use DLLManager directly for that.
*/
-template <typename ReturnType> class CoreExport DLLFactory : public DLLManager
+class CoreExport DLLFactory : public DLLManager
{
- protected:
- /** This typedef represents the init_* function within each module or command.
- * The init_module function is the only exported extern "C" declaration
- * in any module file. In a cmd_*.cpp file the equivilant is init_command
- */
- typedef ReturnType * (initfunctype) ();
+ public:
+ typedef Module* (initfunctype)();
/** Pointer to the init function.
*/
- initfunctype* init_func;
+ initfunctype* const init_func;
- public:
/** Default constructor.
* This constructor passes its paramerers down through DLLFactoryBase and then DLLManager
* to load the module, then calls the factory function to retrieve a pointer to a ModuleFactory
@@ -132,21 +128,6 @@ template <typename ReturnType> class CoreExport DLLFactory : public DLLManager
}
}
- /** Calls the 'init_module' C exported function within a module, which
- * returns a pointer to a Module derived object.
- */
- ReturnType* CallInit()
- {
- if(init_func)
- {
- return init_func();
- }
- else
- {
- return NULL;
- }
- }
-
/** The destructor deletes the ModuleFactory pointer.
*/
~DLLFactory()
diff --git a/include/inspircd.h b/include/inspircd.h
index b80bba7ab..f240c2ecb 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -557,7 +557,7 @@ class CoreExport InspIRCd : public classbase
* @param servername The servername to find the description of
* @return The description of this server, or of the local server
*/
- std::string GetServerDescription(const char* servername);
+ std::string GetServerDescription(const std::string& servername);
/** Find a user in the nick hash.
* If the user cant be found in the nick hash check the uuid hash
@@ -810,12 +810,12 @@ class CoreExport InspIRCd : public classbase
* @param server The server to check for uline status
* @return True if the server is a uline OR the string is empty
*/
- bool ULine(const char* server);
+ bool ULine(const std::string& server);
/** Returns true if the uline is 'silent' (doesnt generate
* remote connect notices etc).
*/
- bool SilentULine(const char* server);
+ bool SilentULine(const std::string& server);
/** Returns the subversion revision ID of this ircd
* @return The revision ID or an empty string
diff --git a/include/modules.h b/include/modules.h
index edfe31007..c9927133f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -408,6 +408,9 @@ class CoreExport Module : public Extensible
/** File that this module was loaded from
*/
std::string ModuleSourceFile;
+ /** Reference to the dlopen() value
+ */
+ DLLFactory* ModuleDLLFactory;
/** Default constructor.
* Creates a module class.
@@ -416,6 +419,11 @@ class CoreExport Module : public Extensible
*/
Module();
+ /** Clean up prior to destruction
+ * If you override, you must call this AFTER your module's cleanup
+ */
+ virtual bool cull();
+
/** Default destructor.
* destroys a module class
*/
@@ -1507,14 +1515,6 @@ class CoreExport FileReader : public classbase
int FileSize();
};
-/** A DLLFactory (designed to load shared objects) containing a
- * handle to a module's init_module() function. Unfortunately,
- * due to the design of shared object systems we must keep this
- * hanging around, as if we remove this handle, we remove the
- * shared object file from memory (!)
- */
-typedef DLLFactory<Module> ircd_module;
-
/** A list of modules
*/
typedef std::vector<Module*> IntModuleList;
@@ -1548,7 +1548,7 @@ class CoreExport ModuleManager : public classbase
/** List of loaded modules and shared object/dll handles
* keyed by module name
*/
- std::map<std::string, std::pair<ircd_module*, Module*> > Modules;
+ std::map<std::string, Module*> Modules;
enum {
PRIO_STATE_FIRST,
diff --git a/include/users.h b/include/users.h
index 31c1c641d..7e05c9f2a 100644
--- a/include/users.h
+++ b/include/users.h
@@ -382,7 +382,7 @@ class CoreExport User : public StreamSocket
/** The server the user is connected to.
*/
- const char* server;
+ std::string server;
/** The user's away message.
* If this string is empty, the user is not marked as away.