aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-08-06 01:01:00 -0700
committerGuy Harris <guy@alum.mit.edu>2014-08-06 01:01:00 -0700
commite5c0edc8a89f7a836bf93af924d30b08edcaa853 (patch)
tree56eebfe818bff4d0cb41b29deb5158a1fc3ebd48 /pcap-linux.c
parentb4c8a02737aba7428a215a7c7daccd85ee6020c8 (diff)
For memory-mapped pcap_t's, set non-blocking mode on the FD first.
That way, if it fails, we don't set the timeout in the private data structure to indicate that we're in non-blocking mode.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 9ed09de1..5fd564de 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -4026,6 +4026,13 @@ pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf)
struct pcap_linux *handlep = p->priv;
/*
+ * Set the file descriptor to non-blocking mode, as we use
+ * it for sending packets.
+ */
+ if (pcap_setnonblock_fd(p, nonblock, errbuf) == -1)
+ return -1;
+
+ /*
* Map each value to their corresponding negation to
* preserve the timeout value provided with pcap_set_timeout.
*/
@@ -4042,7 +4049,7 @@ pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf)
handlep->timeout = ~handlep->timeout;
}
}
- return pcap_setnonblock_fd(p, nonblock, errbuf);
+ return 0;
}
static inline union thdr *