Skip to content

Commit

Permalink
system: fix sink pool test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpi committed Mar 7, 2023
1 parent 74b1c46 commit a373bf8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion system/sink_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ func MutexLocked(m *sync.RWMutex) bool {

state := v.FieldByName("w").FieldByName("state")

return state.Int()&1 == 1 || v.FieldByName("readerCount").Int() > 0
readerCountField := v.FieldByName("readerCount")
// go1.20 changed readerCount to an atomic
// ref; https://github.com/golang/go/commit/e509452727b469d89a3fc4a7d1cbf9d3f110efee
var readerCount int64
if readerCountField.Kind() == reflect.Struct {
readerCount = readerCountField.FieldByName("v").Int()
} else {
readerCount = readerCountField.Int()
}
return state.Int()&1 == 1 || readerCount > 0
}

func TestSink(t *testing.T) {
Expand Down

0 comments on commit a373bf8

Please sign in to comment.