goroutine fairness is not guaranteed causing the hang with GCCGO

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
Upstream-commit: 7c52fcce855e446752b6ad642dd4d6c0d732b8f3
Component: engine
This commit is contained in:
Srini Brahmaroutu
2015-09-25 14:40:16 +00:00
parent 58c0f4ebe8
commit df6cc87bb6
+3 -1
View File
@@ -84,6 +84,9 @@ func NewBufReaderWithDrainbufAndBuffer(r io.Reader, drainBuffer []byte, buffer i
func (r *bufReader) drain() {
for {
//Call to scheduler is made to yield from this goroutine.
//This avoids goroutine looping here when n=0,err=nil, fixes code hangs when run with GCC Go.
callSchedulerIfNecessary()
n, err := r.reader.Read(r.drainBuf)
r.Lock()
if err != nil {
@@ -98,7 +101,6 @@ func (r *bufReader) drain() {
}
r.wait.Signal()
r.Unlock()
callSchedulerIfNecessary()
if err != nil {
break
}