From: Attila Molnar Date: Tue, 12 May 2015 22:26:02 +0000 (+0200) Subject: m_spanningtree Use uint64_t for the burst start time to avoid overflows X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=0982b2a58259ec1653e2af93ec612ec98378a087;p=user%2Fhenk%2Fcode%2Finspircd.git m_spanningtree Use uint64_t for the burst start time to avoid overflows --- diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index c2ee940fc..ab5ee269e 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -473,7 +473,7 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std: // 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)); + params.insert(params.begin()+2, "burst=" + ConvToStr(((uint64_t)ServerInstance->Time())*1000)); } else if (cmd == "BURST") { diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 30931b90e..bc43841c1 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -85,7 +85,7 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vectorBeginBurst(ConvToInt(val)); + newserver->BeginBurst(ConvToUInt64(val)); } } diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 3835695dd..0750e755c 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -117,16 +117,16 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s Parent->Children.push_back(this); } -void TreeServer::BeginBurst(unsigned long startms) +void TreeServer::BeginBurst(uint64_t startms) { behind_bursting++; - unsigned long now = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000); + uint64_t 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 behind_bursting %u", sid.c_str(), startms, behind_bursting); + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %s behind_bursting %u", sid.c_str(), ConvToStr(startms).c_str(), behind_bursting); } void TreeServer::FinishBurstInternal() @@ -147,7 +147,7 @@ void TreeServer::FinishBurstInternal() void TreeServer::FinishBurst() { ServerInstance->XLines->ApplyLines(); - long ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000); + uint64_t ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000); unsigned long bursttime = ts - this->StartBurst; ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)", GetName().c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs")); diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 1a0203ba0..b7e9ee9d9 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -150,7 +150,7 @@ class TreeServer : public Server /** When we recieved BURST from this server, used to calculate total burst time at ENDBURST. */ - unsigned long StartBurst; + uint64_t StartBurst; /** True if this server is hidden */ @@ -213,7 +213,7 @@ class TreeServer : public Server /** Set the bursting state of the server * @param startms Time the server started bursting, if 0 or omitted, use current time */ - void BeginBurst(unsigned long startms = 0); + void BeginBurst(uint64_t startms = 0); /** Register a PONG from the server */