]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Use uint64_t for the burst start time to avoid overflows
authorAttila Molnar <attilamolnar@hush.com>
Tue, 12 May 2015 22:26:02 +0000 (00:26 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Tue, 12 May 2015 22:26:02 +0000 (00:26 +0200)
src/modules/m_spanningtree/compat.cpp
src/modules/m_spanningtree/server.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treeserver.h

index c2ee940fccb6e2e18fb73d5ba08defa4632cfa5e..ab5ee269e98867d0fd318ed7942de74328de9998 100644 (file)
@@ -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")
        {
index 30931b90ea3ed59f4d047c200dd22d8545cf4340..bc43841c1cafefd4a9950605b9b91548413505f0 100644 (file)
@@ -85,7 +85,7 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::st
                }
 
                if (key == "burst")
-                       newserver->BeginBurst(ConvToInt(val));
+                       newserver->BeginBurst(ConvToUInt64(val));
        }
 }
 
index 3835695dde3c6c8dfac8c711a955d442c2707a2f..0750e755cfc8f889a8d0c2b06a5c2788236ab29a 100644 (file)
@@ -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"));
index 1a0203ba09384b9ba989de4818141cb5ba760be7..b7e9ee9d9bdd865d4de2a09ec54346acbf84dea9 100644 (file)
@@ -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
         */