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.
This commit is contained in:
Tim Ruffing 2018-05-03 17:45:51 +02:00
parent a024a1841d
commit 264c643809
No known key found for this signature in database
GPG Key ID: EACFF772B38B3479
1 changed files with 1 additions and 0 deletions

View File

@ -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