@@ -93,13 +93,14 @@ std::shared_ptr<CWallet> GetWallet(const std::string& name)
93
93
94
94
static Mutex g_wallet_release_mutex;
95
95
static std::condition_variable g_wallet_release_cv;
96
- static std::set<CWallet* > g_unloading_wallet_set;
96
+ static std::set<std::string > g_unloading_wallet_set;
97
97
98
98
// Custom deleter for shared_ptr<CWallet>.
99
99
static void ReleaseWallet (CWallet* wallet)
100
100
{
101
101
// Unregister and delete the wallet right after BlockUntilSyncedToCurrentChain
102
102
// so that it's in sync with the current chainstate.
103
+ const std::string name = wallet->GetName ();
103
104
wallet->WalletLogPrintf (" Releasing wallet\n " );
104
105
wallet->BlockUntilSyncedToCurrentChain ();
105
106
wallet->Flush ();
@@ -108,7 +109,7 @@ static void ReleaseWallet(CWallet* wallet)
108
109
// Wallet is now released, notify UnloadWallet, if any.
109
110
{
110
111
LOCK (g_wallet_release_mutex);
111
- if (g_unloading_wallet_set.erase (wallet ) == 0 ) {
112
+ if (g_unloading_wallet_set.erase (name ) == 0 ) {
112
113
// UnloadWallet was not called for this wallet, all done.
113
114
return ;
114
115
}
@@ -119,21 +120,21 @@ static void ReleaseWallet(CWallet* wallet)
119
120
void UnloadWallet (std::shared_ptr<CWallet>&& wallet)
120
121
{
121
122
// Mark wallet for unloading.
122
- CWallet* pwallet = wallet. get ();
123
+ const std::string name = wallet-> GetName ();
123
124
{
124
125
LOCK (g_wallet_release_mutex);
125
- auto it = g_unloading_wallet_set.insert (pwallet );
126
+ auto it = g_unloading_wallet_set.insert (name );
126
127
assert (it.second );
127
128
}
128
129
// The wallet can be in use so it's not possible to explicitly unload here.
129
130
// Notify the unload intent so that all remaining shared pointers are
130
131
// released.
131
- pwallet ->NotifyUnload ();
132
+ wallet ->NotifyUnload ();
132
133
// Time to ditch our shared_ptr and wait for ReleaseWallet call.
133
134
wallet.reset ();
134
135
{
135
136
WAIT_LOCK (g_wallet_release_mutex, lock);
136
- while (g_unloading_wallet_set.count (pwallet ) == 1 ) {
137
+ while (g_unloading_wallet_set.count (name ) == 1 ) {
137
138
g_wallet_release_cv.wait (lock);
138
139
}
139
140
}
0 commit comments