Skip to content

fix: handle negative keepalive replies - #21

Merged
skevetter merged 2 commits into
mainfrom
fix/keepalive-negative-replies
Sep 1, 2026
Merged

fix: handle negative keepalive replies#21
skevetter merged 2 commits into
mainfrom
fix/keepalive-negative-replies

Conversation

@skevetter

@skevetter skevetter commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • require both ok == true and err == nil before resetting server keepalive state
  • apply the check to channel-level and connection-level keepalive requests
  • add regressions proving negative replies do not postpone transport teardown

Verification

  • go test ./...
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Improved SSH connection keep-alive handling so negative replies no longer incorrectly reset connection activity timers.
    • Stalled connections can now close as expected when keep-alive requests are rejected.
  • Tests

    • Added coverage for rejected global and channel keep-alive replies.
    • Simplified test syntax without changing behavior.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d0e7ec51-ee15-48bf-8f58-e192a3ec54a6

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0e347 and 0245983.

📒 Files selected for processing (3)
  • options_test.go
  • server.go
  • server_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The server now resets keepalive liveness timers only after positive replies. New tests cover negative global and channel replies. Test code also removes redundant atomic-expression parentheses.

Keepalive validation

Layer / File(s) Summary
Reply-aware keepalive handling
server.go, server_test.go
connectionKeepAlive checks both the error and boolean reply. Tests verify that negative global and channel replies do not reset the liveness deadline.
Atomic expression cleanup
options_test.go
Test code removes redundant parentheses from atomic field address expressions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 02459

The change prevents negative keepalive replies from postponing transport teardown while preserving successful keepalive behavior, with regressions covering both request levels. No actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant connectionKeepAlive
  participant sshConn
  participant SSHPeer
  participant ConnectionClosingCallback
  connectionKeepAlive->>sshConn: SendRequest keepalive
  sshConn->>SSHPeer: Send keepalive
  SSHPeer-->>sshConn: Negative reply
  connectionKeepAlive->>connectionKeepAlive: Keep liveness deadline
  connectionKeepAlive->>ConnectionClosingCallback: Close after failure threshold
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: handling negative keepalive replies correctly.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/keepalive-negative-replies

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@skevetter
skevetter marked this pull request as ready for review September 1, 2026 07:04
@skevetter skevetter changed the title fix: honor negative keepalive replies fix: handle negative keepalive replies Sep 1, 2026
@skevetter
skevetter merged commit d06e298 into main Sep 1, 2026
6 checks passed
@skevetter
skevetter deleted the fix/keepalive-negative-replies branch September 1, 2026 07:07
@devsy-app devsy-app Bot mentioned this pull request Sep 1, 2026
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