Skip to content

Commit

Permalink
fix restart timers after change leader (#477)
Browse files Browse the repository at this point in the history
Co-authored-by: Фёдор Партанский <partanskiy.f@n-t.io>
Co-authored-by: C0rWin <artem@bargr.net>
  • Loading branch information
3 people authored Dec 13, 2021
1 parent 0e34e5b commit 86be08d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/bft/requestpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@ func (rp *Pool) RestartTimers() {
for reqInfo, element := range rp.existMap {
item := element.Value.(*requestItem)
item.timeout.Stop()
ri := reqInfo
to := time.AfterFunc(
rp.options.ForwardTimeout,
func() { rp.onRequestTO(item.request, reqInfo) },
func() { rp.onRequestTO(item.request, ri) },
)
item.timeout = to
}
Expand Down Expand Up @@ -414,7 +415,7 @@ func (rp *Pool) onRequestTO(request []byte, reqInfo types.RequestInfo) {
return
}

//start a second timeout
// start a second timeout
item := element.Value.(*requestItem)
item.timeout = time.AfterFunc(
rp.options.ComplainTimeout,
Expand Down Expand Up @@ -450,7 +451,7 @@ func (rp *Pool) onLeaderFwdRequestTO(request []byte, reqInfo types.RequestInfo)
return
}

//start a third timeout
// start a third timeout
item := element.Value.(*requestItem)
item.timeout = time.AfterFunc(
rp.options.AutoRemoveTimeout,
Expand Down

0 comments on commit 86be08d

Please sign in to comment.