Commit f1a6def3 authored by acud's avatar acud Committed by GitHub

fix pullsync shutdown (#379)

parent 80ce35e6
...@@ -218,12 +218,15 @@ func (s *Syncer) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) err ...@@ -218,12 +218,15 @@ func (s *Syncer) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) err
s.ruidMtx.Lock() s.ruidMtx.Lock()
s.ruidCtx[ru.Ruid] = cancel s.ruidCtx[ru.Ruid] = cancel
s.ruidMtx.Unlock() s.ruidMtx.Unlock()
defer func() { cc := make(chan struct{})
defer close(cc)
go func() {
select { select {
case <-s.quit: case <-s.quit:
cancel()
case <-ctx.Done(): case <-ctx.Done():
case <-cc:
} }
cancel()
s.ruidMtx.Lock() s.ruidMtx.Lock()
delete(s.ruidCtx, ru.Ruid) delete(s.ruidCtx, ru.Ruid)
s.ruidMtx.Unlock() s.ruidMtx.Unlock()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment