chiark / gitweb /
Licensing: Add copyright for Mark Wooding
[adns.git] / src / event.c
index 1652268c9ab658ffc39c6d72448d06804528361f..3dd927b6974fb675536676eff51a17a8162a319a 100644 (file)
@@ -6,14 +6,15 @@
  */
 /*
  *  This file is part of adns, which is
- *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
+ *    Copyright (C) 1997-2000,2003,2006,2014  Ian Jackson
+ *    Copyright (C) 2014  Mark Wooding
  *    Copyright (C) 1999-2000,2003,2006  Tony Finch
  *    Copyright (C) 1991 Massachusetts Institute of Technology
  *  (See the file INSTALL for full details.)
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
+ *  the Free Software Foundation; either version 3, or (at your option)
  *  any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -22,8 +23,7 @@
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ *  along with this program; if not, write to the Free Software Foundation.
  */
 
 #include <errno.h>
@@ -398,31 +398,30 @@ int adns_processreadable(adns_state ads, int fd, const struct timeval *now) {
   }
   for (i=0; i<ads->nudpsockets; i++) {
     udp= &ads->udpsockets[i];
-    if (fd == udp->fd) {
-      for (;;) {
-       udpaddrlen= sizeof(udpaddr);
-       r= recvfrom(fd,udpbuf,sizeof(udpbuf),0, &udpaddr.sa,&udpaddrlen);
-       if (r<0) {
-         if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
-         if (errno == EINTR) continue;
-         if (errno_resources(errno)) { r= errno; goto xit; }
-         adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
-         r= 0; goto xit;
-       }
-       for (serv= 0;
-            serv < ads->nservers &&
-              !adns__sockaddrs_equal(&udpaddr.sa,
-                                     &ads->servers[serv].addr.sa);
-            serv++);
-       if (serv >= ads->nservers) {
-         adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
-                    adns__sockaddr_ntoa(&udpaddr.sa, addrbuf));
-         continue;
-       }
-       adns__procdgram(ads,udpbuf,r,serv,0,*now);
+    if (fd != udp->fd) continue;
+    for (;;) {
+      udpaddrlen= sizeof(udpaddr);
+      r= recvfrom(fd,udpbuf,sizeof(udpbuf),0, &udpaddr.sa,&udpaddrlen);
+      if (r<0) {
+       if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
+       if (errno == EINTR) continue;
+       if (errno_resources(errno)) { r= errno; goto xit; }
+       adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
+       r= 0; goto xit;
       }
-      break;
+      for (serv= 0;
+          serv < ads->nservers &&
+            !adns__sockaddrs_equal(&udpaddr.sa,
+                                   &ads->servers[serv].addr.sa);
+          serv++);
+      if (serv >= ads->nservers) {
+       adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
+                  adns__sockaddr_ntoa(&udpaddr.sa, addrbuf));
+       continue;
+      }
+      adns__procdgram(ads,udpbuf,r,serv,0,*now);
     }
+    break;
   }
   r= 0;
 xit: