[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: libpcap/pthread problem
- From: Dan Moinescu <danmoinescu_(_at_)_yahoo_(_dot_)_com>
- Date: Wed, 8 Jan 2003 11:08:27 -0800 (PST)
I have recently encountered a problem with a threaded
application using pcap. The basic idea is that one
thread would capture packets with pcap and pass them
via a queue to a second thread wich will compute some
traffic statistics. The second thread sleeps in a
loop, waking up periodically to check for packets in
The problem is, once the 2nd thread goes to sleep, it
never wakes up. I've tried to use sleep, pause,
sigsuspend, sigwait (with the 1st thread signalling
it); none of these work.
There is one case, though, when the application works
fine: when passing 0 as the 4th argument (timeout) to
pcap_open_live. But in this case, the 1st thread sits
in a busy loop, resulting in a 100% CPU utilization
(as reported by top), which is not acceptable.
I've attached attached the relevant code.
Am I missing something, or is this a system bug (or
the intended behaviour?)
Any help would be greatly appreciated.
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
[demime 0.98d removed an attachment of type application/x-tgz which had a name of traffic_stat_demo.tgz]
Visit your host, monkey.org