Skip to content

pcap: wake blocked receive via eventfd when daq_instance_interrupt() is called#40

Open
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:fix/pcap-interrupt-wakes-poll
Open

pcap: wake blocked receive via eventfd when daq_instance_interrupt() is called#40
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:fix/pcap-interrupt-wakes-poll

Conversation

@ssam18
Copy link
Copy Markdown

@ssam18 ssam18 commented May 12, 2026

pcap_daq_interrupt() currently just sets a volatile bool that the receive loop checks at the top of each iteration. On Linux with TPACKET_V3 and idle/virtual interfaces the in-pcap timeout isn't always honored, so the second pcap_next_ex() call inside pcap_daq_msg_receive() blocks inside poll() and never sees the flag. This leaves a Snort thread parked indefinitely after daq_instance_interrupt() and contributes to the service-stop hang in snort3/snort3#338. This change creates an eventfd in pcap_daq_start() for live captures, has pcap_daq_interrupt() write to it, and replaces the blocking fallback in the receive loop with a poll() over the pcap selectable fd and the eventfd, so an interrupt wakes the thread immediately and the receive returns DAQ_RSTAT_INTERRUPTED. The fast path (packets are already available) is unchanged. Note: eventfd is Linux-specific, happy to switch to a self-pipe if a portable implementation is preferred.

Refs snort3/snort3#338

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.

1 participant