Skip to content

Commit

Permalink
OnStop
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Apr 24, 2023
1 parent 18c9af7 commit 023605a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func waitForAndValidateBlockWithTx(
) {
t.Helper()

ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()

fn := func(j int) {
Expand Down
2 changes: 2 additions & 0 deletions internal/dbsync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ func (r *Reactor) OnStart(ctx context.Context) error {
func (r *Reactor) OnStop() {
// tell the dispatcher to stop sending any more requests
r.dispatcher.Close()
// clear up half-populated directories
r.syncer.Stop()
}

func (r *Reactor) handleMetadataRequest(ctx context.Context, req *dstypes.MetadataRequest, from types.NodeID) (err error) {
Expand Down
9 changes: 9 additions & 0 deletions internal/dbsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ func (s *Syncer) Process(ctx context.Context) {
}
}

func (s *Syncer) Stop() {
s.mtx.Lock()
defer s.mtx.Unlock()
if s.active {
s.resetDirFn(s)
s.active = false
}
}

func (s *Syncer) processFile(ctx context.Context, file *dstypes.FileResponse) error {
s.mtx.Lock()
defer s.mtx.Unlock()
Expand Down

0 comments on commit 023605a

Please sign in to comment.