From 5d6d076cc3e6585ec3b52e1b7281767ed4760cb0 Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 24 Oct 2007 15:12:10 +0000 Subject: Start of refcount-based rehash stuff for tags, this is broken and rather ugly right now.. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8342 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 22 +++++++++++++++++++--- src/users.cpp | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/configreader.cpp b/src/configreader.cpp index a0fe67c5f..28c82ef77 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -265,7 +265,7 @@ bool ValidateServerName(ServerConfig* conf, const char*, const char*, ValueItem if ((strcasecmp(conf->ServerName, data.GetString())) && (*conf->ServerName)) { throw CoreException("Configuration error: You cannot change your servername at runtime! Please restart your server for this change to be applied."); - /* XXX: We don't actually reach this return of course... */ + /* We don't actually reach this return of course... */ return false; } if (!strchr(data.GetString(),'.')) @@ -412,7 +412,21 @@ bool ValidateWhoWas(ServerConfig* conf, const char*, const char*, ValueItem &dat bool InitConnect(ServerConfig* conf, const char*) { conf->GetInstance()->Log(DEFAULT,"Reading connect classes..."); - conf->Classes.clear(); + +goagain: + /* change this: only delete a class with refcount 0 */ + for (ClassVector::iterator i = conf->Classes.begin(); i != conf->Classes.end(); i++) + { + ConnectClass *c = &(*i); + + if (c->RefCount == 0) + { + conf->GetInstance()->Log(DEFAULT, "Removing connect class, refcount is 0!"); + conf->Classes.erase(i); + goto goagain; // XXX fucking hell.. how better to do this + } + } + return true; } @@ -420,6 +434,7 @@ bool InitConnect(ServerConfig* conf, const char*) */ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*) { + conf->GetInstance()->Log(DEFAULT,"Adding a connect class!"); ConnectClass c; const char* allow = values[0].GetString(); /* Yeah, there are a lot of values. Live with it. */ const char* deny = values[1].GetString(); @@ -474,8 +489,9 @@ bool DoConnect(ServerConfig* conf, const char*, char**, ValueList &values, int*) /* Callback called when there are no more tags */ -bool DoneConnect(ServerConfig*, const char*) +bool DoneConnect(ServerConfig *conf, const char*) { + conf->GetInstance()->Log(DEFAULT, "Done adding connect classes!"); return true; } diff --git a/src/users.cpp b/src/users.cpp index c6ebcc848..0e08a8848 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1760,13 +1760,13 @@ ConnectClass* User::SetClass(const std::string &explicit_name) /* should always be valid, but just in case .. */ if (this->MyClass) { - ServerInstance->Log(DEBUG, "Untying user from connect class -- refcount: %u", this->MyClass->RefCount); this->MyClass->RefCount--; + ServerInstance->Log(DEBUG, "Untying user from connect class -- refcount: %u", this->MyClass->RefCount); } this->MyClass = found; this->MyClass->RefCount++; - ServerInstance->Log(DEBUG, "User tied to class -- connect refcount now: %u", this->MyClass->RefCount); + ServerInstance->Log(DEBUG, "User tied to new class -- connect refcount now: %u", this->MyClass->RefCount); } return this->MyClass; -- cgit v1.2.3