On May 17, 2004, at 11:31 AM, Lance Uyehara wrote:

Is there a thread safe version of libpcap around?

I have pcap programs which include hostnames, i.e "dst host blahblah.com"
and if multiple pcap programs fail to resolve the hostname then I sometimes
get a core. I've looked at the source and I believe the problem is there are
so many static variables in libpcap that it really does not work
multi-threaded.

The compiler *definitely* doesn't work multi-threaded; are you implying that you have multiple threads doing "pcap_compile()"?


I don't know of any thread-safe version of "pcap_compile()". Unless compilation of filter expressions into BPF programs is done so often in your application that not multi-threading compilation would be a performance bottleneck, you might want to have a thread that does all the compilation - all of the other calls that take a "pcap_t *" as an argument, other than, perhaps, "pcap_close()" on some platforms, work in a multi-threaded program. (No guarantees about "pcap_open_live()", as it might add information to lists that aren't protected by mutexes - and "pcap_close()" would, in that case, use the lists as well.)

-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.

Reply via email to