Merge pull request #5116 from joostjager/mc-deadlock

routing: fix mission control deadlock
This commit is contained in:
Olaoluwa Osuntokun
2021-04-05 20:02:57 -07:00
committed by GitHub

View File

@@ -238,9 +238,6 @@ func NewMissionControl(db kvdb.Backend, self route.Vertex,
func (m *MissionControl) init() error {
log.Debugf("Mission control state reconstruction started")
m.Lock()
defer m.Unlock()
start := time.Now()
results, err := m.store.fetchAll()
@@ -392,9 +389,6 @@ func (m *MissionControl) ReportPaymentFail(paymentID uint64, rt *route.Route,
failureSourceIdx *int, failure lnwire.FailureMessage) (
*channeldb.FailureReason, error) {
m.Lock()
defer m.Unlock()
timestamp := m.now()
result := &paymentResult{
@@ -415,9 +409,6 @@ func (m *MissionControl) ReportPaymentFail(paymentID uint64, rt *route.Route,
func (m *MissionControl) ReportPaymentSuccess(paymentID uint64,
rt *route.Route) error {
m.Lock()
defer m.Unlock()
timestamp := m.now()
result := &paymentResult{
@@ -442,6 +433,9 @@ func (m *MissionControl) processPaymentResult(result *paymentResult) (
return nil, err
}
m.Lock()
defer m.Unlock()
// Apply result to update mission control state.
reason := m.applyPaymentResult(result)