Skip to content

Commit

Permalink
fix: proper cancel backupFetchingTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed Feb 5, 2025
1 parent c6e16d9 commit b003957
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion protocol/messenger_backup_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,30 @@ func (m *Messenger) startBackupFetchingTracking(response *MessengerResponse) err
}

// Add a timeout to mark the backup syncing as failed after 1 minute and 30 seconds
time.AfterFunc(90*time.Second, m.backupFetchingTimeout)
m.shutdownWaitGroup.Add(1)
go func() {
defer utils.LogOnPanic()
defer m.shutdownWaitGroup.Done()
m.watchBackupFetching()
}()

return nil
}

func (m *Messenger) watchBackupFetching() {
select {
case <-m.ctx.Done():
return
case <-time.After(90 * time.Second):
m.backupFetchingTimeout()
}
}

func (m *Messenger) backupFetchingTimeout() {
if m.backedUpFetchingStatus == nil {
return
}

m.backedUpFetchingStatus.fetchingCompletedMutex.Lock()
defer m.backedUpFetchingStatus.fetchingCompletedMutex.Unlock()

Expand Down

0 comments on commit b003957

Please sign in to comment.