summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
67a4a9b)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11888
e03df62e-2008-0410-955e-
edbf42e46eb7
31 files changed:
#include <deque>
#include <string>
#include <deque>
#include <string>
-/** The base class for all inspircd classes.
- * Wherever possible, all classes you create should inherit from this,
- * giving them the ability to be passed to various core functions
- * as 'anonymous' classes.
-*/
+/** Dummy class to help enforce culls being parent-called up to classbase */
+class CullResult
+{
+ CullResult();
+ friend class classbase;
+};
+
+/** The base class for all inspircd classes with a well-defined lifetime.
+ * Classes that inherit from this may be destroyed through GlobalCulls,
+ * and may rely on cull() being called prior to their deletion.
+ */
class CoreExport classbase
{
public:
class CoreExport classbase
{
public:
*
* @return true to allow the delete, or false to halt the delete
*/
*
* @return true to allow the delete, or false to halt the delete
*/
+ virtual CullResult cull();
+ private:
+ // uncopyable
+ classbase(const classbase&);
+ void operator=(const classbase&);
};
/** The base class for inspircd classes that support reference counting.
* Any objects that do not have a well-defined lifetime should inherit from
};
/** The base class for inspircd classes that support reference counting.
* Any objects that do not have a well-defined lifetime should inherit from
+ * this, and should be assigned to a reference<type> object to establish their
+ * lifetime.
+ *
+ * Reference objects should not hold circular references back to themselves,
+ * even indirectly; this will cause a memory leak because the count will never
+ * drop to zero.
+ *
+ * Using a normal pointer for the object is recommended if you can assure that
+ * at least one reference<> will remain as long as that pointer is used; this
+ * will avoid the slight overhead of changing the reference count.
-class CoreExport refcountbase : public classbase
+class CoreExport refcountbase
{
unsigned int refcount;
public:
refcountbase();
{
unsigned int refcount;
public:
refcountbase();
virtual ~refcountbase();
inline unsigned int GetReferenceCount() const { return refcount; }
friend class reference_base;
virtual ~refcountbase();
inline unsigned int GetReferenceCount() const { return refcount; }
friend class reference_base;
+ private:
+ // uncopyable
+ refcountbase(const refcountbase&);
+ void operator=(const refcountbase&);
};
class CoreExport reference_base
};
class CoreExport reference_base
if (value)
{
int rc = dec(value);
if (value)
{
int rc = dec(value);
- if (rc == 0 && value->cull())
/** Holds an entry for a ban list, exemption list, or invite list.
* This class contains a single element in a channel list, such as a banlist.
*/
/** Holds an entry for a ban list, exemption list, or invite list.
* This class contains a single element in a channel list, such as a banlist.
*/
-class HostItem : public classbase
{
public:
/** Time the item was added
{
public:
/** Time the item was added
/**
* Result status, used internally
*/
/**
* Result status, used internally
*/
-class CoreExport DNSResult : public classbase
+class CoreExport DNSResult
/** Cached item stored in the query cache.
*/
/** Cached item stored in the query cache.
*/
-class CoreExport CachedQuery : public classbase
+class CoreExport CachedQuery
{
public:
/** The cached result data, an IP or hostname
{
public:
/** The cached result data, an IP or hostname
* can occur by calling virtual methods, one is a success situation, and the other
* an error situation.
*/
* can occur by calling virtual methods, one is a success situation, and the other
* an error situation.
*/
-class CoreExport Resolver : public Extensible
+class CoreExport Resolver
*/
inline const ExtensibleStore& GetExtList() const { return extensions; }
*/
inline const ExtensibleStore& GetExtList() const { return extensions; }
+ virtual CullResult cull();
virtual ~Extensible();
void doUnhookExtensions(const std::vector<ExtensionItem*>& toRemove);
};
virtual ~Extensible();
void doUnhookExtensions(const std::vector<ExtensionItem*>& toRemove);
};
* std::string, or a const char* const* array, using overloaded
* constructors.
*/
* std::string, or a const char* const* array, using overloaded
* constructors.
*/
- class CoreExport stringjoiner : public classbase
+ class CoreExport stringjoiner
* It can then reproduce this list, clamped to a maximum of MAXMODES
* values per line.
*/
* It can then reproduce this list, clamped to a maximum of MAXMODES
* values per line.
*/
- class CoreExport modestacker : public classbase
+ class CoreExport modestacker
{
private:
/** The mode sequence and its parameters
{
private:
/** The mode sequence and its parameters
* list will be ":item". This is to allow for parsing 'source' fields
* from data.
*/
* list will be ":item". This is to allow for parsing 'source' fields
* from data.
*/
- class CoreExport tokenstream : public classbase
+ class CoreExport tokenstream
* the next token, until none remain, at which point the method returns
* an empty string.
*/
* the next token, until none remain, at which point the method returns
* an empty string.
*/
- class CoreExport sepstream : public classbase
+ class CoreExport sepstream
{
private:
/** Original string.
{
private:
/** Original string.
* start or end < 0) then GetToken() will return the first element
* of the pair of numbers.
*/
* start or end < 0) then GetToken() will return the first element
* of the pair of numbers.
*/
- class CoreExport portparser : public classbase
+ class CoreExport portparser
*/
virtual void Close();
/** This ensures that close is called prior to destructor */
*/
virtual void Close();
/** This ensures that close is called prior to destructor */
+ virtual CullResult cull();
};
/**
* BufferedSocket is an extendable socket class which modules
};
/**
* BufferedSocket is an extendable socket class which modules
* @param type Type of the mode (MODETYPE_USER or MODETYPE_CHANNEL)
*/
ModeHandler(Module* me, const std::string& name, char modeletter, ParamSpec params, ModeType type);
* @param type Type of the mode (MODETYPE_USER or MODETYPE_CHANNEL)
*/
ModeHandler(Module* me, const std::string& name, char modeletter, ParamSpec params, ModeType type);
+ virtual CullResult cull();
virtual ~ModeHandler();
/**
* Returns true if the mode is a list mode
virtual ~ModeHandler();
/**
* Returns true if the mode is a list mode
* error when attempting to load a module compiled against a different API_VERSION.
*/
template<int api>
* error when attempting to load a module compiled against a different API_VERSION.
*/
template<int api>
-class CoreExport VersionBase : public classbase
+class CoreExport VersionBase
{
public:
/** Module description
{
public:
/** Module description
* its methods will be called when irc server events occur. class inherited from module must be
* instantiated by the ModuleFactory class (see relevent section) for the module to be initialised.
*/
* its methods will be called when irc server events occur. class inherited from module must be
* instantiated by the ModuleFactory class (see relevent section) for the module to be initialised.
*/
-class CoreExport Module : public Extensible
+class CoreExport Module : public classbase
{
public:
/** File that this module was loaded from
{
public:
/** File that this module was loaded from
/** Clean up prior to destruction
* If you override, you must call this AFTER your module's cleanup
*/
/** Clean up prior to destruction
* If you override, you must call this AFTER your module's cleanup
*/
+ virtual CullResult cull();
/** Default destructor.
* destroys a module class
/** Default destructor.
* destroys a module class
/** Default destructor
*/
virtual ~User();
/** Default destructor
*/
virtual ~User();
+ virtual CullResult cull();
};
/** Derived from Resolver, and performs user forward/reverse lookups.
};
/** Derived from Resolver, and performs user forward/reverse lookups.
+CullResult classbase::cull()
}
classbase::~classbase()
{
}
}
classbase::~classbase()
{
}
-refcountbase::refcountbase() : refcount(0)
+CullResult::CullResult()
-bool refcountbase::cull()
+refcountbase::refcountbase() : refcount(0)
- return (refcount == 0);
}
refcountbase::~refcountbase()
}
refcountbase::~refcountbase()
-Extensible::~Extensible()
+CullResult Extensible::cull()
{
for(ExtensibleStore::iterator i = extensions.begin(); i != extensions.end(); ++i)
{
i->first->free(i->second);
}
{
for(ExtensibleStore::iterator i = extensions.begin(); i != extensions.end(); ++i)
{
i->first->free(i->second);
}
+ return classbase::cull();
+}
+
+Extensible::~Extensible()
+{
}
LocalExtItem::LocalExtItem(const std::string& Key, Module* mod) : ExtensionItem(Key, mod)
}
LocalExtItem::LocalExtItem(const std::string& Key, Module* mod) : ExtensionItem(Key, mod)
{
ServerInstance->Logs->Log("CULLLIST", DEBUG, "Deleting %s @%p", typeid(*c).name(),
(void*)c);
{
ServerInstance->Logs->Log("CULLLIST", DEBUG, "Deleting %s @%p", typeid(*c).name(),
(void*)c);
- if (c->cull())
- queue.push_back(c);
+ c->cull();
+ queue.push_back(c);
-bool StreamSocket::cull()
+CullResult StreamSocket::cull()
+ return EventHandler::cull();
}
bool StreamSocket::GetNextLine(std::string& line, char delim)
}
bool StreamSocket::GetNextLine(std::string& line, char delim)
-bool ModeHandler::cull()
+CullResult ModeHandler::cull()
{
ServerInstance->Modes->DelMode(this);
{
ServerInstance->Modes->DelMode(this);
+ return classbase::cull();
}
ModeHandler::~ModeHandler()
}
ModeHandler::~ModeHandler()
ModeParser::~ModeParser()
{
ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
ModeParser::~ModeParser()
{
ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL);
+ if (mh)
+ {
+ mh->cull();
// These declarations define the behavours of the base class Module (which does nothing at all)
Module::Module() { }
// These declarations define the behavours of the base class Module (which does nothing at all)
Module::Module() { }
+CullResult Module::cull()
+ return classbase::cull();
/** An alias definition
*/
/** An alias definition
*/
-class Alias : public classbase
{
public:
/** The text of the alias command */
{
public:
/** The text of the alias command */
/* Originally written by Om, January 2009
*/
/* Originally written by Om, January 2009
*/
-class BanRedirectEntry : public classbase
{
public:
std::string targetchan;
{
public:
std::string targetchan;
/** Holds a CGI site's details
*/
/** Holds a CGI site's details
*/
-class CGIhost : public classbase
{
public:
std::string hostmask;
{
public:
std::string hostmask;
static ConfigReader *Conf;
static ConfigReader *Conf;
-class BannedFileList : public classbase
{
public:
std::string filemask;
std::string action;
};
{
public:
std::string filemask;
std::string action;
};
-class DCCAllow : public classbase
{
public:
std::string nickname;
{
public:
std::string nickname;
-class FilterResult : public classbase
{
public:
std::string freeform;
{
public:
std::string freeform;
#include "protocol.h"
/* $ModDesc: Provides access control lists (passwording of resources, ip restrictions etc) to m_httpd.so dependent modules */
#include "protocol.h"
/* $ModDesc: Provides access control lists (passwording of resources, ip restrictions etc) to m_httpd.so dependent modules */
-class HTTPACL : public Extensible
{
public:
std::string path;
{
public:
std::string path;
void DumpMeta(std::stringstream& data, Extensible* ext)
{
data << "<metadata>";
void DumpMeta(std::stringstream& data, Extensible* ext)
{
data << "<metadata>";
- for(ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++)
+ for(Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++)
{
ExtensionItem* item = i->first;
std::string value = item->serialize(FORMAT_USER, ext, i->second);
{
ExtensionItem* item = i->first;
std::string value = item->serialize(FORMAT_USER, ext, i->second);
s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata);
}
s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata);
}
-bool ModuleSpanningTree::cull()
+CullResult ModuleSpanningTree::cull()
{
Utils->cull();
ServerInstance->Timers->DelTimer(RefreshTimer);
{
Utils->cull();
ServerInstance->Timers->DelTimer(RefreshTimer);
void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
void OnLoadModule(Module* mod);
void OnUnloadModule(Module* mod);
void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
void OnLoadModule(Module* mod);
void OnUnloadModule(Module* mod);
~ModuleSpanningTree();
Version GetVersion();
void Prioritize();
~ModuleSpanningTree();
Version GetVersion();
void Prioritize();
*/
void CleanNegotiationInfo();
*/
void CleanNegotiationInfo();
/** Destructor
*/
~TreeSocket();
/** Destructor
*/
~TreeSocket();
+CullResult TreeSocket::cull()
{
Utils->timeoutlist.erase(this);
if (myautoconnect)
{
Utils->timeoutlist.erase(this);
if (myautoconnect)
this->ReadConfiguration(true);
}
this->ReadConfiguration(true);
}
-bool SpanningTreeUtilities::cull()
+CullResult SpanningTreeUtilities::cull()
{
for (unsigned int i = 0; i < ServerInstance->ports.size(); i++)
{
{
for (unsigned int i = 0; i < ServerInstance->ports.size(); i++)
{
}
ServerUser->uuid = TreeRoot->GetID();
}
ServerUser->uuid = TreeRoot->GetID();
- if (ServerUser->cull())
- delete ServerUser;
- return true;
+ ServerUser->cull();
+ delete ServerUser;
+ return classbase::cull();
}
SpanningTreeUtilities::~SpanningTreeUtilities()
}
SpanningTreeUtilities::~SpanningTreeUtilities()
/** Prepare for class destruction
*/
/** Prepare for class destruction
*/
/** Destroy class and free listeners etc
*/
/** Destroy class and free listeners etc
*/
* The error string varies from database software to database software
* and should be used to display informational error messages to users.
*/
* The error string varies from database software to database software
* and should be used to display informational error messages to users.
*/
-class SQLerror : public classbase
*
* SQLrequest foo = SQLrequest(this, target, "databaseid", (SQLquery("SELECT.. ?"), parameter, parameter));
*/
*
* SQLrequest foo = SQLrequest(this, target, "databaseid", (SQLquery("SELECT.. ?"), parameter, parameter));
*/
-class SQLquery : public classbase
{
public:
/** The query 'format string'
{
public:
/** The query 'format string'
+ // Copy constructor - XXX probably shouldn't be needed
+ SQLrequest(const SQLrequest& o)
+ : Request(o.source, o.dest, SQLREQID), query(o.query), dbid(o.dbid), pri(o.pri), cancel(o.cancel),
+ id(o.id), error(o.error) {}
+
/** Set the priority of a request.
*/
void Priority(bool p = true)
/** Set the priority of a request.
*/
void Priority(bool p = true)
* until pop() is called.
*/
* until pop() is called.
*/
-class QueryQueue : public classbase
{
private:
typedef std::deque<SQLrequest*> ReqDeque;
{
private:
typedef std::deque<SQLrequest*> ReqDeque;
-class TimedBan : public classbase
{
public:
std::string channel;
{
public:
std::string channel;
/** An item in a listmode's list
*/
/** An item in a listmode's list
*/
-class ListItem : public classbase
{
public:
std::string nick;
{
public:
std::string nick;
/** The number of items a listmode's list may contain
*/
/** The number of items a listmode's list may contain
*/
-class ListLimit : public classbase
{
public:
std::string mask;
{
public:
std::string mask;
ServerInstance->Users->QuitUser(this, getError());
}
ServerInstance->Users->QuitUser(this, getError());
}
{
if (!quitting)
ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
if (uuid.empty())
{
ServerInstance->Logs->Log("USERS", DEBUG, "User culled twice? UUID empty");
{
if (!quitting)
ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
if (uuid.empty())
{
ServerInstance->Logs->Log("USERS", DEBUG, "User culled twice? UUID empty");
+ return Extensible::cull();
}
PurgeEmptyChannels();
if (IS_LOCAL(this))
}
PurgeEmptyChannels();
if (IS_LOCAL(this))
ServerInstance->Users->uuidlist->erase(uuid);
uuid.clear();
ServerInstance->Users->uuidlist->erase(uuid);
uuid.clear();
+ return Extensible::cull();
}
void User::Oper(const std::string &opertype, const std::string &opername)
}
void User::Oper(const std::string &opertype, const std::string &opername)