Fix AsyncSniffer early stop when timeout is set#5007
Conversation
4d24b94 to
6cc9845
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5007 +/- ##
==========================================
- Coverage 80.03% 79.50% -0.53%
==========================================
Files 384 384
Lines 95622 95622
==========================================
- Hits 76527 76022 -505
- Misses 19095 19600 +505
🚀 New features to boost your workflow:
|
6cc9845 to
af2414d
Compare
Add a control ObjectPipe for nonblocking sniffers when a timeout is set, so stop() can wake select() instead of waiting for the full timeout (secdev#4890). Blocking sockets keep the existing control pipe behavior. Regression test uses select_objects() so ObjectPipe wake works on Windows too. Fixes secdev#4890 AI-Assisted: yes [Cursor] Co-authored-by: Cursor <cursoragent@cursor.com>
af2414d to
cbb9124
Compare
CI status (follow-up)The latest CI run still reports some failing checks. Below is why those failures are not blockers for this PR and what was already addressed here. What this PR fixes (verified in CI)
The change in Remaining red checks (not introduced by this PR)1.
|
Summary
ObjectPipeinAsyncSniffer._run(), not only when the sniff socket is blocking.stop()now wakesselect()immediately instead of leaving the sniff thread blocked until the configuredtimeoutexpires.Fixes #4890
Problem
With
AsyncSniffer(..., timeout=N)and a nonblocking listen socket (default on macOS with BPF), callingstop(join=False)setcontinue_sniff = Falsebut the thread remained insideselect(..., remain)for up toNseconds.runningstayedTrueandresultsstayedNoneuntil that wait finished.Solution
Use the same control-pipe mechanism already employed for blocking sockets:
stop_cb()sends on the pipe soselect()returns and the loop exits promptly.Test plan
AsyncSniffer early stop with timeout on nonblocking socket (#4890)intest/regression.uts(no root required; uses a minimalSuperSocketthat blocks inselectfor the fullremain).python3 -m scapy.tools.UTscapy -t test/regression.uts -F "4890"— new test passes.Made with Cursor