std::unique_ptr<DynListener> dl{nullptr};
CommunicatorClass Communicator;
shared_ptr<UDPNameserver> N;
-int avg_latency;
+double avg_latency{0.0};
unique_ptr<TCPNameserver> TN;
static vector<DNSDistributor*> g_distributors;
vector<std::shared_ptr<UDPNameserver> > g_udpReceivers;
static uint64_t getLatency(const std::string& str)
{
- return avg_latency;
+ return round(avg_latency);
}
void declareStats(void)
N->send(*a);
int diff=a->d_dt.udiff();
- avg_latency=(int)(0.999*avg_latency+0.001*diff);
+ avg_latency=0.999*avg_latency+0.001*diff;
}
//! The qthread receives questions over the internet via the Nameserver class, and hands them to the Distributor for further processing
cached.commitD(); // commit d to the packet inlined
NS->send(cached); // answer it then inlined
diff=question.d_dt.udiff();
- avg_latency=(int)(0.999*avg_latency+0.001*diff); // 'EWMA'
+ avg_latency=0.999*avg_latency+0.001*diff; // 'EWMA'
continue;
}
}
extern CommunicatorClass Communicator;
extern std::shared_ptr<UDPNameserver> N;
extern vector<std::shared_ptr<UDPNameserver> > g_udpReceivers;
-extern int avg_latency;
+extern double avg_latency;
extern std::unique_ptr<TCPNameserver> TN;
extern void declareArguments();
extern void declareStats();