system: fix sink pool test

This commit is contained in:
Matthew Penner 2023-03-07 15:36:20 -07:00
parent 74b1c46b7f
commit a373bf8eda
No known key found for this signature in database

View File

@ -15,7 +15,16 @@ func MutexLocked(m *sync.RWMutex) bool {
state := v.FieldByName("w").FieldByName("state") 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) { func TestSink(t *testing.T) {