Repository navigation
fix: TUI async polling, replay validation, assert→Result (LAN-150, LAN-181) - #116
Merged
Merged
Conversation
…N-181) Three fixes in one PR: LAN-150 #32 — TUI input polling blocks async runtime: - Spawn a dedicated std::thread for crossterm event::poll/read (blocking calls that previously ran on the tokio executor, stalling it for up to 16ms per frame). - The thread forwards Event values over an mpsc channel; the async loop uses try_recv (non-blocking) and tokio::time::sleep for frame pacing. LAN-150 #22 — Replay/diff bypasses CLI validation: - Move args.validate() before the replay/diff early returns in main() so nonsensical flag combos are caught in all modes. - Add validation rules: --pmtud and --jumbo rejected with --replay/--diff. LAN-181 — assert! in build_ipv4_packet production path: - Convert build_ipv4_packet to return Result<Vec<u8>> instead of Vec<u8> with an assert! that panics on oversized packets. - All 4 production callers in engine.rs updated: 3 use ? (in Result- returning functions), 1 (PMTUD bool fn) handles Err with eprintln + return false. - Tests updated: should_panic → is_err, all test callsites use .unwrap()/.expect().
Review finding: moving validate() before replay/diff dispatch broke --replay/--diff combined with --json/--csv/--report/--no-tui, because validate() still treated those as live/batch modes requiring targets and -c. Fix: gate the target and count checks with !replay_or_diff so replay and diff modes skip live-probe validations. Added 5 tests covering the regression: --replay with --json/--csv/ --report/--no-tui, and --diff with --json.
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.
Summary
Closes LAN-150 and LAN-181 — the last two open ttl issues.
LAN-150 #32 — TUI input polling blocks async runtime
Problem:
event::poll(tick_rate)andevent::read()are blocking calls running on the tokio executor, stalling it for up to 16ms per frame iteration.Fix: Spawn a dedicated
std::threadthat runs the crossterm event loop and forwardsEventvalues over anmpscchannel. The async loop usestry_recv()(non-blocking) andtokio::time::sleep(tick_rate)for frame pacing.Files:
src/tui/app.rs— newspawn_event_reader()helper,run_appinput handling switched from blockingevent::poll/event::readto non-blockingtry_recv.LAN-150 #22 — Replay/diff bypasses CLI validation
Problem:
args.validate()ran after the replay/diff early returns inmain(), so nonsensical flags (e.g.--pmtud --replay) were accepted silently.Fix: Move
validate()before the early returns. Add validation rules rejecting--pmtudand--jumboin replay/diff modes.Files:
src/main.rs,src/cli.rs.LAN-181 — assert! in build_ipv4_packet production path panics
Problem:
build_ipv4_packetusedassert!to guard against oversized IPv4 packets — a production panic path.Fix: Convert to
Result<Vec<u8>>usinganyhow::bail!. All 4 production callers inengine.rsupdated: 3 use?(inResult-returning functions), 1 (PMTUDboolfn) handlesErrwitheprintln!+return false.Files:
src/probe/rawip.rs,src/trace/engine.rs.Tests
test_build_ipv4_packet_oversized_returns_err— replacesshould_panicwithis_err+ error message checktest_pmtud_rejected_with_replay— validates --pmtud + --replay is rejectedtest_jumbo_rejected_with_replay— validates --jumbo + --replay is rejectedtest_pmtud_rejected_with_diff— validates --pmtud + --diff is rejectedtest_validate_passes_for_plain_replay— plain --replay still validatestest_validate_passes_for_plain_diff— plain --diff still validatesAll 603 tests pass, clippy clean.