summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/servers.h8
-rw-r--r--modules/core/os_jupe.cpp2
-rw-r--r--modules/core/os_stats.cpp8
-rw-r--r--modules/protocol/bahamut.cpp2
-rw-r--r--modules/protocol/inspircd11.cpp2
-rw-r--r--src/bots.cpp2
-rw-r--r--src/main.cpp16
-rw-r--r--src/operserv.cpp8
-rw-r--r--src/servers.cpp39
9 files changed, 53 insertions, 34 deletions
diff --git a/include/servers.h b/include/servers.h
index efb6ace62..cbf017df8 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -86,7 +86,7 @@ class CoreExport Server : public Flags<ServerFlag>
/* Server ID */
Anope::string SID;
/* Links for this server */
- std::list<Server *> Links;
+ std::vector<Server *> Links;
/* Uplink for this server */
Server *UplinkServer;
@@ -140,7 +140,7 @@ class CoreExport Server : public Flags<ServerFlag>
/** Get the list of links this server has, or NULL if it has none
* @return A list of servers
*/
- const std::list<Server *> &GetLinks() const;
+ const std::vector<Server *> &GetLinks() const;
/** Get the uplink server for this server, if this is our uplink will be Me
* @return The servers uplink
@@ -157,6 +157,10 @@ class CoreExport Server : public Flags<ServerFlag>
*/
void DelLink(Server *s);
+ /** Remove all links from this server
+ */
+ void ClearLinks();
+
/** Finish syncing this server and optionally all links to it
* @param SyncLinks True to sync the links for this server too (if any)
*/
diff --git a/modules/core/os_jupe.cpp b/modules/core/os_jupe.cpp
index a6d478708..220e88abd 100644
--- a/modules/core/os_jupe.cpp
+++ b/modules/core/os_jupe.cpp
@@ -28,7 +28,7 @@ class CommandOSJupe : public Command
if (!isValidHost(jserver, 3))
notice_lang(Config.s_OperServ, u, OPER_JUPE_HOST_ERROR);
- else if (server && (server == Me || server == Me->GetUplink()))
+ else if (server && (server == Me || server == Me->GetLinks().front()))
notice_lang(Config.s_OperServ, u, OPER_JUPE_INVALID_SERVER);
else
{
diff --git a/modules/core/os_stats.cpp b/modules/core/os_stats.cpp
index 9cb3865a1..efbf62e2f 100644
--- a/modules/core/os_stats.cpp
+++ b/modules/core/os_stats.cpp
@@ -28,8 +28,8 @@ static int stats_count_servers(Server *s)
int count = 1;
if (!s->GetLinks().empty())
- for (std::list<Server *>::const_iterator it = s->GetLinks().begin(), it_end = s->GetLinks().end(); it != it_end; ++it)
- count += stats_count_servers(*it);
+ for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i)
+ count += stats_count_servers(s->GetLinks()[i]);
return count;
}
@@ -209,9 +209,9 @@ class CommandOSStats : public Command
if (!buf.empty())
buf.erase(buf.begin());
- notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, Me->GetUplink()->GetName().c_str());
+ notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, Me->GetLinks().front()->GetName().c_str());
notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf.c_str());
- notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(Me->GetUplink()));
+ notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(Me->GetLinks().front()));
return MOD_CONT;
}
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 724c59879..d71e88dd3 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -700,7 +700,7 @@ int anope_event_burst(const Anope::string &source, int ac, const char **av)
* server finished bursting. -GD
*/
if (!s)
- s = Me->GetUplink();
+ s = Me->GetLinks().front();
if (s)
s->Sync(true);
}
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index e7297b679..c13ee1120 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -1036,7 +1036,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
int anope_event_endburst(const Anope::string &source, int ac, const char **av)
{
- Me->GetUplink()->Sync(true);
+ Me->GetLinks().front()->Sync(true);
return MOD_CONT;
}
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 */