From 3b9d84b1e29fae81c2ba7db28634c6a329d14755 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Tue, 14 Jan 2014 20:21:27 -0500 Subject: [PATCH] Release reader lock before syncing to disk. When disk syncing a wallet file, if the wallet is flagged dirty, the disk syncer must grab the wallet writer lock to set dirty=false. The disk syncing code was being called in the end of (*Account).RescanActiveAddresses with the reader lock held (unlocked using a defer), which prevented the writer lock from being aquired. This change removes the defered unlock to release the reader lock before syncing to disk. --- account.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/account.go b/account.go index 6a3a71c..be622b9 100644 --- a/account.go +++ b/account.go @@ -473,10 +473,8 @@ func (a *Account) Track() { // it would have missed notifications as blocks are attached to the // main chain. func (a *Account) RescanActiveAddresses() { - a.mtx.RLock() - defer a.mtx.RUnlock() - // Determine the block to begin the rescan from. + a.mtx.RLock() beginBlock := int32(0) if a.fullRescan { // Need to perform a complete rescan since the wallet creation @@ -498,6 +496,7 @@ func (a *Account) RescanActiveAddresses() { // Rescan active addresses starting at the determined block height. Rescan(CurrentRPCConn(), beginBlock, a.ActivePaymentAddresses()) + a.mtx.RUnlock() a.writeDirtyToDisk() }