summaryrefslogtreecommitdiff
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
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
-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
-rw-r--r--src/commands/cmd_notice.cpp2
-rw-r--r--src/commands/cmd_privmsg.cpp2
-rw-r--r--src/commands/cmd_whowas.cpp2
-rw-r--r--src/cull_list.cpp14
-rw-r--r--src/helperfuncs.cpp17
-rw-r--r--src/inspircd.cpp11
-rw-r--r--src/mode.cpp2
-rw-r--r--src/modes/umode_o.cpp2
-rw-r--r--src/modules.cpp54
-rw-r--r--src/modules/m_lockserv.cpp4
-rw-r--r--src/modules/m_nokicks.cpp2
-rw-r--r--src/modules/m_ojoin.cpp3
-rw-r--r--src/modules/m_spanningtree/main.cpp10
-rw-r--r--src/modules/m_spanningtree/opertype.cpp2
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp2
-rw-r--r--src/modules/m_spanningtree/treesocket.h1
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp11
-rw-r--r--src/modules/m_spanningtree/uid.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp1
-rw-r--r--src/usermanager.cpp2
-rw-r--r--src/users.cpp1
-rw-r--r--src/whois.cpp2
27 files changed, 105 insertions, 101 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.
diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp
index 41dbe5b3b..ae1f6d83b 100644
--- a/src/commands/cmd_notice.cpp
+++ b/src/commands/cmd_notice.cpp
@@ -159,7 +159,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
nickonly.assign(destnick, 0, targetserver - destnick);
dest = ServerInstance->FindNickOnly(nickonly);
- if (dest && strcasecmp(dest->server, targetserver + 1))
+ if (dest && strcasecmp(dest->server.c_str(), targetserver + 1))
{
/* Incorrect server for user */
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index 868a5864b..54ed50c0f 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -171,7 +171,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us
nickonly.assign(destnick, 0, targetserver - destnick);
dest = ServerInstance->FindNickOnly(nickonly);
- if (dest && strcasecmp(dest->server, targetserver + 1))
+ if (dest && strcasecmp(dest->server.c_str(), targetserver + 1))
{
/* Incorrect server for user */
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp
index 4a9ac9499..6cd50f8b8 100644
--- a/src/commands/cmd_whowas.cpp
+++ b/src/commands/cmd_whowas.cpp
@@ -68,7 +68,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use
if (*ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex"))
user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b);
else
- user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), u->server, b);
+ user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), u->server.c_str(), b);
}
}
else
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index ff2bc64b5..f87095126 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -17,6 +17,8 @@
void CullList::Apply()
{
std::set<classbase*> gone;
+ std::vector<classbase*> queue;
+ queue.reserve(list.size() + 32);
for(unsigned int i=0; i < list.size(); i++)
{
classbase* c = list[i];
@@ -25,7 +27,7 @@ void CullList::Apply()
ServerInstance->Logs->Log("CULLLIST", DEBUG, "Deleting %s @%p", typeid(*c).name(),
(void*)c);
if (c->cull())
- delete c;
+ queue.push_back(c);
}
else
{
@@ -34,5 +36,15 @@ void CullList::Apply()
}
}
list.clear();
+ for(unsigned int i=0; i < queue.size(); i++)
+ {
+ classbase* c = queue[i];
+ delete c;
+ }
+ if (list.size())
+ {
+ ServerInstance->Logs->Log("CULLLIST",DEBUG, "WARNING: Objects added to cull list in a destructor");
+ Apply();
+ }
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 155e29dd4..6c2ceabb2 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -17,7 +17,7 @@
#include "xline.h"
#include "exitcodes.h"
-std::string InspIRCd::GetServerDescription(const char* servername)
+std::string InspIRCd::GetServerDescription(const std::string& servername)
{
std::string description;
@@ -401,22 +401,21 @@ long InspIRCd::Duration(const std::string &str)
return total + subtotal;
}
-bool InspIRCd::ULine(const char* sserver)
+bool InspIRCd::ULine(const std::string& sserver)
{
- if (!sserver)
- return false;
- if (!*sserver)
+ if (sserver.empty())
return true;
- return (Config->ulines.find(sserver) != Config->ulines.end());
+ return (Config->ulines.find(sserver.c_str()) != Config->ulines.end());
}
-bool InspIRCd::SilentULine(const char* sserver)
+bool InspIRCd::SilentULine(const std::string& sserver)
{
- std::map<irc::string,bool>::iterator n = Config->ulines.find(sserver);
+ std::map<irc::string,bool>::iterator n = Config->ulines.find(sserver.c_str());
if (n != Config->ulines.end())
return n->second;
- else return false;
+ else
+ return false;
}
std::string InspIRCd::TimeString(time_t curtime)
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index b815ce4ac..2a9f506bc 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -111,11 +111,15 @@ void InspIRCd::Cleanup()
Users->QuitUser(u, "Server shutdown");
}
+ /* Cleanup Server Names */
+ for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
+ delete (*itr);
+
/* We do this more than once, so that any service providers get a
* chance to be unhooked by the modules using them, but then get
* a chance to be removed themsleves.
*
- * XXX there may be a better way to do this with 1.2
+ * XXX there may be a better way to do this
*/
for (int tries = 0; tries < 4; tries++)
{
@@ -125,12 +129,9 @@ void InspIRCd::Cleanup()
/* Unload all modules, so they get a chance to clean up their listeners */
this->Modules->Unload(k->c_str());
}
+ GlobalCulls.Apply();
}
- /* Cleanup Server Names */
- for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
- delete (*itr);
-
/* Delete objects dynamically allocated in constructor (destructor would be more appropriate, but we're likely exiting) */
/* Must be deleted before modes as it decrements modelines */
DeleteZero(this->FakeClient);
diff --git a/src/mode.cpp b/src/mode.cpp
index 965619eea..73b465917 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -1004,7 +1004,7 @@ ModeParser::~ModeParser()
for(int i=0; i < 256; i++)
{
ModeHandler* mh = modehandlers[i];
- if (mh)
+ if (mh && mh->creator == NULL)
{
count++;
delete mh;
diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp
index 1d6992144..3c0eb37a1 100644
--- a/src/modes/umode_o.cpp
+++ b/src/modes/umode_o.cpp
@@ -40,7 +40,7 @@ ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, st
*/
char snomask = IS_LOCAL(dest) ? 'o' : 'O';
ServerInstance->SNO->WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(),
- source->nick.empty() ? source->server : source->nick.c_str());
+ source->nick.empty() ? source->server.c_str() : source->nick.c_str());
dest->UnOper();
return MODEACTION_ALLOW;
diff --git a/src/modules.cpp b/src/modules.cpp
index db41a757a..a96dfe5e8 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -105,6 +105,11 @@ std::string Event::GetEventID()
// These declarations define the behavours of the base class Module (which does nothing at all)
Module::Module() { }
+bool Module::cull()
+{
+ ServerInstance->GlobalCulls.AddItem(ModuleDLLFactory);
+ return true;
+}
Module::~Module() { }
ModResult Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; }
@@ -418,19 +423,21 @@ bool ModuleManager::Load(const char* filename)
}
Module* newmod = NULL;
- ircd_module* newhandle = NULL;
+ DLLFactory* newhandle = NULL;
try
{
/* This will throw a CoreException if there's a problem loading
* the module file or getting a pointer to the init_module symbol.
*/
- newhandle = new ircd_module(modfile, "init_module");
- newmod = newhandle->CallInit();
+ newhandle = new DLLFactory(modfile, "init_module");
+ if (newhandle->init_func)
+ newmod = newhandle->init_func();
if (newmod)
{
newmod->ModuleSourceFile = filename_str;
+ newmod->ModuleDLLFactory = newhandle;
Version v = newmod->GetVersion();
if (v.API != API_VERSION)
@@ -447,7 +454,7 @@ bool ModuleManager::Load(const char* filename)
ServerInstance->Logs->Log("MODULE", DEFAULT,"New module introduced: %s (API version %d, Module version %s)%s", filename, v.API, v.version.c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]"));
}
- Modules[filename_str] = std::make_pair(newhandle, newmod);
+ Modules[filename_str] = newmod;
}
else
{
@@ -502,8 +509,8 @@ bool ModuleManager::Load(const char* filename)
for(int tries = 0; tries < 20; tries++)
{
prioritizationState = tries > 0 ? PRIO_STATE_LAST : PRIO_STATE_FIRST;
- for (std::map<std::string, std::pair<ircd_module*, Module*> >::iterator n = Modules.begin(); n != Modules.end(); ++n)
- n->second.second->Prioritize();
+ for (std::map<std::string, Module*>::iterator n = Modules.begin(); n != Modules.end(); ++n)
+ n->second->Prioritize();
if (prioritizationState == PRIO_STATE_LAST)
break;
@@ -518,17 +525,17 @@ bool ModuleManager::Load(const char* filename)
bool ModuleManager::Unload(const char* filename)
{
std::string filename_str(filename);
- std::map<std::string, std::pair<ircd_module*, Module*> >::iterator modfind = Modules.find(filename);
+ std::map<std::string, Module*>::iterator modfind = Modules.find(filename);
if (modfind != Modules.end())
{
- if (modfind->second.second->GetVersion().Flags & VF_STATIC)
+ if (modfind->second->GetVersion().Flags & VF_STATIC)
{
LastModuleError = "Module " + filename_str + " not unloadable (marked static)";
ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
return false;
}
- std::pair<int,std::string> intercount = GetInterfaceInstanceCount(modfind->second.second);
+ std::pair<int,std::string> intercount = GetInterfaceInstanceCount(modfind->second);
if (intercount.first > 0)
{
LastModuleError = "Failed to unload module " + filename_str + ", being used by " + ConvToStr(intercount.first) + " other(s) via interface '" + intercount.second + "'";
@@ -536,11 +543,11 @@ bool ModuleManager::Unload(const char* filename)
return false;
}
- std::vector<ExtensionItem*> items = Extensible::BeginUnregister(modfind->second.second);
+ std::vector<ExtensionItem*> items = Extensible::BeginUnregister(modfind->second);
/* Give the module a chance to tidy out all its metadata */
for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); c++)
{
- modfind->second.second->OnCleanup(TYPE_CHANNEL,c->second);
+ modfind->second->OnCleanup(TYPE_CHANNEL,c->second);
c->second->doUnhookExtensions(items);
const UserMembList* users = c->second->GetUsers();
for(UserMembCIter mi = users->begin(); mi != users->end(); mi++)
@@ -548,21 +555,20 @@ bool ModuleManager::Unload(const char* filename)
}
for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
{
- modfind->second.second->OnCleanup(TYPE_USER,u->second);
+ modfind->second->OnCleanup(TYPE_USER,u->second);
u->second->doUnhookExtensions(items);
}
/* Tidy up any dangling resolvers */
- ServerInstance->Res->CleanResolvers(modfind->second.second);
+ ServerInstance->Res->CleanResolvers(modfind->second);
- FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(modfind->second.second, modfind->first));
+ FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(modfind->second, modfind->first));
- this->DetachAll(modfind->second.second);
+ this->DetachAll(modfind->second);
- ServerInstance->Parser->RemoveCommands(modfind->second.second);
+ ServerInstance->Parser->RemoveCommands(modfind->second);
- ServerInstance->GlobalCulls.AddItem(modfind->second.second);
- ServerInstance->GlobalCulls.AddItem(modfind->second.first);
+ ServerInstance->GlobalCulls.AddItem(modfind->second);
Modules.erase(modfind);
ServerInstance->Logs->Log("MODULE", DEFAULT,"Module %s unloaded",filename);
@@ -746,9 +752,9 @@ const std::string& ModuleManager::GetModuleName(Module* m)
{
static std::string nothing;
- for (std::map<std::string, std::pair<ircd_module*, Module*> >::iterator n = Modules.begin(); n != Modules.end(); ++n)
+ for (std::map<std::string, Module*>::iterator n = Modules.begin(); n != Modules.end(); ++n)
{
- if (n->second.second == m)
+ if (n->second == m)
return n->first;
}
@@ -859,19 +865,19 @@ bool InspIRCd::AddResolver(Resolver* r, bool cached)
Module* ModuleManager::Find(const std::string &name)
{
- std::map<std::string, std::pair<ircd_module*, Module*> >::iterator modfind = Modules.find(name);
+ std::map<std::string, Module*>::iterator modfind = Modules.find(name);
if (modfind == Modules.end())
return NULL;
else
- return modfind->second.second;
+ return modfind->second;
}
const std::vector<std::string> ModuleManager::GetAllModuleNames(int filter)
{
std::vector<std::string> retval;
- for (std::map<std::string, std::pair<ircd_module*, Module*> >::iterator x = Modules.begin(); x != Modules.end(); ++x)
- if (!filter || (x->second.second->GetVersion().Flags & filter))
+ for (std::map<std::string, Module*>::iterator x = Modules.begin(); x != Modules.end(); ++x)
+ if (!filter || (x->second->GetVersion().Flags & filter))
retval.push_back(x->first);
return retval;
}
diff --git a/src/modules/m_lockserv.cpp b/src/modules/m_lockserv.cpp
index 78c15dead..fa5fc3a3f 100644
--- a/src/modules/m_lockserv.cpp
+++ b/src/modules/m_lockserv.cpp
@@ -33,7 +33,7 @@ public:
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
{
locked = true;
- user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server);
+ user->WriteNumeric(988, "%s %s :Closed for new connections", user->nick.c_str(), user->server.c_str());
ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily close for new connections", user->nick.c_str());
/* Dont send to the network */
return CMD_SUCCESS;
@@ -54,7 +54,7 @@ public:
CmdResult Handle (const std::vector<std::string> &parameters, User *user)
{
locked = false;
- user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server);
+ user->WriteNumeric(989, "%s %s :Open for new connections", user->nick.c_str(), user->server.c_str());
ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow for new connections", user->nick.c_str());
/* Dont send to the network */
return CMD_SUCCESS;
diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp
index db77184d6..0a9ce2edf 100644
--- a/src/modules/m_nokicks.cpp
+++ b/src/modules/m_nokicks.cpp
@@ -44,7 +44,7 @@ class ModuleNoKicks : public Module
{
if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet('Q')))
{
- if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
+ if ((ServerInstance->ULine(source->nick.c_str())) || ServerInstance->ULine(source->server))
{
// ulines can still kick with +Q in place
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index 8b8c1401e..c4ba99779 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -212,7 +212,6 @@ class NetworkPrefix : public ModeHandler
((source == theuser) && (!adding)) ||
(ServerInstance->ULine(source->nick.c_str())) ||
(ServerInstance->ULine(source->server)) ||
- (!*source->server) ||
(!IS_LOCAL(source))
)
{
@@ -289,7 +288,7 @@ class ModuleOjoin : public Module
ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason)
{
- if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
+ if ((ServerInstance->ULine(source->nick.c_str())) || ServerInstance->ULine(source->server))
return MOD_RES_PASSTHRU;
// Don't do anything if they're not +Y
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index b0829cc1d..8b9f40e0b 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -368,6 +368,7 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
failovers.push_back(s->myautoconnect);
Utils->timeoutlist.erase(me);
s->Close();
+ ServerInstance->GlobalCulls.AddItem(s);
}
}
for(unsigned int j=0; j < failovers.size(); j++)
@@ -963,7 +964,10 @@ void ModuleSpanningTree::OnEvent(Event* event)
bool ModuleSpanningTree::cull()
{
- return Utils->cull();
+ Utils->cull();
+ ServerInstance->Timers->DelTimer(RefreshTimer);
+ ServerInstance->Modules->DoneWithInterface("BufferedSocketHook");
+ return this->Module::cull();
}
ModuleSpanningTree::~ModuleSpanningTree()
@@ -976,10 +980,6 @@ ModuleSpanningTree::~ModuleSpanningTree()
delete command_rconnect;
delete command_rsquit;
-
- ServerInstance->Timers->DelTimer(RefreshTimer);
-
- ServerInstance->Modules->DoneWithInterface("BufferedSocketHook");
}
Version ModuleSpanningTree::GetVersion()
diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp
index a1ad88007..38b621fb5 100644
--- a/src/modules/m_spanningtree/opertype.cpp
+++ b/src/modules/m_spanningtree/opertype.cpp
@@ -57,7 +57,7 @@ bool TreeSocket::OperType(const std::string &prefix, parameterlist &params)
}
if (dosend)
- ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server, u->nick.c_str(),u->ident.c_str(), u->host.c_str(), irc::Spacify(opertype.c_str()));
+ ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), irc::Spacify(opertype.c_str()));
}
return true;
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index ffc533daf..95f686698 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -164,7 +164,7 @@ int TreeServer::QuitUsers(const std::string &reason)
std::vector<User*> time_to_die;
for (user_hash::iterator n = ServerInstance->Users->clientlist->begin(); n != ServerInstance->Users->clientlist->end(); n++)
{
- if (!strcmp(n->second->server, this->ServerName.c_str()))
+ if (n->second->server == ServerName)
{
time_to_die.push_back(n->second);
}
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 3744de96b..b29a0480c 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -136,6 +136,7 @@ class TreeSocket : public BufferedSocket
*/
void CleanNegotiationInfo();
+ bool cull();
/** Destructor
*/
~TreeSocket();
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index ad15a33c8..70046d774 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -70,7 +70,7 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, char* ip, Autocon
ServerInstance->Timers->AddTimer(hstimer);
/* Fix by Brain - inbound sockets need a timeout, too. 30 secs should be pleanty */
- Utils->timeoutlist[this] = std::pair<std::string, int>("<unknown>", 30);
+ Utils->timeoutlist[this] = std::pair<std::string, int>("<from " + std::string(ip) + ">", 30);
}
ServerState TreeSocket::GetLinkState()
@@ -88,13 +88,18 @@ void TreeSocket::CleanNegotiationInfo()
OutboundPass.clear();
}
-TreeSocket::~TreeSocket()
+bool TreeSocket::cull()
{
if (GetIOHook())
BufferedSocketUnhookRequest(this, Utils->Creator, GetIOHook()).Send();
+ Utils->timeoutlist.erase(this);
+ return this->BufferedSocket::cull();
+}
+
+TreeSocket::~TreeSocket()
+{
if (hstimer)
ServerInstance->Timers->DelTimer(hstimer);
- Utils->timeoutlist.erase(this);
}
/** When an outbound connection finishes connecting, we receive
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index f1a4e6256..96ca2236d 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -168,7 +168,7 @@ bool TreeSocket::ParseUID(const std::string &source, parameterlist &params)
dosend = false;
if (dosend)
- ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s [%s] [%s]", _new->server, _new->nick.c_str(), _new->ident.c_str(), _new->host.c_str(), _new->GetIPString(), _new->fullname.c_str());
+ ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s [%s] [%s]", _new->server.c_str(), _new->nick.c_str(), _new->ident.c_str(), _new->host.c_str(), _new->GetIPString(), _new->fullname.c_str());
params[params.size() - 1] = ":" + params[params.size() - 1];
Utils->DoOneToAllButSender(source, "UID", params, source);
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 7b6ea1565..3cdd495aa 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -171,6 +171,7 @@ bool SpanningTreeUtilities::cull()
{
TreeSocket* sock = child_server->GetSocket();
sock->Close();
+ ServerInstance->GlobalCulls.AddItem(sock);
}
}
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 023e2aa5a..e4bc3254e 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -244,7 +244,7 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char
if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit))
{
ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",
- user->server, user->nick.c_str(), user->ident.c_str(), user->host.c_str(), oper_reason.c_str());
+ user->server.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str(), oper_reason.c_str());
}
}
user->AddToWhoWas();
diff --git a/src/users.cpp b/src/users.cpp
index 93e7e89a6..222bde9e9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1298,7 +1298,6 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op
snprintf(tb2,MAXBUF,":%s QUIT :%s",this->GetFullHost().c_str(),oper_text.c_str());
std::string out1 = tb1;
std::string out2 = tb2;
- already_sent[this->fd] = uniq_id;
for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
{
diff --git a/src/whois.cpp b/src/whois.cpp
index 83bfd31da..3f0343343 100644
--- a/src/whois.cpp
+++ b/src/whois.cpp
@@ -40,7 +40,7 @@ void InspIRCd::DoWhois(User* user, User* dest,unsigned long signon, unsigned lon
}
else
{
- this->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server, this->GetServerDescription(dest->server).c_str());
+ this->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server.c_str(), this->GetServerDescription(dest->server).c_str());
}
if (IS_AWAY(dest))