summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/m_spanningtree/opertype.cpp2
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp17
-rw-r--r--src/modules/m_spanningtree/treeserver.h13
-rw-r--r--src/modules/m_spanningtree/uid.cpp2
4 files changed, 28 insertions, 6 deletions
diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp
index cb55d5c40..ab531c171 100644
--- a/src/modules/m_spanningtree/opertype.cpp
+++ b/src/modules/m_spanningtree/opertype.cpp
@@ -51,7 +51,7 @@ CmdResult CommandOpertype::HandleRemote(RemoteUser* u, std::vector<std::string>&
* then do nothing. -- w00t
*/
TreeServer* remoteserver = TreeServer::Get(u);
- if (remoteserver->IsBursting() || remoteserver->IsSilentULine())
+ if (remoteserver->IsBehindBursting() || remoteserver->IsSilentULine())
return CMD_SUCCESS;
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 3adbcb530..f4c7b511e 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -37,7 +37,7 @@ TreeServer::TreeServer()
, Parent(NULL), Route(NULL)
, VersionString(ServerInstance->GetVersionString())
, fullversion(ServerInstance->GetVersionString(true))
- , Socket(NULL), sid(ServerInstance->Config->GetSID()), ServerUser(ServerInstance->FakeClient)
+ , Socket(NULL), sid(ServerInstance->Config->GetSID()), behind_bursting(0), ServerUser(ServerInstance->FakeClient)
, age(ServerInstance->Time()), Warned(false), UserCount(ServerInstance->Users.GetLocalUsers().size())
, OperCount(0), rtt(0), StartBurst(0), Hidden(false)
{
@@ -50,9 +50,10 @@ TreeServer::TreeServer()
*/
TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide)
: Server(Name, Desc)
- , Parent(Above), Socket(Sock), sid(id), ServerUser(new FakeUser(id, this))
+ , Parent(Above), Socket(Sock), sid(id), behind_bursting(Parent->behind_bursting), ServerUser(new FakeUser(id, this))
, age(ServerInstance->Time()), Warned(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(Hide)
{
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "New server %s behind_bursting %u", GetName().c_str(), behind_bursting);
CheckULine();
SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
SetPingFlag();
@@ -114,12 +115,14 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s
void TreeServer::BeginBurst(unsigned long startms)
{
+ behind_bursting++;
+
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);
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %lu behind_bursting %u", sid.c_str(), startms, behind_bursting);
}
const std::string& TreeServer::GetID()
@@ -129,7 +132,13 @@ const std::string& TreeServer::GetID()
void TreeServer::FinishBurstInternal()
{
- if (!IsBursting())
+ // Check is needed because 1202 protocol servers don't send the bursting state of a server, so servers
+ // introduced during a netburst may later send ENDBURST which would normally decrease this counter
+ if (behind_bursting > 0)
+ behind_bursting--;
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "FinishBurstInternal() %s behind_bursting %u", GetName().c_str(), behind_bursting);
+
+ if (!IsBehindBursting())
{
SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
SetPingFlag();
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index 192896cdb..3f1f0755d 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -53,6 +53,13 @@ class TreeServer : public Server
bool LastPingWasGood; /* True if the server responded to the last PING with a PONG */
std::string sid; /* Server ID */
+ /** Counter counting how many servers are bursting in front of this server, including
+ * this server. Set to parents' value on construction then it is increased if the
+ * server itself starts bursting. Decreased when a server on the path to this server
+ * finishes burst.
+ */
+ unsigned int behind_bursting;
+
/** This method is used to add this TreeServer to the
* hash maps. It is only called by the constructors.
*/
@@ -199,6 +206,12 @@ class TreeServer : public Server
*/
bool IsBursting() const { return (StartBurst != 0); }
+ /** Check whether this server is behind a bursting server or is itself bursting.
+ * This can tell whether a user is on a part of the network that is still bursting.
+ * @return True if this server is bursting or is behind a server that is bursting, false if it isn't
+ */
+ bool IsBehindBursting() const { return (behind_bursting != 0); }
+
/** Set the bursting state of the server
* @param startms Time the server started bursting, if 0 or omitted, use current time
*/
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index f7749a1e4..398573616 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -129,7 +129,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
bool dosend = true;
- if ((Utils->quiet_bursts && remoteserver->IsBursting()) || _new->server->IsSilentULine())
+ if ((Utils->quiet_bursts && remoteserver->IsBehindBursting()) || _new->server->IsSilentULine())
dosend = false;
if (dosend)