Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83bead4

Browse files
authored
internal/buffer: set closed flag when closing channel in the Load method (#8575)
## DescriptionThis PR fixes a bug in the `Unbounded.Load()` method where the `closed`flag was not being set to `true` when the channel was closed.## ProblemIn the `Load()` method, when the condition `b.closing && !b.closed` ismet, the code closes the channel but doesn't update the `closed` flag.This creates an inconsistent state where:- The channel is closed (no more data can be sent)- But `b.closed` remains `false`This inconsistency could potentially cause issues in code that relies onthe `closed` flag to determine the buffer's state.## SolutionAdded `b.closed = true` before `close(b.c)` in the `else if` branch ofthe `Load()` method to ensure the closed flag accurately reflects thebuffer's state.## Changes- **File**: `internal/buffer/unbounded.go`- **Method**: `Load()`- **Line**: 86- **Change**: Added `b.closed = true` before closing the channel## Testing- ✅ All existing tests pass- ✅ No linter errors introduced- ✅ The fix ensures consistent state between channel closure and closedflag## ImpactThis is a bug fix that improves the correctness of the `Unbounded`buffer implementation without changing its public API or behavior from auser perspective.Fixes:#8572RELEASE NOTES: None
1 parent0f45079 commit83bead4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

‎internal/buffer/unbounded.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (b *Unbounded) Load() {
8383
default:
8484
}
8585
}elseifb.closing&&!b.closed {
86+
b.closed=true
8687
close(b.c)
8788
}
8889
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp