Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gdamore
Copy link
Owner

@gdamore gdamore commented Dec 10, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Fixed timeout handling so "maximum" duration values are treated as indefinite waits, ensuring consistent behavior across different read/poll paths.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

Adjusts timeout handling in source/dcell/termio.d: treats Duration.max like an infinite wait in the UseSelect path (sets tvp to null) and fixes the polling branch to compare against Duration.max (sets dly = -1) for consistent indefinite-wait behavior.

Changes

Cohort / File(s) Summary
Timeout handling
source/dcell/termio.d
UseSelect path: set tvp to null when dur.isNegative or dur == Duration.max so select() waits indefinitely. Polling path: fix condition to compare dur == Duration.max (was dur.max), setting dly = -1 for indefinite wait.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Specific areas for attention:
    • Confirm Duration.max semantics and that equating it to an infinite wait is intended.
    • Review any tests or callers that rely on previous timeout distinctions.
    • Verify there are no other places using dur.max that should be corrected similarly.

Poem

🐇 I nudge the clock, then let it lie still,
Duration.max whispers "wait" on the hill.
Null the pointer, or set dly to none,
The terminal listens till morning's sun.
A rabbit applauds: an infinite run. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing overflow handling with Duration.max in timeout/duration logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gdamore/duration-max

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f461864 and 2ac63fc.

📒 Files selected for processing (1)
  • source/dcell/termio.d (2 hunks)
🔇 Additional comments (2)
source/dcell/termio.d (2)

279-290: LGTM! Proper handling of Duration.max to prevent overflow.

The added check for Duration.max correctly treats it as an infinite wait by setting tvp to null. This prevents arithmetic overflow when converting to microseconds at line 285, as Duration.max would overflow when calling total!"usecs".


340-347: LGTM! Critical fix for Duration.max reference.

The corrected reference to Duration.max (static property) fixes what was likely a compilation or runtime error with the previous dur.max. Additionally, this prevents overflow when casting to milliseconds at line 346, ensuring the polling path behaves consistently with the UseSelect implementation.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
source/dcell/termio.d (1)

340-340: Use Duration.max instead of dur.max for consistency.

While dur.max works in D (accessing a static property through an instance), it's confusing and inconsistent with the fix at line 279, which correctly uses Duration.max. Please update this line to match the clearer style.

Apply this diff:

-                if (dur.isNegative || dur == dur.max)
+                if (dur.isNegative || dur == Duration.max)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4abdfd2 and f461864.

📒 Files selected for processing (1)
  • source/dcell/termio.d (1 hunks)
🔇 Additional comments (1)
source/dcell/termio.d (1)

279-290: LGTM! Good overflow prevention.

The addition of || dur == Duration.max correctly prevents potential overflow when converting Duration.max to microseconds at line 285. Treating Duration.max as an infinite wait (by setting tvp to null) is semantically appropriate and prevents arithmetic overflow in the subsequent timeout calculations.

@gdamore gdamore force-pushed the gdamore/duration-max branch from f461864 to 2ac63fc Compare December 10, 2025 07:23
@gdamore gdamore merged commit b9be06d into main Dec 10, 2025
3 checks passed
@gdamore gdamore deleted the gdamore/duration-max branch December 10, 2025 07:30
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