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

Fix a multithreading issue in writing pcap files #204

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

saiarcot895
Copy link
Contributor

When there are separate threads that are sending and receiving packets, both threads may try to write the packet data to the pcap file. This causes the packet to get interleaved, thus basically making it corrupted and unable to be read by tcpdump, wireshark, etc.

This is happening due to a missing lock on self.cvar. Fix it by wrapping the write call in the send method and the initial assignment in start_pcap method with a lock on self.cvar.

When there are separate threads that are sending and receiving packets,
both threads may try to write the packet data to the pcap file. This
causes the packet to get interleaved, thus basically making it corrupted
and unable to be read by tcpdump, wireshark, etc.

This is happening due to a missing lock on `self.cvar`. Fix it by
wrapping the write call in the `send` method and the initial assignment
in `start_pcap` method with a lock on `self.cvar`.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
Copy link
Collaborator

@jafingerhut jafingerhut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like very low risk changes to me, in that the changes simply add acquisition of the lock asociated with self.cvar in more places than it was before.

Testing that these are the only places useful to add with self.cvar would require a lot more careful investigation of the entire class definitions, which I have not done.

@jafingerhut jafingerhut merged commit e8b545f into p4lang:main Jan 24, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants