mirror of
https://github.com/minio/minio.git
synced 2024-12-26 07:05:55 -05:00
dsync: use refresh timer properly to avoid leaks (#11820)
timer pattern should always involve a 'Stop()/Reset()' otherwise `time.NewTimer(duration).C` will always leak.
This commit is contained in:
parent
add3cd4e44
commit
eed3b66d98
@ -220,11 +220,17 @@ func (dm *DRWMutex) startContinousLockRefresh(lockLossCallback func(), id, sourc
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
refreshTimer := time.NewTimer(drwMutexRefreshInterval)
|
||||||
|
defer refreshTimer.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-time.NewTimer(drwMutexRefreshInterval).C:
|
case <-refreshTimer.C:
|
||||||
|
refreshTimer.Reset(drwMutexRefreshInterval)
|
||||||
|
|
||||||
refreshed, err := refresh(ctx, dm.clnt, id, source, quorum, dm.Names...)
|
refreshed, err := refresh(ctx, dm.clnt, id, source, quorum, dm.Names...)
|
||||||
if err == nil && !refreshed {
|
if err == nil && !refreshed {
|
||||||
if lockLossCallback != nil {
|
if lockLossCallback != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user