Explorar el Código

Go Scheduler issue with sync.Mutex using gccgo

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
root hace 10 años
padre
commit
9ca913d0f1

+ 1 - 0
pkg/ioutils/readers.go

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

+ 1 - 1
pkg/ioutils/readers_test.go

@@ -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 - 0
pkg/ioutils/scheduler.go

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

+ 13 - 0
pkg/ioutils/scheduler_gccgo.go

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