summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/modules/m_spanningtree/treeserver.h6
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp5
3 files changed, 14 insertions, 3 deletions
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<std::string> &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