[dns-operations] announcement of new tool -- dnscap

Florian Weimer fw at deneb.enyo.de
Fri May 4 08:55:41 UTC 2007


* Stephane Bortzmeyer:

> On Wed, May 02, 2007 at 09:04:47PM +0000,
>  Paul Vixie <paul at vix.com> wrote 
>  a message of 5 lines which said:
>
>> http://public.oarci.net/tools/dnscap
>
> Strange bug with the -t option. On i386/CentOS, it works fine but on
> amd64/Gentoo, the dump file is renamed bu dnscap crashes just after:
>
> select: Interrupted system call

Try the attached patch, which is completely untested by the way.

(This could have been coded in a nicer way using a goto, of course.

commit e72e71363254fe8314920c85f7156d2fd1a10e16
Author: Florian Weimer <fw at deneb.enyo.de>
Date:   Fri May 4 10:54:23 2007 +0200

    Ignore EINTR after a select call
    
    When the configured alarm fires during the call, select will return
    with errno == EINTR on some systems.

diff --git a/dnscap.c b/dnscap.c
index 95d1e97..e52de47 100644
--- a/dnscap.c
+++ b/dnscap.c
@@ -48,6 +48,7 @@ static const char copyright[] =
 #include <arpa/inet.h>
 
 #include <assert.h>
+#include <errno.h>
 #include <netdb.h>
 #include <pcap.h>
 #include <signal.h>
@@ -671,13 +672,19 @@ poll_pcaps(void) {
 	fd_set readfds;
 	int n;
 
-	readfds = pcapif_fdset;
-	n = select(pcap_maxfd+1, &readfds, NULL, NULL, NULL);
-	if (n < 0) {
-		perror("select");
-		main_exit = TRUE;
-		return;
+	while (1) {
+		readfds = pcapif_fdset;
+		n = select(pcap_maxfd+1, &readfds, NULL, NULL, NULL);
+		if (n < 0) {
+			if (errno == EINTR)
+				continue;
+			perror("select");
+			main_exit = TRUE;
+			return;
+		}
+		break;
 	}
+
 	/* Poll them all. */
 	for (pcapif = ISC_LIST_HEAD(pcapifs);
 	     pcapif != NULL;



More information about the dns-operations mailing list