automaton: drop stopped children from the spawn listener - #5129
Open
KernelClint wants to merge 1 commit into
Open
automaton: drop stopped children from the spawn listener#5129KernelClint wants to merge 1 commit into
KernelClint wants to merge 1 commit into
Conversation
AI-Assisted: yes (GPT-5.6-Cyber)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5129 +/- ##
==========================================
- Coverage 80.63% 80.63% -0.01%
==========================================
Files 390 390
Lines 96936 96937 +1
==========================================
Hits 78168 78168
- Misses 18768 18769 +1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automaton.spawn()runs a listener that accepts connections and starts a child automaton for eachone, tracking them in a
clientslist so they can be shut down with the listener.Children are appended at
scapy/automaton.py:1041-1047and never removed. Each new connection walks the entire list and calls
destroy()again on everychild that has already stopped. Over a run of short-lived connections the list only grows, and the
work done per connection grows with it — the total is quadratic in the number of connections
served. The stopped children stay reachable too, so their memory is not reclaimed.
The change removes each stopped child once it has been destroyed, iterating a copy so removal
during iteration is safe:
Live children are untouched, so listener shutdown still reaches all of them.
The added regression accepts several connections, stops them, and asserts the list holds only the
running children. Without the removal it fails.
Performance was measured on one computer, before and after the fix: accepting a connection while a
child is still running took 6,652.7 ns before and 6,669.2 ns after. Repeat runs moved by about 2%,
so that difference is smaller than the test can distinguish.