-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpcserver: fix recoveryPending
attribute
#355
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1148,12 +1148,19 @@ func (s *rpcServer) RecoverAccounts(ctx context.Context, | |
|
||
s.recoveryMutex.Lock() | ||
if s.recoveryPending { | ||
defer s.recoveryMutex.Unlock() | ||
s.recoveryMutex.Unlock() | ||
return nil, fmt.Errorf("recovery already in progress") | ||
} | ||
s.recoveryPending = true | ||
s.recoveryMutex.Unlock() | ||
|
||
// Mark the recovery process as done whenever we finish. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we move this whole block just one line down, so it's after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, my comment was a bit inaccurate. But the |
||
defer func() { | ||
s.recoveryMutex.Lock() | ||
s.recoveryPending = false | ||
s.recoveryMutex.Unlock() | ||
}() | ||
|
||
log.Infof("Attempting to recover accounts...") | ||
|
||
var recoveredAccounts []*account.Account | ||
|
@@ -1188,10 +1195,6 @@ func (s *rpcServer) RecoverAccounts(ctx context.Context, | |
} | ||
} | ||
|
||
s.recoveryMutex.Lock() | ||
s.recoveryPending = false | ||
s.recoveryMutex.Unlock() | ||
|
||
return &poolrpc.RecoverAccountsResponse{ | ||
NumRecoveredAccounts: uint32(numRecovered), | ||
}, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alternatively we could just use an atomic int to avoid the (slightly complex) locking logic.