- strcpy(buf, config.db2_dbpath);
- strcat(buf, "/keydb.db");
-
- ret = db_create(&dbconn, NULL, 0);
+ ret = db_env_create(&dbenv, 0);
+ if (ret != 0) {
+ fprintf(stderr, "db_env_create: %s\n", db_strerror(ret));
+ exit(1);
+ }
+
+ /*
+ * This is a bit of a kludge. Either we run a separate process for
+ * deadlock detection or we do this every time we run. What we really
+ * want to do is specify that our locks are exclusive locks when we
+ * start to do an update.
+ */
+ ret = lock_detect(dbenv,
+ 0, /* flags */
+ DB_LOCK_RANDOM,
+ NULL); /* If non null int* for number broken */
+
+ ret = dbenv->open(dbenv, config.db_dir,
+ DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_LOCK |
+ DB_INIT_TXN |
+ DB_CREATE,
+ 0);
+ if (ret != 0) {
+ dbenv->err(dbenv, ret, "%s", config.db_dir);
+ exit(1);
+ }
+
+ ret = db_create(&dbconn, dbenv, 0);