Skip to content

Commit

Permalink
Release Lock Before Panicking (#12464)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas authored May 25, 2023
1 parent be16b64 commit 52da7b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions async/event/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (f *Feed) Send(value interface{}) (nsent int) {

if !f.typecheck(rvalue.Type()) {
f.sendLock <- struct{}{}
f.mu.Unlock()
panic(feedTypeError{op: "Send", got: rvalue.Type(), want: f.etype})
}
f.mu.Unlock()
Expand Down
2 changes: 2 additions & 0 deletions async/event/feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func TestFeedPanics(t *testing.T) {
f.Send(2)
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(0)}
assert.NoError(t, checkPanic(want, func() { f.Send(uint64(2)) }))
// Validate it doesn't deadlock.
assert.NoError(t, checkPanic(want, func() { f.Send(uint64(2)) }))
}
{
var f Feed
Expand Down

0 comments on commit 52da7b3

Please sign in to comment.