From: bert hubert Date: Fri, 30 Jan 2015 12:57:00 +0000 (+0100) Subject: unshare g_now between threads, it was causing weirdness. Again thanks to Winfried... X-Git-Tag: rec-3.7.0-rc2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=183eb8774e4bc2569f06d5894fec65740f4b70b6;p=thirdparty%2Fpdns.git unshare g_now between threads, it was causing weirdness. Again thanks to Winfried for great debugging & solution! --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 4065f9cc23..c0569b01f0 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;