diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 16 | ||||
-rw-r--r-- | src/operserv.cpp | 8 | ||||
-rw-r--r-- | src/servers.cpp | 39 |
4 files changed, 40 insertions, 25 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index 88b981dcc..940fd8f3b 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -49,7 +49,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A BotListByUID[this->uid] = this; // If we're synchronised with the uplink already, call introduce_user() for this bot. - if (Me && Me->GetUplink() && Me->GetUplink()->IsSynced()) + if (Me && !Me->GetLinks().empty() && Me->GetLinks().front()->IsSynced()) { ircdproto->SendClientIntroduction(this->nick, this->GetIdent(), this->host, this->realname, ircd->pseudoclient_mode, this->uid); XLine x(this->nick, "Reserved for services"); diff --git a/src/main.cpp b/src/main.cpp index 9f108a4d9..453dba91b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,8 +116,6 @@ class UplinkSocket : public ClientSocket ~UplinkSocket() { - /* Process the last bits of data before disconnecting */ - SocketEngine->Process(); UplinkSock = NULL; } @@ -188,6 +186,7 @@ void do_restart_services() UserListByUID.erase(it->second->GetUID()); } ircdproto->SendSquit(Config.ServerName, quitmsg); + SocketEngine->Process(); delete UplinkSock; close_log(); /* First don't unload protocol module, then do so */ @@ -236,6 +235,7 @@ static void services_shutdown() while (!UserListByNick.empty()) delete UserListByNick.begin()->second; } + SocketEngine->Process(); delete UplinkSock; FOREACH_MOD(I_OnShutdown, OnShutdown()); /* First don't unload protocol module, then do so */ @@ -553,6 +553,18 @@ int main(int ac, char **av, char **envp) delete u; } + /* Nuke all channels */ + for (channel_map::const_iterator it = ChannelList.begin(); it != ChannelList.end();) + { + Channel *c = it->second; + ++it; + + delete c; + } + + Me->SetFlag(SERVER_SYNCING); + Me->ClearLinks(); + unsigned j = 0; for (; j < (Config.MaxRetries ? Config.MaxRetries : j + 1); ++j) { diff --git a/src/operserv.cpp b/src/operserv.cpp index b39333932..d66088b03 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -130,8 +130,8 @@ void server_global(const Server *s, const Anope::string &message) if (!s->GetLinks().empty()) { - for (std::list<Server *>::const_iterator it = s->GetLinks().begin(), it_end = s->GetLinks().end(); it != it_end; ++it) - server_global(*it, message); + for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i) + server_global(s->GetLinks()[i], message); } } @@ -147,10 +147,10 @@ void oper_global(const Anope::string &nick, const char *fmt, ...) if (!nick.empty() && !Config.AnonymousGlobal) { Anope::string rmsg = "[" + nick + "] " + msg; - server_global(Me->GetUplink(), rmsg); + server_global(Me->GetLinks().front(), rmsg); } else - server_global(Me->GetUplink(), msg); + server_global(Me->GetLinks().front(), msg); } /**************************************************************************/ diff --git a/src/servers.cpp b/src/servers.cpp index 664d8fb0a..a029890f7 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -114,7 +114,7 @@ Server::~Server() if (this->UplinkServer) this->UplinkServer->DelLink(this); - for (std::list<Server *>::iterator it = this->Links.begin(), it_end = this->Links.end(); it != it_end; ++it) + for (std::vector<Server *>::iterator it = this->Links.begin(), it_end = this->Links.end(); it != it_end; ++it) delete *it; } @@ -170,7 +170,7 @@ const Anope::string &Server::GetSID() const /** Get the list of links this server has, or NULL if it has none * @return A list of servers */ -const std::list<Server*> &Server::GetLinks() const +const std::vector<Server *> &Server::GetLinks() const { return this->Links; } @@ -188,12 +188,6 @@ Server *Server::GetUplink() */ void Server::AddLink(Server *s) { - /* This is only used for Me, initially we start services with an uplink of NULL, then - * connect to the server which introduces itself and has us as the uplink, which calls this - */ - if (this == Me && !this->UplinkServer) - this->UplinkServer = s; - this->Links.push_back(s); Alog() << "Server " << s->GetName() << " introduced from " << this->GetName(); @@ -207,11 +201,11 @@ void Server::DelLink(Server *s) if (this->Links.empty()) throw CoreException("Server::DelLink called on " + this->GetName() + " for " + s->GetName() + " but we have no links?"); - for (std::list<Server *>::iterator it = this->Links.begin(), it_end = this->Links.end(); it != it_end; ++it) + for (unsigned i = 0, j = this->Links.size(); i < j; ++i) { - if (*it == s) + if (this->Links[i] == s) { - this->Links.erase(it); + this->Links.erase(this->Links.begin() + i); break; } } @@ -219,6 +213,15 @@ void Server::DelLink(Server *s) Alog() << "Server " << s->GetName() << " quit from " << this->GetName(); } +/** Remov all links from this server + */ +void Server::ClearLinks() +{ + for (unsigned i = 0, j = this->Links.size(); i < j; ++i) + delete this->Links[i]; + this->Links.clear(); +} + /** Finish syncing this server and optionally all links to it * @param SyncLinks True to sync the links for this server too (if any) */ @@ -231,11 +234,11 @@ void Server::Sync(bool SyncLinks) if (SyncLinks && !this->Links.empty()) { - for (std::list<Server *>::iterator it = this->Links.begin(), it_end = this->Links.end(); it != it_end; ++it) - (*it)->Sync(true); + for (unsigned i = 0, j = this->Links.size(); i < j; ++i) + this->Links[i]->Sync(true); } - if (this == Me->GetUplink()) + if (this == Me->GetLinks().front()) { FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this)); ircdproto->SendEOB(); @@ -246,7 +249,7 @@ void Server::Sync(bool SyncLinks) FOREACH_MOD(I_OnServerSync, OnServerSync(this)); - if (this == Me->GetUplink()) + if (this == Me->GetLinks().front()) { FOREACH_MOD(I_OnUplinkSync, OnUplinkSync(this)); restore_unsynced_topics(); @@ -288,9 +291,9 @@ Server *Server::Find(const Anope::string &name, Server *s) if (!s->GetLinks().empty()) { - for (std::list<Server *>::const_iterator it = s->GetLinks().begin(), it_end = s->GetLinks().end(); it != it_end; ++it) + for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i) { - Server *serv = *it; + Server *serv = s->GetLinks()[i]; if (serv->GetName().equals_cs(name) || serv->GetSID().equals_cs(name)) return serv; @@ -378,7 +381,7 @@ void do_squit(const Anope::string &source, int ac, const char **av) buf = s->GetName() + " " + s->GetUplink()->GetName(); - if (s->GetUplink() == Me->GetUplink() && Capab.HasFlag(CAPAB_UNCONNECT)) + if (s->GetUplink() == Me && Capab.HasFlag(CAPAB_UNCONNECT)) { Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->GetName(); /* need to fix */ |