statesync: remove deadlock on init fail

This commit is contained in:
William Banfield
2021-09-29 14:16:50 -04:00
parent 23fe6fd2f9
commit 7679cc5015

View File

@@ -274,12 +274,14 @@ func (r *Reactor) Sync(ctx context.Context) (sm.State, error) {
}
r.mtx.Lock()
defer r.mtx.Unlock()
if r.syncer != nil {
r.mtx.Unlock()
return sm.State{}, errors.New("a state sync is already in progress")
}
if err := r.initStateProvider(ctx, r.chainID, r.initialHeight); err != nil {
r.mtx.Unlock()
return sm.State{}, err
}
@@ -889,11 +891,10 @@ func (r *Reactor) processPeerUpdate(peerUpdate p2p.PeerUpdate) {
}
r.mtx.Lock()
defer r.mtx.Unlock()
if r.syncer == nil {
r.mtx.Unlock()
return
}
defer r.mtx.Unlock()
switch peerUpdate.Status {
case p2p.PeerStatusUp: