Skip to content

Commit

Permalink
fix v2ray#638
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Oct 23, 2017
1 parent 66b81a8 commit 62258e6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions transport/ray/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62258e6

Please sign in to comment.