From 183eb8774e4bc2569f06d5894fec65740f4b70b6 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 30 Jan 2015 13:57:00 +0100 Subject: [PATCH] unshare g_now between threads, it was causing weirdness. Again thanks to Winfried for great debugging & solution! --- pdns/pdns_recursor.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 4065f9cc2..c0569b01f 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1,6 +1,6 @@ /* PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2003 - 2014 PowerDNS.COM BV + Copyright (C) 2003 - 2015 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 @@ -121,7 +121,7 @@ typedef vector tcpListenSockets_t; tcpListenSockets_t g_tcpListenSockets; // shared across threads, but this is fine, never written to from a thread. All threads listen on all sockets int g_tcpTimeout; unsigned int g_maxMThreads; -struct timeval g_now; // timestamp, updated (too) frequently +__thread struct timeval g_now; // timestamp, updated (too) frequently typedef map listenSocketsAddresses_t; // is shared across all threads right now listenSocketsAddresses_t g_listenSocketsAddresses; // is shared across all threads right now @@ -930,9 +930,10 @@ void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t& ) string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fromaddr, const ComboAddress& destaddr, struct timeval tv, int fd) { + gettimeofday(&g_now, 0); struct timeval diff = g_now - tv; double delta=(diff.tv_sec*1000 + diff.tv_usec/1000.0); - + if(delta > 1000.0) { g_stats.tooOldDrops++; return 0; -- 2.40.0