From 9db7af579c46a9f0379fdf71fb773a0a76a94846 Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 17 Oct 2009 18:52:39 +0000 Subject: Make classbase and refcountbase uncopyable; expand comments on their indended uses git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11888 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/base.cpp | 16 ++++++++++------ src/cull_list.cpp | 4 ++-- src/inspsocket.cpp | 4 ++-- src/mode.cpp | 9 ++++++--- src/modules.cpp | 4 ++-- src/modules/m_alias.cpp | 2 +- src/modules/m_banredirect.cpp | 2 +- src/modules/m_cgiirc.cpp | 2 +- src/modules/m_dccallow.cpp | 4 ++-- src/modules/m_filter.cpp | 2 +- src/modules/m_httpd_acl.cpp | 3 +-- src/modules/m_httpd_stats.cpp | 2 +- src/modules/m_spanningtree/main.cpp | 2 +- src/modules/m_spanningtree/main.h | 2 +- src/modules/m_spanningtree/treesocket.h | 2 +- src/modules/m_spanningtree/treesocket1.cpp | 2 +- src/modules/m_spanningtree/utils.cpp | 8 ++++---- src/modules/m_spanningtree/utils.h | 2 +- src/modules/m_sqlv2.h | 11 ++++++++--- src/modules/m_timedbans.cpp | 2 +- src/modules/u_listmode.h | 4 ++-- src/users.cpp | 6 +++--- 22 files changed, 53 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/base.cpp b/src/base.cpp index 1b01da707..2e2dbfb28 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -22,22 +22,21 @@ classbase::classbase() { } -bool classbase::cull() +CullResult classbase::cull() { - return true; + return CullResult(); } classbase::~classbase() { } -refcountbase::refcountbase() : refcount(0) +CullResult::CullResult() { } -bool refcountbase::cull() +refcountbase::refcountbase() : refcount(0) { - return (refcount == 0); } refcountbase::~refcountbase() @@ -129,12 +128,17 @@ void Extensible::doUnhookExtensions(const std::vector& toRemove) } } -Extensible::~Extensible() +CullResult Extensible::cull() { 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) diff --git a/src/cull_list.cpp b/src/cull_list.cpp index 6033ec695..1ce6dfae1 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -26,8 +26,8 @@ void CullList::Apply() { 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); } else { diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 37335c855..fc8bc142f 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -145,10 +145,10 @@ void StreamSocket::Close() errno = save; } -bool StreamSocket::cull() +CullResult StreamSocket::cull() { Close(); - return true; + return EventHandler::cull(); } bool StreamSocket::GetNextLine(std::string& line, char delim) diff --git a/src/mode.cpp b/src/mode.cpp index 144ddee72..47553f238 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -53,10 +53,10 @@ ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modelett { } -bool ModeHandler::cull() +CullResult ModeHandler::cull() { ServerInstance->Modes->DelMode(this); - return true; + return classbase::cull(); } ModeHandler::~ModeHandler() @@ -1027,6 +1027,9 @@ ModeParser::ModeParser() ModeParser::~ModeParser() { ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL); - if (mh && mh->cull()) + if (mh) + { + mh->cull(); delete mh; + } } diff --git a/src/modules.cpp b/src/modules.cpp index 913293e13..2dafc8864 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -52,9 +52,9 @@ void Event::Send() // These declarations define the behavours of the base class Module (which does nothing at all) Module::Module() { } -bool Module::cull() +CullResult Module::cull() { - return true; + return classbase::cull(); } Module::~Module() { } diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 6aa1f6c36..62c02396a 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -17,7 +17,7 @@ /** An alias definition */ -class Alias : public classbase +class Alias { public: /** The text of the alias command */ diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index fdc5b1220..cf6c27828 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -20,7 +20,7 @@ /* Originally written by Om, January 2009 */ -class BanRedirectEntry : public classbase +class BanRedirectEntry { public: std::string targetchan; diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 04e35adcb..53c761b3e 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -26,7 +26,7 @@ enum CGItype { INVALID, PASS, IDENT, PASSFIRST, IDENTFIRST, WEBIRC }; /** Holds a CGI site's details */ -class CGIhost : public classbase +class CGIhost { public: std::string hostmask; diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index c202a97b4..d4be35ceb 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -17,14 +17,14 @@ static ConfigReader *Conf; -class BannedFileList : public classbase +class BannedFileList { public: std::string filemask; std::string action; }; -class DCCAllow : public classbase +class DCCAllow { public: std::string nickname; diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index a9187098b..0220a3a44 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -28,7 +28,7 @@ enum FilterFlags FLAG_NOTICE = 16 }; -class FilterResult : public classbase +class FilterResult { public: std::string freeform; diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp index dd6f5a8bb..85ec4b6cd 100644 --- a/src/modules/m_httpd_acl.cpp +++ b/src/modules/m_httpd_acl.cpp @@ -16,9 +16,8 @@ #include "protocol.h" /* $ModDesc: Provides access control lists (passwording of resources, ip restrictions etc) to m_httpd.so dependent modules */ -/* $ModDep: httpd.h */ -class HTTPACL : public Extensible +class HTTPACL { public: std::string path; diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index a075bc59c..a451f6af9 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -69,7 +69,7 @@ class ModuleHttpStats : public Module void DumpMeta(std::stringstream& data, Extensible* ext) { data << ""; - 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); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index afd40e0c9..e46c2d320 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -944,7 +944,7 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata); } -bool ModuleSpanningTree::cull() +CullResult ModuleSpanningTree::cull() { Utils->cull(); ServerInstance->Timers->DelTimer(RefreshTimer); diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index be9c460d9..692442598 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -190,7 +190,7 @@ class ModuleSpanningTree : public Module void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata); void OnLoadModule(Module* mod); void OnUnloadModule(Module* mod); - bool cull(); + CullResult cull(); ~ModuleSpanningTree(); Version GetVersion(); void Prioritize(); diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index a0f0e5d88..b5f97c30f 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -133,7 +133,7 @@ class TreeSocket : public BufferedSocket */ void CleanNegotiationInfo(); - bool cull(); + CullResult cull(); /** Destructor */ ~TreeSocket(); diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index d99d8d6c9..f6f237529 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -103,7 +103,7 @@ void TreeSocket::CleanNegotiationInfo() OutboundPass.clear(); } -bool TreeSocket::cull() +CullResult TreeSocket::cull() { Utils->timeoutlist.erase(this); if (myautoconnect) diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 09333fdd2..024605a79 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -151,7 +151,7 @@ SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) : Creator(C) this->ReadConfiguration(true); } -bool SpanningTreeUtilities::cull() +CullResult SpanningTreeUtilities::cull() { for (unsigned int i = 0; i < ServerInstance->ports.size(); i++) { @@ -171,9 +171,9 @@ bool SpanningTreeUtilities::cull() } ServerUser->uuid = TreeRoot->GetID(); - if (ServerUser->cull()) - delete ServerUser; - return true; + ServerUser->cull(); + delete ServerUser; + return classbase::cull(); } SpanningTreeUtilities::~SpanningTreeUtilities() diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 48677e57d..2fc7304af 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -133,7 +133,7 @@ class SpanningTreeUtilities : public classbase /** Prepare for class destruction */ - bool cull(); + CullResult cull(); /** Destroy class and free listeners etc */ diff --git a/src/modules/m_sqlv2.h b/src/modules/m_sqlv2.h index bcdcb6546..05079a8e6 100644 --- a/src/modules/m_sqlv2.h +++ b/src/modules/m_sqlv2.h @@ -61,7 +61,7 @@ public: * 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 +class SQLerror { /** The error id */ @@ -149,7 +149,7 @@ public: * * SQLrequest foo = SQLrequest(this, target, "databaseid", (SQLquery("SELECT.. ?"), parameter, parameter)); */ -class SQLquery : public classbase +class SQLquery { public: /** The query 'format string' @@ -242,6 +242,11 @@ public: { } + // 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) @@ -489,7 +494,7 @@ bool operator!= (const SQLhost& l, const SQLhost& r) * until pop() is called. */ -class QueryQueue : public classbase +class QueryQueue { private: typedef std::deque ReqDeque; diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 02e687b2d..94301bb7b 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -17,7 +17,7 @@ /** Holds a timed ban */ -class TimedBan : public classbase +class TimedBan { public: std::string channel; diff --git a/src/modules/u_listmode.h b/src/modules/u_listmode.h index 1516b724c..0ca44547f 100644 --- a/src/modules/u_listmode.h +++ b/src/modules/u_listmode.h @@ -25,7 +25,7 @@ inline std::string stringtime() /** An item in a listmode's list */ -class ListItem : public classbase +class ListItem { public: std::string nick; @@ -35,7 +35,7 @@ public: /** The number of items a listmode's list may contain */ -class ListLimit : public classbase +class ListLimit { public: std::string mask; diff --git a/src/users.cpp b/src/users.cpp index 657225069..542a6e565 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -583,14 +583,14 @@ void User::OnError(BufferedSocketError) ServerInstance->Users->QuitUser(this, getError()); } -bool User::cull() +CullResult User::cull() { if (!quitting) ServerInstance->Users->QuitUser(this, "Culled without QuitUser"); if (uuid.empty()) { ServerInstance->Logs->Log("USERS", DEBUG, "User culled twice? UUID empty"); - return true; + return Extensible::cull(); } PurgeEmptyChannels(); if (IS_LOCAL(this)) @@ -625,7 +625,7 @@ bool User::cull() ServerInstance->Users->uuidlist->erase(uuid); uuid.clear(); - return true; + return Extensible::cull(); } void User::Oper(const std::string &opertype, const std::string &opername) -- cgit v1.2.3