[#393] rpc/grpc: Use NewTimer
instead of time.After
From the docs of `time.After`: ``` The underlying Timer is not recovered by the garbage collector until the timer fires. ``` We have 1 minute default timeout, which is pretty long given that most of the time we exchange small messages. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
23702bc51a
commit
e8e09f0d00
1 changed files with 4 additions and 1 deletions
|
@ -57,10 +57,13 @@ func (w *streamWrapper) withTimeout(closure func() error) error {
|
||||||
close(ch)
|
close(ch)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
tt := time.NewTimer(w.timeout)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err := <-ch:
|
case err := <-ch:
|
||||||
|
tt.Stop()
|
||||||
return err
|
return err
|
||||||
case <-time.After(w.timeout):
|
case <-tt.C:
|
||||||
w.cancel()
|
w.cancel()
|
||||||
return context.DeadlineExceeded
|
return context.DeadlineExceeded
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue