summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/dynamic.h10
-rw-r--r--src/dynamic.cpp21
-rw-r--r--src/inspircd.cpp3
-rw-r--r--src/modules/m_devoice.cpp2
4 files changed, 14 insertions, 22 deletions
diff --git a/include/dynamic.h b/include/dynamic.h
index 937005e11..a8b7392bf 100644
--- a/include/dynamic.h
+++ b/include/dynamic.h
@@ -22,6 +22,8 @@ typedef void * (initfunc) (void);
#include "inspircd_config.h"
+extern void do_log(int, const char*, ...);
+
class DLLManager
{
public:
@@ -61,21 +63,21 @@ class DLLFactoryBase : public DLLManager
#endif
};
-
template <class T> class DLLFactory : public DLLFactoryBase
{
public:
DLLFactory(const char *fname, const char *func_name=0) : DLLFactoryBase(fname,func_name)
{
if (factory_func)
- factory = (T*)factory_func();
+ factory = reinterpret_cast<T*>(factory_func());
else
- factory = 0;
+ factory = reinterpret_cast<T*>(-1);
}
~DLLFactory()
{
- delete factory;
+ if (factory)
+ delete factory;
}
T *factory;
diff --git a/src/dynamic.cpp b/src/dynamic.cpp
index 778a94521..ebb1ee71c 100644
--- a/src/dynamic.cpp
+++ b/src/dynamic.cpp
@@ -64,7 +64,7 @@ DLLManager::DLLManager(const char *fname)
// a little safer if the ircd is running at the time as the
// shared libraries are mmap()ed and not doing this causes
// segfaults.
- /*FILE* x = fopen(fname,"rb");
+ FILE* x = fopen(fname,"rb");
if (!x)
{
err = strerror(errno);
@@ -102,7 +102,7 @@ DLLManager::DLLManager(const char *fname)
if (close(fd) == -1)
err = strerror(errno);
if (fclose(x) == EOF)
- err = strerror(errno);*/
+ err = strerror(errno);
h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
if (!h)
@@ -112,7 +112,7 @@ DLLManager::DLLManager(const char *fname)
return;
}
- /*log(DEBUG,"Finished loading '%s': %0x",tmpfile_template, h);
+ log(DEBUG,"Finished loading '%s': %0x",tmpfile_template, h);
// We can delete the tempfile once it's loaded, leaving just the inode.
if (!err && !Config->debugging)
@@ -120,7 +120,7 @@ DLLManager::DLLManager(const char *fname)
log(DEBUG,"Deleteting %s",tmpfile_template);
if (unlink(tmpfile_template) == -1)
err = strerror(errno);
- }*/
+ }
#endif
}
@@ -165,19 +165,14 @@ bool DLLManager::GetSymbol(void** v, const char* sym_name)
{
log(DEBUG,"Found symbol %s", sym_name);
dlerror(); // clear value
- *v = dlsym(h, "init_module");
+ *v = dlsym(h, sym_name);
err = dlerror();
-
- log(DEBUG,"%s",err);
if (!*v || err)
return false;
-
- log(DEBUG,"%0x %0x",dlsym(h, "init_module"), *v);
}
if (err)
{
- log(DEBUG,"Not found symbol");
return false;
}
else
@@ -188,7 +183,7 @@ bool DLLManager::GetSymbol(void** v, const char* sym_name)
#endif
-DLLFactoryBase::DLLFactoryBase(const char* fname, const char* factory) : DLLManager(fname)
+DLLFactoryBase::DLLFactoryBase(const char* fname, const char* symbol) : DLLManager(fname)
{
// try get the factory function if there is no error yet
factory_func = 0;
@@ -196,9 +191,9 @@ DLLFactoryBase::DLLFactoryBase(const char* fname, const char* factory) : DLLMana
if (!LastError())
{
#ifdef STATIC_LINK
- if (!GetSymbol( factory_func, factory ? factory : "init_module" ))
+ if (!GetSymbol( factory_func, symbol ? symbol : "init_module"))
#else
- if (!GetSymbol( (void **)&factory_func, factory ? factory : "init_module" ))
+ if (!GetSymbol( (void **)&factory_func, symbol ? symbol : "init_module"))
#endif
{
throw ModuleException("Missing init_module() entrypoint!");
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 79435ea58..cd5f74a0a 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -589,7 +589,6 @@ bool InspIRCd::LoadModule(const char* filename)
try
{
ircd_module* a = new ircd_module(modfile);
- log(DEBUG,"ircd_module constructor success, MODCOUNT %d",MODCOUNT);
factory[MODCOUNT+1] = a;
if (factory[MODCOUNT+1]->LastError())
{
@@ -597,10 +596,8 @@ bool InspIRCd::LoadModule(const char* filename)
snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
return false;
}
- log(DEBUG,"No last error");
if ((int)factory[MODCOUNT+1]->factory != -1)
{
- log(DEBUG,"Factory ptr: %0x",&factory[MODCOUNT+1]->factory);
Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
modules[MODCOUNT+1] = m;
/* save the module and the module's classfactory, if
diff --git a/src/modules/m_devoice.cpp b/src/modules/m_devoice.cpp
index 346132eaa..b4ba9f117 100644
--- a/src/modules/m_devoice.cpp
+++ b/src/modules/m_devoice.cpp
@@ -63,7 +63,6 @@ class ModuleDeVoice : public Module
public:
ModuleDeVoice(Server* Me) : Module::Module(Me)
{
- log(DEBUG,"ModuleDeVoice constructor");
Srv = Me;
mycommand = new cmd_devoice();
Srv->AddCommand(mycommand);
@@ -93,7 +92,6 @@ class ModuleDeVoiceFactory : public ModuleFactory
virtual Module * CreateModule(Server* Me)
{
- log(DEBUG,"ModuleDevoiceFactory::CreateModule()");
return new ModuleDeVoice(Me);
}