Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Prevent multiple instances of "ipfs routing reprovide" running …
…at the same time
  • Loading branch information
gsergey418 committed Feb 5, 2025
commit ca1fabf702eb3f5ae6b02bba8c644769003c44ac
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ The following emojis are used to highlight certain changes:

### Changed

- `provider`: Prevent multiple instances of reprovider.Reprovide() from running at the same time.

### Removed

### Fixed
Expand Down
7 changes: 7 additions & 0 deletions provider/reprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ctx context.Context
close context.CancelFunc
closewg sync.WaitGroup
mu sync.Mutex

reprovideInterval time.Duration
initalReprovideDelay time.Duration
Expand Down Expand Up @@ -470,6 +471,12 @@
return nil
}

ok := s.mu.TryLock()
if !ok {
return fmt.Errorf("instance of reprovide already running")
}

Check warning on line 477 in provider/reprovider.go

View check run for this annotation

Codecov / codecov/patch

provider/reprovider.go#L476-L477

Added lines #L476 - L477 were not covered by tests
defer s.mu.Unlock()

kch, err := s.keyProvider(ctx)
if err != nil {
return err
Expand Down
Loading