diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-05-13 00:26:02 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-05-13 00:26:02 +0200 |
commit | 0982b2a58259ec1653e2af93ec612ec98378a087 (patch) | |
tree | 9454d0f4b7b8f02a2a3efe08b462f302d3d1a8aa /src | |
parent | a6433b37967e22e19658967ae4e798febea86356 (diff) |
m_spanningtree Use uint64_t for the burst start time to avoid overflows
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/compat.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/server.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 4 |
4 files changed, 8 insertions, 8 deletions
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::vector<std::st } if (key == "burst") - newserver->BeginBurst(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 */ |