mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-04-21 17:01:35 +00:00
Fix deadlock in kcp.read
This commit is contained in:
@@ -179,8 +179,12 @@ func (this *Connection) Read(b []byte) (int, error) {
|
||||
return nBytes, nil
|
||||
}
|
||||
var timer *time.Timer
|
||||
if !this.rd.IsZero() && this.rd.Before(time.Now()) {
|
||||
timer = time.AfterFunc(this.rd.Sub(time.Now()), this.dataInputCond.Signal)
|
||||
if !this.rd.IsZero() {
|
||||
duration := this.rd.Sub(time.Now())
|
||||
if duration <= 0 {
|
||||
return 0, errTimeout
|
||||
}
|
||||
timer = time.AfterFunc(duration, this.dataInputCond.Signal)
|
||||
}
|
||||
this.dataInputCond.L.Lock()
|
||||
this.dataInputCond.Wait()
|
||||
|
||||
Reference in New Issue
Block a user