On Mon, Nov 18, 2013 at 12:38:24AM -0500, Benjamin Vanheuverzwijn wrote: > Hi,
Hi Benjamin, > > libpcap version: 1.4.0 (on archlinux) I am running Fedora 19 (libpcap-1.4.0). > > Is it possible to have multiple call to "pcap_open_live()" followed by > pcap_close() ? It shouldn't be a problem. > > It seems like pcap_close() doesn't cleanly close opened resources, if you > strace the following program, you will see file descriptors growing up. I am unable to reproduce the issue. In strace output I see only descriptor 3 which is acquired and closed on every iteration. Tried with two NICs, wired and wireless. > > Am i doing it wrong? How it should be done? >From output you have provided I have a suspicion that your problem is somehow caused by calling open() on those /sys/bus/usb/* files. I don't have those in my strace output, probably because interface you have used is hotplugged wireless usb dongle, I guess (judging by interface name from udev). I might be able to try again with wireless USB dongle tomorrow. Will keep you posted on my findings. > > Thanks, Cheers, Michal > > To reproduce: > // Compile with gcc -o openlive openlive.c -l pcap > #include <pcap.h> > > int main(int argc, char *argv[]) { > int i=0; > for (i = 0; i != 2000; ++i) { > char errbuf[256]; > pcap_t *pcap = pcap_open_live("wls3", 1024, 1, 0, errbuf); > pcap_close(pcap); > } > return 0; > } > > $ strace ./openlive > [...] > open("/sys/bus/usb/devices/4-2/devnum", O_RDONLY) = 16 > fstat(16, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0 > mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = > 0x7f5e040f0000 > read(16, "8\n", 4096) = 2 > [...] > open("/sys/bus/usb/devices/usb4/speed", O_RDONLY) = 91 > fstat(91, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0 > mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = > 0x7fc006371000 > read(91, "480\n", 4096) = 4 > > > -- > Benjamin Vanheuverzwijn > _______________________________________________ > tcpdump-workers mailing list > tcpdump-workers@lists.tcpdump.org > https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers _______________________________________________ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers