func (p *pipe) Read(d []byte) (n int, err error) {
	p.mu.Lock()
	defer p.mu.Unlock()
	if p.c.L == nil {
		p.c.L = &p.mu
	}
	for {
		if p.breakErr != nil {
			return 0, p.breakErr
		}
		if p.b.Len() > 0 {
			return p.b.Read(d)
		}
		if p.err != nil {
			if p.readFn != nil {
				p.readFn()      
				p.readFn = nil  
			}
			return 0, p.err
		}
		p.c.Wait()
	}
}
Read waits until data is available and copies bytes
from the buffer into p.
package http2
import (
	"errors"
	"io"
	"sync"
)
type pipe struct {
	mu       sync.Mutex
	c        sync.Cond  
	b        pipeBuffer
	err      error          
	breakErr error          
	donec    chan struct{}  
	readFn   func()         
}
type pipeBuffer interface {
	Len() int
	io.Writer
	io.Reader
}
func (p *pipe) Len() int {
	p.mu.Lock()
	defer p.mu.Unlock()
	return p.b.Len()
}