while (state->timeout > 0 && retval == 0) {
if (iface->fd == -1)
timeout = INFTIM;
- else
+ else {
timeout = TIMEOUT_MINI;
- if (state->timeout < timeout)
- timeout = (int) state->timeout;
+ if (state->timeout < timeout)
+ timeout = (int) state->timeout;
+ timeout *= 1000;
+ }
state->start = uptime ();
- retval = poll (fds, iface->fd == -1 ? 1 : 2, timeout * 1000);
+ retval = poll (fds, iface->fd == -1 ? 1 : 2, timeout);
state->timeout -= uptime () - state->start;
if (retval == 0 && iface->fd != -1 && state->timeout > 0)
_send_message (state, state->last_type, options);
#include <netinet/udp.h>
#include <arpa/inet.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
*buffer_len = read (iface->fd, bpf.buffer, iface->buffer_length);
*buffer_pos = 0;
if (*buffer_len < 1) {
- struct timespec tv;
+ struct timespec ts;
logger (LOG_ERR, "read: %s", strerror (errno));
ts.tv_sec = 3;
ts.tv_nsec = 0;