From 728a907e887406df109f37e68cafbb3abd2a02e4 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 5 Aug 2007 19:22:10 +0000 Subject: Change latency figures in /map to milliseconds, much more useful for lag measurement than seconds git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7667 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/main.cpp | 6 +++++- src/modules/m_spanningtree/treeserver.h | 6 +++++- src/modules/m_spanningtree/treesocket2.cpp | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 9a678dc5b..2b159fa4e 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -174,7 +174,7 @@ std::string ModuleSpanningTree::TimeToStr(time_t secs) const std::string ModuleSpanningTree::MapOperInfo(TreeServer* Current) { time_t secs_up = ServerInstance->Time() - Current->age; - return (" [Up: " + TimeToStr(secs_up) + " Lag: "+ConvToStr(Current->rtt)+"s]"); + return (" [Up: " + TimeToStr(secs_up) + " Lag: "+ConvToStr(Current->rtt)+"ms]"); } // WARNING: NOT THREAD SAFE - DONT GET ANY SMART IDEAS. @@ -487,6 +487,10 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime) sock->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" PING "+serv->GetName()); serv->SetNextPingTime(curtime + 60); serv->LastPing = curtime; + timeval t; + gettimeofday(&t, NULL); + long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000); + serv->LastPingMsec = ts; serv->Warned = false; } else diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 514d6bc07..d8d3b70e8 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -109,9 +109,13 @@ class TreeServer : public classbase */ time_t LastPing; + /** Last ping time in microseconds, used to calculate round trip time + */ + unsigned long LastPingMsec; + /** Round trip time of last ping */ - time_t rtt; + unsigned long rtt; /** True if this server is hidden */ diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 077350d20..fc6853ba8 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -365,7 +365,10 @@ bool TreeSocket::LocalPong(const std::string &prefix, std::deque &p if (ServerSource) { ServerSource->SetPingFlag(); - ServerSource->rtt = Instance->Time() - ServerSource->LastPing; + timeval t; + gettimeofday(&t, NULL); + long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000); + ServerSource->rtt = ts - ServerSource->LastPingMsec; } } else -- cgit v1.2.3