1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

destroy timer immedietely after use

This commit is contained in:
Darien Raymond 2018-08-09 12:23:27 +02:00
parent b238188770
commit c81531fc77
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -82,7 +82,9 @@ func (p *pipe) ReadMultiBuffer() (buf.MultiBuffer, error) {
}
func (p *pipe) ReadMultiBufferTimeout(d time.Duration) (buf.MultiBuffer, error) {
timer := time.After(d)
timer := time.NewTimer(d)
defer timer.Stop()
for {
data, err := p.readMultiBufferInternal()
if data != nil || err != nil {
@ -93,7 +95,7 @@ func (p *pipe) ReadMultiBufferTimeout(d time.Duration) (buf.MultiBuffer, error)
select {
case <-p.readSignal.Wait():
case <-p.done.Wait():
case <-timer:
case <-timer.C:
return nil, buf.ErrReadTimeout
}
}