Conversation
📝 WalkthroughWalkthroughThe changes add synchronization mechanisms to the Pipeline struct to prevent multiple closes on internal channels. A new Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
48344c9 to
d675772
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pipeline/pipeline.go (1)
36-36: ThecloseOnceguard appears redundant given the existingstopOnce.Since
closeOnce.Do()is nested insidestopOnce.Do()(line 169 within line 138), andstopOncealready guarantees the entire Stop body executes exactly once, the additionalcloseOnceprovides no extra protection. The channels are already guarded from double-close bystopOncealone.This may be defensive programming for future refactoring, but currently it adds unnecessary complexity.
Consider simplifying by removing
closeOnceand relying onstopOnce:- closeOnce sync.Once // protects channel closesAnd in Stop():
- // Close pipeline-owned channels safely - p.closeOnce.Do(func() { - close(p.errorChan) - close(p.filterChan) - close(p.outputChan) - }) + // Close pipeline-owned channels + close(p.errorChan) + close(p.filterChan) + close(p.outputChan)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pipeline/pipeline.go(2 hunks)pipeline/pipeline_test.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pipeline/pipeline_test.go (1)
pipeline/pipeline.go (1)
New(39-47)
🔇 Additional comments (2)
pipeline/pipeline_test.go (2)
28-40: Good test coverage for panic propagation.This test correctly verifies that Stop() propagates panics from plugin.Stop() rather than suppressing them, documenting important behavior for pipeline shutdown.
42-53: Excellent test for idempotent Stop() behavior.This test validates the PR's objective of making Stop() safe to call multiple times, ensuring no errors or panics occur on repeated calls.
|
Closing this in favor of #554 |
Summary by cubic
Make pipeline.Stop safe by closing internal channels only once, preventing panics from double close during repeated or concurrent stops. Added closeOnce to guard closing errorChan, filterChan, and outputChan.
Written for commit d675772. Summary will update automatically on new commits.
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.