Make timer around pcap_dispatch() tighter.
authorEmil Mikulic <emikulic@gmail.com>
Sat, 25 Jan 2014 09:11:41 +0000 (20:11 +1100)
committerEmil Mikulic <emikulic@gmail.com>
Sat, 25 Jan 2014 14:07:28 +0000 (01:07 +1100)
cap.c

diff --git a/cap.c b/cap.c
index 51f861b..59daf43 100644 (file)
--- a/cap.c
+++ b/cap.c
@@ -415,15 +415,15 @@ void cap_poll(fd_set *read_set _unused_on_linux_) {
                -1, /* count = entire buffer */
                callback,
                (u_char*)iface); /* user = struct to pass to callback */
+         timer_stop(&t,
+                    2 * CAP_TIMEOUT_MSEC * 1000000,
+                    "pcap_dispatch took too long");
 
          if (ret < 0) {
             warnx("pcap_dispatch('%s'): %s",
                iface->name, pcap_geterr(iface->pcap));
             continue;
          }
-         timer_stop(&t,
-                    2 * CAP_TIMEOUT_MSEC * 1000000,
-                    "pcap_dispatch took too long");
 
 #if 0 /* debugging */
          verbosef("iface '%s' got %d pkts", iface->name, ret);