Browse code

goroutine fairness is not guaranteed causing the hang with GCCGO Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>

Srini Brahmaroutu authored on 2015/09/25 09:13:38
Showing 1 changed files
... ...
@@ -84,6 +84,9 @@ func NewBufReaderWithDrainbufAndBuffer(r io.Reader, drainBuffer []byte, buffer i
84 84
 
85 85
 func (r *bufReader) drain() {
86 86
 	for {
87
+		//Call to scheduler is made to yield from this goroutine.
88
+		//This avoids goroutine looping here when n=0,err=nil, fixes code hangs when run with GCC Go.
89
+		callSchedulerIfNecessary()
87 90
 		n, err := r.reader.Read(r.drainBuf)
88 91
 		r.Lock()
89 92
 		if err != nil {
... ...
@@ -98,7 +101,6 @@ func (r *bufReader) drain() {
98 98
 		}
99 99
 		r.wait.Signal()
100 100
 		r.Unlock()
101
-		callSchedulerIfNecessary()
102 101
 		if err != nil {
103 102
 			break
104 103
 		}