@@ -1,4 +1,4 @@
-/* $NetBSD: npfd.c,v 1.6 2017/01/07 16:48:03 christos Exp $ */
+/* $NetBSD: npfd.c,v 1.7 2017/01/24 20:24:59 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npfd.c,v 1.6 2017/01/07 16:48:03 christos Exp $");
+__RCSID("$NetBSD: npfd.c,v 1.7 2017/01/24 20:24:59 christos Exp $");
#include <stdio.h>
#include <string.h>
@@ -75,6 +75,7 @@
npfd_event_loop(npfd_log_t *log, int delay)
{
struct pollfd pfd;
+ size_t count = 0;
pfd.fd = npfd_log_getsock(log);
pfd.events = POLLHUP | POLLIN;
@@ -91,6 +92,7 @@
if (flush) {
flush = false;
npfd_log_flush(log);
+ count = 0;
}
switch (poll(&pfd, 1, delay)) {
case -1:
@@ -101,8 +103,13 @@
/*NOTREACHED*/
case 0:
npfd_log_flush(log);
+ count = 0;
continue;
default:
+ if (count++ >= 100) {
+ npfd_log_flush(log);
+ count = 0;
+ }
npfd_log(log);
}
@@ -168,7 +175,7 @@
bool daemon_off = false;
int ch;
- int delay = 60 * 1000;
+ int delay = 5 * 1000;
const char *iface = "npflog0";
int snaplen = 116;
char *pidname = NULL;