Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread safety problem in pcap_ex_next() #31

Open
GoogleCodeExporter opened this issue Jun 14, 2015 · 0 comments
Open

Thread safety problem in pcap_ex_next() #31

GoogleCodeExporter opened this issue Jun 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Use pypcap in a multi-threaded scenario, with each thread using a 
   separate pcap instance.
2. In each thread, read packets via pcap.next(), in parallel.

What is the expected output? What do you see instead?

Expected output is normal packet retrieval. Instead, one sees occasional
packet truncation (e.g., caplen 46, IP hlen indicating full 1500B). The
cause for this is the additional static pcap_pkthdr variable in pcap_ex_next
and the fact that the hdr variable in __next__ points to it, as races may
not reflect the right content at the time it is accessed.

I'm attaching a patch that fixes the problem for me. It removes the
static variable, thus restoring pcap's "caller owns value" semantics in 
this particular case.

What version of the product are you using? On what operating system?

SVN trunk, Linux 2.6.

Original issue reported on code.google.com by kreib...@gmail.com on 2 Feb 2011 at 9:26

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant