Go Scheduler issue with sync.Mutex using gccgo

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
root 2015-07-09 23:23:03 +00:00
parent 48a01a317c
commit 9ca913d0f1
4 changed files with 21 additions and 1 deletions

View file

@ -189,6 +189,7 @@ func (r *bufReader) drain() {
reuseCount++
r.wait.Signal()
r.Unlock()
callSchedulerIfNecessary()
if err != nil {
break
}

View file

@ -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
pkg/ioutils/scheduler.go Normal file
View file

@ -0,0 +1,6 @@
// +build !gccgo
package ioutils
func callSchedulerIfNecessary() {
}

View 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()
}