X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_db3.c;h=21977193fd41cf9fb2f1b72d5b439e378becb7c2;hb=0d38a62f4c8e92149a5daade98079fb7445b7a0b;hp=de24f750d2656ad04c6c53fc7367fdbbbb601eb2;hpb=76c5dd1081bc9db3bf446480457b52d4ae7b3891;p=onak.git diff --git a/keydb_db3.c b/keydb_db3.c index de24f75..2197719 100644 --- a/keydb_db3.c +++ b/keydb_db3.c @@ -25,6 +25,7 @@ #include "decodekey.h" #include "keystructs.h" #include "mem.h" +#include "log.h" #include "onak-conf.h" #include "parsekey.h" @@ -111,20 +112,22 @@ void initdb(void) ret = db_env_create(&dbenv, 0); if (ret != 0) { - fprintf(stderr, "db_env_create: %s\n", db_strerror(ret)); + logthing(LOGTHING_CRITICAL, + "db_env_create: %s", 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. + * Enable deadlock detection so that we don't block indefinitely on + * anything. What we really want is simple 2 state locks, but I'm not + * sure how to make the standard DB functions do that yet. */ - ret = lock_detect(dbenv, - 0, /* flags */ - DB_LOCK_RANDOM, - NULL); /* If non null int* for number broken */ + ret = dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT); + if (ret != 0) { + logthing(LOGTHING_CRITICAL, + "db_env_create: %s", db_strerror(ret)); + exit(1); + } ret = dbenv->open(dbenv, config.db_dir, DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_LOCK | @@ -138,7 +141,8 @@ void initdb(void) ret = db_create(&dbconn, dbenv, 0); if (ret != 0) { - fprintf(stderr, "db_create: %s\n", db_strerror(ret)); + logthing(LOGTHING_CRITICAL, + "db_create: %s", db_strerror(ret)); exit(1); } @@ -154,7 +158,7 @@ void initdb(void) ret = db_create(&worddb, dbenv, 0); if (ret != 0) { - fprintf(stderr, "db_create: %s\n", db_strerror(ret)); + logthing(LOGTHING_CRITICAL, "db_create: %s", db_strerror(ret)); exit(1); } ret = worddb->set_flags(worddb, DB_DUP);