summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-07-27 18:59:43 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-07-27 18:59:43 +0200
commitc1fa07d2eb6146a9e3f6c26f478a22b119032d27 (patch)
treecc3bb95c8419b527f7efb36f52c93d490e5b60be
parent6c37b451cd2bb948d562cb00354bdc7a7dc400da (diff)
m_spanningtree Sync bursting state of servers in SERVER
Also send the time when they started bursting
-rw-r--r--src/modules/m_spanningtree/compat.cpp5
-rw-r--r--src/modules/m_spanningtree/server.cpp6
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp6
3 files changed, 14 insertions, 3 deletions
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index 9f25f251d..127907836 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -469,6 +469,11 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std:
params[1].swap(params[3]);
params.erase(params.begin()+2, params.begin()+4);
+
+ // If the source of this SERVER message is not bursting, then new servers it introduces are bursting
+ TreeServer* server = TreeServer::Get(who);
+ if (!server->IsBursting())
+ params.insert(params.begin()+2, "burst=" + ConvToStr(ServerInstance->Time()*1000));
}
else if (cmd == "BURST")
{
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index e7868090d..d7c6332f2 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -63,7 +63,6 @@ CmdResult CommandServer::HandleServer(TreeServer* ParentOfThis, std::vector<std:
TreeServer* Node = new TreeServer(servername, description, sid, ParentOfThis, ParentOfThis->GetSocket(), lnk ? lnk->Hidden : false);
- Node->BeginBurst();
HandleExtra(Node, params);
ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+ParentOfThis->GetName()+"\002 introduced server \002"+servername+"\002 ("+description+")");
@@ -84,6 +83,9 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::st
key.erase(p);
val = prop.substr(p+1);
}
+
+ if (key == "burst")
+ newserver->BeginBurst(ConvToInt(val));
}
}
@@ -217,5 +219,7 @@ CommandServer::Builder::Builder(TreeServer* server)
{
push(server->GetName());
push(server->GetID());
+ if (server->IsBursting())
+ push_property("burst", ConvToStr(server->StartBurst));
push_last(server->GetDesc());
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 8ff4cbe7b..3a7d8c4a9 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -114,8 +114,10 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s
void TreeServer::BeginBurst(unsigned long startms)
{
- if (!startms)
- startms = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
+ unsigned long now = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
+ // If the start time is in the future (clocks are not synced) then use current time
+ if ((!startms) || (startms > now))
+ startms = now;
this->StartBurst = startms;
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %lu", sid.c_str(), startms);
}