diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2009-10-11 01:39:39 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2009-10-11 01:39:39 +0200 |
commit | ee895815c8f924a9d54420cca07d2e8dc3ddf9e0 (patch) | |
tree | 5ca08e35a2b0466f2f935e7bf62d6f97babae325 /src | |
parent | 69a2548913619eb81dcb6c03e27585e02fe057cd (diff) | |
download | librcc-ee895815c8f924a9d54420cca07d2e8dc3ddf9e0.tar.gz librcc-ee895815c8f924a9d54420cca07d2e8dc3ddf9e0.tar.bz2 librcc-ee895815c8f924a9d54420cca07d2e8dc3ddf9e0.tar.xz librcc-ee895815c8f924a9d54420cca07d2e8dc3ddf9e0.zip |
Problems with BerkeleyDB 4.7.x
Diffstat (limited to 'src')
-rw-r--r-- | src/rccdb4.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/rccdb4.c b/src/rccdb4.c index fe7f540..f29f5e3 100644 --- a/src/rccdb4.c +++ b/src/rccdb4.c @@ -36,7 +36,7 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { DB_ENV *dbe; DB *db; -# ifndef DB_LOG_AUTOREMOVE +# if ((!defined(DB_LOG_AUTOREMOVE)) && (!defined(DB_LOG_AUTO_REMOVE))) # ifdef DB_VERSION_MISMATCH char stmp[160]; # endif /* DB_VERSION_MISMATCH */ @@ -45,7 +45,7 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { err = db_env_create(&dbe, 0); if (err) return NULL; -# ifdef DB_LOG_AUTOREMOVE +# if defined(DB_LOG_AUTOREMOVE) dbe->set_flags(dbe, DB_LOG_AUTOREMOVE, 1); dbe->set_lg_max(dbe, 131072); @@ -54,14 +54,27 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_TXN|DB_USE_ENVIRON|DB_INIT_LOCK|DB_INIT_MPOOL|DB_RECOVER, 00644); rccUnLock(); } +# elif defined(DB_LOG_AUTO_REMOVE) + // Starting from berkeleydb 4.7 API has changed + dbe->log_set_config(dbe, DB_LOG_AUTO_REMOVE, 1); + dbe->set_lg_max(dbe, 131072); + + err = rccLock(); + if (!err) { + err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_TXN|DB_USE_ENVIRON|DB_INIT_LOCK|DB_INIT_MPOOL|DB_RECOVER, 00644); + rccUnLock(); + } # else /* DB_LOG_AUTOREMOVE */ err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 00644); # ifdef DB_VERSION_MISMATCH if (err == DB_VERSION_MISMATCH) { - if (!rccLock()) { + if (!rccLock()) { err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_USE_ENVIRON|DB_PRIVATE|DB_RECOVER, 0); dbe->close(dbe, 0); - dbe->remove(dbe, dbpath, 0); + if (err) { + err = db_env_create(&dbe, 0); + if (!err) dbe->remove(dbe, dbpath, 0); + } rccUnLock(); } else { err = -1; |