Always lock waddrmgr for every timeout or explicit request.

Use waddrmgr.IsError to avoid logging errors when trying to lock an
already locked wallet.

Fixes #349.
This commit is contained in:
Josh Rickmar 2016-01-31 20:33:40 -05:00
parent 4c839ae3d3
commit 515cbc69ce

View file

@ -693,20 +693,17 @@ out:
break out break out
case <-w.lockRequests: case <-w.lockRequests:
timeout = nil
case <-timeout: case <-timeout:
} }
// Select statement fell through by an explicit lock or the // Select statement fell through by an explicit lock or the
// timer expiring. Lock the manager here. // timer expiring. Lock the manager here.
if timeout != nil { timeout = nil
timeout = nil err := w.Manager.Lock()
err := w.Manager.Lock() if err != nil && !waddrmgr.IsError(err, waddrmgr.ErrLocked) {
if err != nil { log.Errorf("Could not lock wallet: %v", err)
log.Errorf("Could not lock wallet: %v", err) } else {
} else { w.notifyLockStateChange(true)
w.notifyLockStateChange(true)
}
} }
} }
w.wg.Done() w.wg.Done()