]> granicus.if.org Git - pdns/commitdiff
rec: Only increase `no-packet-error` on the first read
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 3 Jul 2017 11:04:58 +0000 (13:04 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 3 Jul 2017 11:20:18 +0000 (13:20 +0200)
We try to read as many messages as possible after being woken up,
but only the first read can count as a no-packet error.

pdns/pdns_recursor.cc

index 2220f192c8ec24e25e4fa2aaf7073a641a3ed141..51f9325140dae19261c59133d148cdf7feb25911 100644 (file)
@@ -1729,12 +1729,16 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
   struct msghdr msgh;
   struct iovec iov;
   char cbuf[256];
+  bool firstQuery = true;
 
   fromaddr.sin6.sin6_family=AF_INET6; // this makes sure fromaddr is big enough
   fillMSGHdr(&msgh, &iov, cbuf, sizeof(cbuf), data, sizeof(data), &fromaddr);
 
   for(;;)
   if((len=recvmsg(fd, &msgh, 0)) >= 0) {
+
+    firstQuery = false;
+
     if(t_remotes)
       t_remotes->push_back(fromaddr);
 
@@ -1807,8 +1811,9 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
   }
   else {
     // cerr<<t_id<<" had error: "<<stringerror()<<endl;
-    if(errno == EAGAIN)
+    if(firstQuery && errno == EAGAIN)
       g_stats.noPacketError++;
+
     break;
   }
 }