diff options
author | Tim Ruffing <crypto@timruffing.de> | 2018-05-03 17:45:51 +0200 |
---|---|---|
committer | Tim Ruffing <crypto@timruffing.de> | 2018-05-03 19:15:11 +0200 |
commit | 264c64380978d7b0bd3ecb56a861eb004cc58b01 (patch) | |
tree | 03438990ead1c785bec2a2775ae424d1d3c07441 /src/wallet | |
parent | a024a1841d6229ef5ed5d9d92b0b320bbf34fb5c (diff) |
wallet: Reset BerkeleyDB handle after connection fails
According to the BerkeleyDB docs, the DbEnv handle may not be accessed
after close() has been called. This change ensures that we create a new
handle after close() is called. This avoids a segfault when the first
connection attempt fails and then a second connection attempt tries to
call open() on the already closed DbEnv handle.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/db.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 10a06e4b9a..adf6944280 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -169,6 +169,7 @@ bool BerkeleyEnvironment::Open(bool retry) S_IRUSR | S_IWUSR); if (ret != 0) { dbenv->close(0); + Reset(); LogPrintf("BerkeleyEnvironment::Open: Error %d opening database environment: %s\n", ret, DbEnv::strerror(ret)); if (retry) { // try moving the database env out of the way |