Go Scheduler issue with sync.Mutex using gccgo
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
parent
4832a3dc2d
commit
b0e927fed5
4 changed files with 21 additions and 1 deletions
|
@ -189,6 +189,7 @@ func (r *bufReader) drain() {
|
|||
reuseCount++
|
||||
r.wait.Signal()
|
||||
r.Unlock()
|
||||
callSchedulerIfNecessary()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestReaderErrWrapperReadOnError(t *testing.T) {
|
|||
func TestReaderErrWrapperRead(t *testing.T) {
|
||||
reader := strings.NewReader("a string reader.")
|
||||
wrapper := NewReaderErrWrapper(reader, func() {
|
||||
t.Fatalf("readErrWrapper should not have called the anonymous function on failure")
|
||||
t.Fatalf("readErrWrapper should not have called the anonymous function")
|
||||
})
|
||||
// Read 20 byte (should be ok with the string above)
|
||||
num, err := wrapper.Read(make([]byte, 20))
|
||||
|
|
6
ioutils/scheduler.go
Normal file
6
ioutils/scheduler.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
// +build !gccgo
|
||||
|
||||
package ioutils
|
||||
|
||||
func callSchedulerIfNecessary() {
|
||||
}
|
13
ioutils/scheduler_gccgo.go
Normal file
13
ioutils/scheduler_gccgo.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// +build gccgo
|
||||
|
||||
package ioutils
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func callSchedulerIfNecessary() {
|
||||
//allow or force Go scheduler to switch context, without explicitly
|
||||
//forcing this will make it hang when using gccgo implementation
|
||||
runtime.Gosched()
|
||||
}
|
Loading…
Reference in a new issue