Merge pull request #14605 from brahmaroutu/gccgo_scheduler

Go Scheduler issue with sync.Mutex
This commit is contained in:
David Calavera 2015-07-17 08:16:32 -07:00
Родитель b900aaac46 9ca913d0f1
Коммит 7b83b0e15c
4 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -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
pkg/ioutils/scheduler.go Normal file
Просмотреть файл

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

Просмотреть файл

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