Skip to content

Commit

Permalink
fix: revert pullsync
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Jul 21, 2023
1 parent 25b1234 commit 05e5b05
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pkg/pullsync/pullsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/ethersphere/bee/pkg/storage"
storer "github.com/ethersphere/bee/pkg/storer"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/util"
"resenje.org/multex"
"resenje.org/singleflight"
)
Expand Down Expand Up @@ -86,7 +85,6 @@ type Syncer struct {
intervalsSF singleflight.Group
syncInProgress atomic.Int32
binLock *multex.Multex
inFlight *util.WaitingCounter

maxPage uint64

Expand All @@ -113,7 +111,6 @@ func New(
quit: make(chan struct{}),
maxPage: maxPage,
binLock: multex.New(),
inFlight: new(util.WaitingCounter),
}
}

Expand Down Expand Up @@ -560,10 +557,22 @@ func (s *Syncer) cursorHandler(ctx context.Context, p p2p.Peer, stream p2p.Strea
func (s *Syncer) Close() error {
s.logger.Info("pull syncer shutting down")
close(s.quit)
cc := make(chan struct{})
go func() {
defer close(cc)
for {
if s.syncInProgress.Load() > 0 {
time.Sleep(100 * time.Millisecond)
continue
}
break
}
}()

if rgr := s.inFlight.Wait(5 * time.Second); rgr > 0 {
select {
case <-cc:
case <-time.After(5 * time.Second):
s.logger.Warning("pull syncer shutting down with running goroutines")
}

return nil
}

0 comments on commit 05e5b05

Please sign in to comment.