mirror of https://github.com/v2ray/v2ray-core
Fix deadlock in kcp.read
parent
e13ea7a54f
commit
a88a120938
|
@ -179,8 +179,12 @@ func (this *Connection) Read(b []byte) (int, error) {
|
||||||
return nBytes, nil
|
return nBytes, nil
|
||||||
}
|
}
|
||||||
var timer *time.Timer
|
var timer *time.Timer
|
||||||
if !this.rd.IsZero() && this.rd.Before(time.Now()) {
|
if !this.rd.IsZero() {
|
||||||
timer = time.AfterFunc(this.rd.Sub(time.Now()), this.dataInputCond.Signal)
|
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.L.Lock()
|
||||||
this.dataInputCond.Wait()
|
this.dataInputCond.Wait()
|
||||||
|
|
Loading…
Reference in New Issue