tcpdump mailing list archives
Re: Portable way to "block" on pcap_next_ex()
From: Guy Harris <guy () alum mit edu>
Date: Mon, 16 Jan 2012 18:56:55 -0800
On Jan 16, 2012, at 2:20 PM, Fernando Gont wrote:
Both on Linux and on BSDs, each time a packet is received, select() returns readable (without waiting for the entire buffer to fill up). -- my understanding is that you were expecting select() to block till the buffer filled up, or when the timer expired. But everytime select() returns, there's a packet to read, and it seems it never returns when there are no packets to read.
OK, so it appears that, at least on those OSes, select() won't list a BPF device as readable if there are no packets to read when the timer expires. (I just checked it with the selpolltest program that comes with recent versions of libpcap source: https://github.com/mcr/libpcap/blob/master/tests/selpolltest.c running it on FreeBSD 7.3 with the "-s" flag and a filter "icmp" to minimize the traffic it sees - pinging it causes wakeups, so it's not waiting for the buffer to fill.) It *does* appear to treat it as readable if there *are* packets to read when the timer expires.- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Portable way to "block" on pcap_next_ex() Fernando Gont (Jan 15)
- Re: Portable way to "block" on pcap_next_ex() Guy Harris (Jan 15)
- Re: Portable way to "block" on pcap_next_ex() Fernando Gont (Jan 15)
- Re: Portable way to "block" on pcap_next_ex() Guy Harris (Jan 15)
- Re: Portable way to "block" on pcap_next_ex() Fernando Gont (Jan 16)
- Re: Portable way to "block" on pcap_next_ex() Guy Harris (Jan 16)
- Re: Portable way to "block" on pcap_next_ex() Fernando Gont (Jan 16)
- Re: Portable way to "block" on pcap_next_ex() Guy Harris (Jan 16)
- Re: Portable way to "block" on pcap_next_ex() Fernando Gont (Jan 15)
- Re: Portable way to "block" on pcap_next_ex() Guy Harris (Jan 15)