From b91203daf1a2b5865bfd284821c0c0b103f5b8e7 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 24 Nov 2006 20:23:09 +0000 Subject: DB4 Recovery - RCC Subsystem Locking (per user) - DB4 Recovery (automatically restores environment in the case of db4 upgrades) --- src/rccdb4.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/rccdb4.c') diff --git a/src/rccdb4.c b/src/rccdb4.c index 6a57a5f..a4e0976 100644 --- a/src/rccdb4.c +++ b/src/rccdb4.c @@ -15,11 +15,35 @@ db4_context rccDb4CreateContext(const char *dbpath, rcc_db4_flags flags) { #ifdef HAVE_DB_H DB_ENV *dbe; DB *db; + + char stmp[160]; err = db_env_create(&dbe, 0); if (err) return NULL; + + err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 00644); + if (err == DB_VERSION_MISMATCH) { + + 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); + rccUnLock(); + } else err = -1; + + dbe->close(dbe, 0); + if (err) return NULL; + + if (strlen(dbpath)<128) { + sprintf(stmp, "%s/log.0000000001", dbpath); + remove(stmp); + } + + err = db_env_create(&dbe, 0); + if (err) return NULL; + + err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 00644); + + } - err = dbe->open(dbe, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 00755); if (err) { dbe->close(dbe, 0); return NULL; -- cgit v1.2.3