From 9c137aaccf8900138f40fc9fecbc00b11828223a Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 21 May 2012 12:38:45 -0400 Subject: [PATCH] BDB: restore DB_PRIVATE flag to environment Satoshi's commits fdbf76d and c8ad9b8 (SVN import) removed the DB_PRIVATE flag from the environment. In part, this enables processes other than bitcoind to examine the active database environment. However, this incurs a slight performance penalty versus working entirely within application memory (DB_PRIVATE). Because bitcointools and other direct-BDB-accessing tools are not used by the vast majority of users, prefer to default with DB_PRIVATE with the option of disabling it if needed via -privdb=0. --- src/db.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/db.cpp b/src/db.cpp index 90442f77f..a0b9dc20f 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -76,6 +76,10 @@ CDB::CDB(const char *pszFile, const char* pszMode) : pdb(NULL) if (fCreate) nFlags |= DB_CREATE; + unsigned int nEnvFlags = 0; + if (GetBoolArg("-privdb", true)) + nEnvFlags |= DB_PRIVATE; + { LOCK(cs_db); if (!fDbEnvInit) @@ -106,7 +110,8 @@ CDB::CDB(const char *pszFile, const char* pszMode) : pdb(NULL) DB_INIT_MPOOL | DB_INIT_TXN | DB_THREAD | - DB_RECOVER, + DB_RECOVER | + nEnvFlags, S_IRUSR | S_IWUSR); if (ret > 0) throw runtime_error(strprintf("CDB() : error %d opening database environment", ret));