From e1998bd008515471428a7aada47a044bc4ec4f14 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Sat, 1 Jul 2000 01:54:25 +0000 Subject: [PATCH] * adb_openclose.c (osa_adb_create_db): Default to btree. (osa_adb_init_db): Set up btinfo as well. (osa_adb_open_and_lock): Try btree, then hash. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12500 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kadm5/srv/ChangeLog | 4 +++ src/lib/kadm5/srv/adb_openclose.c | 42 ++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/lib/kadm5/srv/ChangeLog b/src/lib/kadm5/srv/ChangeLog index aeab2c139..21fd2d333 100644 --- a/src/lib/kadm5/srv/ChangeLog +++ b/src/lib/kadm5/srv/ChangeLog @@ -1,5 +1,9 @@ 2000-06-30 Tom Yu + * adb_openclose.c (osa_adb_create_db): Default to btree. + (osa_adb_init_db): Set up btinfo as well. + (osa_adb_open_and_lock): Try btree, then hash. + * Makefile.in (SHLIB_EXPDEPS): Add libdb. (SHLIB_EXPLIBS): Add -ldb. diff --git a/src/lib/kadm5/srv/adb_openclose.c b/src/lib/kadm5/srv/adb_openclose.c index 2a9bba8f6..dbbc3b698 100644 --- a/src/lib/kadm5/srv/adb_openclose.c +++ b/src/lib/kadm5/srv/adb_openclose.c @@ -26,15 +26,17 @@ osa_adb_ret_t osa_adb_create_db(char *filename, char *lockfilename, { int lf; DB *db; - HASHINFO info; + BTREEINFO btinfo; - memset(&info, 0, sizeof(info)); - info.hash = NULL; - info.bsize = 256; - info.ffactor = 8; - info.nelem = 25000; - info.lorder = 0; - db = dbopen(filename, O_RDWR | O_CREAT | O_EXCL, 0600, DB_HASH, &info); + memset(&btinfo, 0, sizeof(btinfo)); + btinfo.flags = 0; + btinfo.cachesize = 0; + btinfo.psize = 4096; + btinfo.lorder = 0; + btinfo.minkeypage = 0; + btinfo.compare = NULL; + btinfo.prefix = NULL; + db = dbopen(filename, O_RDWR | O_CREAT | O_EXCL, 0600, DB_BTREE, &btinfo); if (db == NULL) return errno; if (db->close(db) < 0) @@ -128,6 +130,13 @@ osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename, db->info.nelem = 25000; db->info.lorder = 0; + db->btinfo.flags = 0; + db->btinfo.cachesize = 0; + db->btinfo.psize = 4096; + db->btinfo.lorder = 0; + db->btinfo.minkeypage = 0; + db->btinfo.compare = NULL; + db->btinfo.prefix = NULL; /* * A process is allowed to open the same database multiple times * and access it via different handles. If the handles use @@ -363,14 +372,23 @@ osa_adb_ret_t osa_adb_open_and_lock(osa_adb_princ_t db, int locktype) if (ret != OSA_ADB_OK) return ret; - db->db = dbopen(db->filename, O_RDWR, 0600, DB_HASH, &db->info); - if (db->db == NULL) { + db->db = dbopen(db->filename, O_RDWR, 0600, DB_BTREE, &db->btinfo); + if (db->db != NULL) + return OSA_ADB_OK; + switch (errno) { +#ifdef EFTYPE + case EFTYPE: +#endif + case EINVAL: + db->db = dbopen(db->filename, O_RDWR, 0600, DB_HASH, &db->info); + if (db->db != NULL) + return OSA_ADB_OK; + default: (void) osa_adb_release_lock(db); - if(errno == EINVAL) + if (errno == EINVAL) return OSA_ADB_BAD_DB; return errno; } - return OSA_ADB_OK; } osa_adb_ret_t osa_adb_close_and_unlock(osa_adb_princ_t db) -- 2.26.2