pull/642/merge v2.43
Darien Raymond 2017-10-23 14:09:14 +02:00
parent 66b81a842d
commit 62258e6aef
1 changed files with 9 additions and 4 deletions

View File

@ -143,15 +143,20 @@ func (s *Stream) ReadTimeout(timeout time.Duration) (buf.MultiBuffer, error) {
}
}
// Size returns the number of bytes hold in the Stream.
func (s *Stream) Size() uint64 {
s.access.RLock()
defer s.access.RUnlock()
return s.size
}
func (s *Stream) waitForStreamSize() error {
if streamSizeLimit == 0 {
return nil
}
s.access.RLock()
defer s.access.RUnlock()
for streamSizeLimit > 0 && s.size >= streamSizeLimit {
for s.Size() >= streamSizeLimit {
select {
case <-s.ctx.Done():
return io.ErrClosedPipe