clear store error in responseHook if ErrResourceDoesNotExist appear

This commit is contained in:
Lawrence, Rendall
2022-04-14 01:52:52 +03:00
parent 781fa9440f
commit 57d9c8e78e
2 changed files with 5 additions and 2 deletions

View File

@@ -50,7 +50,7 @@ func (h *swarmInteractionHook) HandleAnnounce(ctx context.Context, req *bittorre
err = h.store.GraduateLeecher(req.InfoHash, req.Peer)
return ctx, err
case req.Left == 0:
// Completed events will also have Key == 0, but by making this
// Completed events will also have Left == 0, but by making this
// an extra case we can treat "old" seeders differently from
// graduating leechers. (Calling PutSeeder is probably faster
// than calling GraduateLeecher.)
@@ -110,6 +110,7 @@ func (h *responseHook) appendPeers(req *bittorrent.AnnounceRequest, resp *bittor
if err != nil && !errors.Is(err, storage.ErrResourceDoesNotExist) {
return err
}
err = nil
// Some clients expect a minimum of their own peer representation returned to
// them if they are the only peer in a swarm.

View File

@@ -611,7 +611,9 @@ func (ps *store) collectGarbage(cutoff time.Time) error {
func (ps *store) Stop() stop.Result {
c := make(stop.Channel)
go func() {
close(ps.closed)
if ps.closed != nil {
close(ps.closed)
}
ps.wg.Wait()
// Explicitly deallocate our storage.