mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
fix error handling in ray
This commit is contained in:
parent
226d65c6c7
commit
f1231822f7
@ -85,14 +85,14 @@ func (s *Stream) getData() (buf.MultiBuffer, error) {
|
|||||||
return mb, nil
|
return mb, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.close {
|
|
||||||
return nil, io.EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.err {
|
if s.err {
|
||||||
return nil, io.ErrClosedPipe
|
return nil, io.ErrClosedPipe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.close {
|
||||||
|
return nil, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ func (s *Stream) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-s.ctx.Done():
|
case <-s.ctx.Done():
|
||||||
return nil, io.EOF
|
return nil, s.ctx.Err()
|
||||||
case <-s.writeSignal.Wait():
|
case <-s.writeSignal.Wait():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ func (s *Stream) ReadTimeout(timeout time.Duration) (buf.MultiBuffer, error) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-s.ctx.Done():
|
case <-s.ctx.Done():
|
||||||
return nil, io.EOF
|
return nil, s.ctx.Err()
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
return nil, buf.ErrReadTimeout
|
return nil, buf.ErrReadTimeout
|
||||||
case <-s.writeSignal.Wait():
|
case <-s.writeSignal.Wait():
|
||||||
@ -167,7 +167,7 @@ func (s *Stream) waitForStreamSize() error {
|
|||||||
for s.Size() >= streamSizeLimit {
|
for s.Size() >= streamSizeLimit {
|
||||||
select {
|
select {
|
||||||
case <-s.ctx.Done():
|
case <-s.ctx.Done():
|
||||||
return io.ErrClosedPipe
|
return s.ctx.Err()
|
||||||
case <-s.readSignal.Wait():
|
case <-s.readSignal.Wait():
|
||||||
if s.err || s.close {
|
if s.err || s.close {
|
||||||
return io.ErrClosedPipe
|
return io.ErrClosedPipe
|
||||||
@ -227,7 +227,9 @@ func (s *Stream) CloseError() {
|
|||||||
s.data = nil
|
s.data = nil
|
||||||
s.size = 0
|
s.size = 0
|
||||||
}
|
}
|
||||||
|
s.access.Unlock()
|
||||||
|
|
||||||
s.readSignal.Signal()
|
s.readSignal.Signal()
|
||||||
s.writeSignal.Signal()
|
s.writeSignal.Signal()
|
||||||
s.access.Unlock()
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user