summaryrefslogtreecommitdiffstats
path: root/src/plugins/kdb/db2
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/kdb/db2')
-rw-r--r--src/plugins/kdb/db2/kdb_db2.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/kdb/db2/kdb_db2.c b/src/plugins/kdb/db2/kdb_db2.c
index a5ec2d01d..36969584a 100644
--- a/src/plugins/kdb/db2/kdb_db2.c
+++ b/src/plugins/kdb/db2/kdb_db2.c
@@ -309,13 +309,14 @@ open_db(krb5_db2_context *dbc, char *fname, int flags, int mode)
hashi.lorder = 0;
hashi.nelem = 1;
+ /* Try our best guess at the database type. */
db = dbopen(fname, flags, mode,
dbc->hashfirst ? DB_HASH : DB_BTREE,
dbc->hashfirst ? (void *) &hashi : (void *) &bti);
- if (db != NULL) {
- free(fname);
- return db;
- }
+ if (db != NULL)
+ goto done;
+
+ /* If that was wrong, retry with the other type. */
switch (errno) {
#ifdef EFTYPE
case EFTYPE:
@@ -324,12 +325,15 @@ open_db(krb5_db2_context *dbc, char *fname, int flags, int mode)
db = dbopen(fname, flags, mode,
dbc->hashfirst ? DB_BTREE : DB_HASH,
dbc->hashfirst ? (void *) &bti : (void *) &hashi);
+ /* If that worked, update our guess for next time. */
if (db != NULL)
dbc->hashfirst = !dbc->hashfirst;
- default:
- free(fname);
- return db;
+ break;
}
+
+done:
+ free(fname);
+ return db;
}
/* Initialize the lock file and policy database fields of the DB2 context