mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-15 09:34:00 +08:00
TimeoutWrapperReader: Fix latency issue
Pre-released for 2 days and no one had ever noticed this issue until today : (
This commit is contained in:
@@ -54,12 +54,16 @@ func (r *TimeoutWrapperReader) ReadMultiBufferTimeout(duration time.Duration) (M
|
||||
close(r.done)
|
||||
}()
|
||||
}
|
||||
time.Sleep(duration)
|
||||
timeout := make(chan struct{})
|
||||
go func() {
|
||||
time.Sleep(duration)
|
||||
close(timeout)
|
||||
}()
|
||||
select {
|
||||
case <-r.done:
|
||||
r.done = nil
|
||||
return r.mb, r.err
|
||||
default:
|
||||
case <-timeout:
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user