summaryrefslogtreecommitdiffstats
path: root/src/rccdb4.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2006-11-24 20:23:09 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2006-11-24 20:23:09 +0000
commitb91203daf1a2b5865bfd284821c0c0b103f5b8e7 (patch)
tree60949a1c16c1ce22c897393ab4534dab5e8acc0c /src/rccdb4.c
parent0e5da4d706fa83d29999d9d90976fa4822c3e2e1 (diff)
downloadlibrcc-b91203daf1a2b5865bfd284821c0c0b103f5b8e7.tar.gz
librcc-b91203daf1a2b5865bfd284821c0c0b103f5b8e7.tar.bz2
librcc-b91203daf1a2b5865bfd284821c0c0b103f5b8e7.tar.xz
librcc-b91203daf1a2b5865bfd284821c0c0b103f5b8e7.zip
DB4 Recovery
- RCC Subsystem Locking (per user) - DB4 Recovery (automatically restores environment in the case of db4 upgrades)
Diffstat (limited to 'src/rccdb4.c')
-rw-r--r--src/rccdb4.c26
1 files changed, 25 insertions, 1 deletions
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;