mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(rpc): timeout with response in rpc client for timer reset
@formatter:off Signed-off-by: JasonHu520 <huzongchao@oppo.com>
This commit is contained in:
parent
d076024883
commit
b4309236a2
@ -357,6 +357,7 @@ type timeoutReadCloser struct {
|
||||
timer *time.Timer
|
||||
timeout time.Duration
|
||||
closeOnce sync.Once
|
||||
hasRead bool
|
||||
}
|
||||
|
||||
func (tr *timeoutReadCloser) Close() (err error) {
|
||||
@ -371,6 +372,14 @@ func (tr *timeoutReadCloser) Read(p []byte) (int, error) {
|
||||
if tr.timeout <= 0 {
|
||||
return 0, ErrBodyReadTimeout
|
||||
}
|
||||
|
||||
if tr.hasRead {
|
||||
select {
|
||||
case <-tr.timer.C:
|
||||
default:
|
||||
}
|
||||
}
|
||||
tr.hasRead = true
|
||||
tr.timer.Reset(tr.timeout)
|
||||
|
||||
start := time.Now()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user