1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-28 10:15:23 +00:00
This commit is contained in:
Darien Raymond 2017-10-23 14:09:14 +02:00
parent 66b81a842d
commit 62258e6aef

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