Permalink
Browse files

fix up whitespace plus pdns-distributes-queries efficiency error hand…

…ling
  • Loading branch information...
1 parent d299d4f commit 2f22827a2c4e84f7afefedbba8321977242740d6 @ahupowerdns ahupowerdns committed Mar 17, 2014
Showing with 12 additions and 15 deletions.
  1. +2 −14 pdns/dnsreplay.cc
  2. +10 −1 pdns/pdns_recursor.cc
View
@@ -99,16 +99,13 @@ const struct timeval operator*(float fact, const struct timeval& rhs)
}
-
-
class DNSIDManager : public boost::noncopyable
{
public:
DNSIDManager()
{
for(unsigned int i=0; i < 65536; ++i)
d_available.push_back(i);
-
}
uint16_t peakID()
@@ -166,8 +163,6 @@ typedef multi_index_container<
> qids_t;
qids_t qids;
-
-
bool g_throttled;
unsigned int s_questions, s_origanswers, s_weanswers, s_wetimedout, s_perfect, s_mostly, s_origtimedout;
@@ -176,7 +171,6 @@ unsigned int s_webetter, s_origbetter, s_norecursionavailable;
unsigned int s_weunmatched, s_origunmatched;
unsigned int s_wednserrors, s_origdnserrors, s_duplicates;
-
double DiffTime(const struct timeval& first, const struct timeval& second)
{
int seconds=second.tv_sec - first.tv_sec;
@@ -374,16 +368,15 @@ try
s_wednserrors++;
}
}
-
}
catch(std::exception& e)
{
- cerr<<"Receiver thread died: "<<e.what()<<endl;
+ cerr<<"Receiver function died: "<<e.what()<<endl;
exit(1);
}
catch(...)
{
- cerr<<"Receiver thread died with unknown exception"<<endl;
+ cerr<<"Receiver function died with unknown exception"<<endl;
exit(1);
}
@@ -409,14 +402,12 @@ void pruneQids()
}
}
-
void printStats(uint64_t origWaitingFor=0, uint64_t weWaitingFor=0)
{
format headerfmt ("%|9t|Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok)\n");
format datafmt("%s%|9t|%d %|21t|%d %|29t|%d %|36t|%d %|47t|%d %|57t|%d %|66t|%d %|72t|%d\n");
-
cerr<<headerfmt;
cerr<<(datafmt % "Orig" % s_questions % origWaitingFor % s_orignever % s_origanswers % 0 % s_origtimedout % 0 % 0);
cerr<<(datafmt % "Refer." % s_questions % weWaitingFor % s_wenever % s_weanswers % 0 % s_wetimedout % 0 % 0);
@@ -429,7 +420,6 @@ void printStats(uint64_t origWaitingFor=0, uint64_t weWaitingFor=0)
cerr<<"original questions from IP addresses for which recursion was not available: "<<s_norecursionavailable<<endl;
cerr<<"Unmatched from us: "<<s_weunmatched<<", unmatched from original: "<<s_origunmatched << " ( - decoding err: "<<s_origunmatched-s_origdnserrors<<")"<<endl;
cerr<<"DNS decoding errors from us: "<<s_wednserrors<<", from original: "<<s_origdnserrors<<", exact duplicates from client: "<<s_duplicates<<endl<<endl;
-
}
void houseKeeping()
@@ -469,9 +459,7 @@ Orig 9 21 29 36 47 57 66 72
*/
printStats(origWaitingFor, weWaitingFor);
-
pruneQids();
-
}
View
@@ -1290,7 +1290,16 @@ void handlePipeRequest(int fd, FDMultiplexer::funcparam_t& var)
unixDie("read from thread pipe returned wrong size or error");
}
- void *resp = tmsg->func();
+ void *resp=0;
+ try {
+ resp = tmsg->func();
+ }
+ catch(std::exception& e) {
+ L<<Logger::Error<<"PIPE function we executed created exception: "<<e.what()<<endl; // but what if they wanted an answer.. we send 0
+ }
+ catch(PDNSException& e) {
+ L<<Logger::Error<<"PIPE function we executed created PDNS exception: "<<e.reason<<endl; // but what if they wanted an answer.. we send 0
+ }
if(tmsg->wantAnswer)
if(write(g_pipes[t_id].writeFromThread, &resp, sizeof(resp)) != sizeof(resp))
unixDie("write to thread pipe returned wrong size or error");

0 comments on commit 2f22827

Please sign in to comment.