Skip to content

Commit 86be08d

Browse files
pfi79C0rWin
andauthored
fix restart timers after change leader (#477)
Co-authored-by: Фёдор Партанский <partanskiy.f@n-t.io> Co-authored-by: C0rWin <artem@bargr.net>
1 parent 0e34e5b commit 86be08d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/bft/requestpool.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,10 @@ func (rp *Pool) RestartTimers() {
376376
for reqInfo, element := range rp.existMap {
377377
item := element.Value.(*requestItem)
378378
item.timeout.Stop()
379+
ri := reqInfo
379380
to := time.AfterFunc(
380381
rp.options.ForwardTimeout,
381-
func() { rp.onRequestTO(item.request, reqInfo) },
382+
func() { rp.onRequestTO(item.request, ri) },
382383
)
383384
item.timeout = to
384385
}
@@ -414,7 +415,7 @@ func (rp *Pool) onRequestTO(request []byte, reqInfo types.RequestInfo) {
414415
return
415416
}
416417

417-
//start a second timeout
418+
// start a second timeout
418419
item := element.Value.(*requestItem)
419420
item.timeout = time.AfterFunc(
420421
rp.options.ComplainTimeout,
@@ -450,7 +451,7 @@ func (rp *Pool) onLeaderFwdRequestTO(request []byte, reqInfo types.RequestInfo)
450451
return
451452
}
452453

453-
//start a third timeout
454+
// start a third timeout
454455
item := element.Value.(*requestItem)
455456
item.timeout = time.AfterFunc(
456457
rp.options.AutoRemoveTimeout,

0 commit comments

Comments
 (0)