aboutsummaryrefslogtreecommitdiff
path: root/lib/hdb/hdb-mdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hdb/hdb-mdb.c')
-rw-r--r--lib/hdb/hdb-mdb.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/hdb/hdb-mdb.c b/lib/hdb/hdb-mdb.c
index 920d7780e844..52d9aed7ac1f 100644
--- a/lib/hdb/hdb-mdb.c
+++ b/lib/hdb/hdb-mdb.c
@@ -76,6 +76,15 @@ DB_destroy(krb5_context context, HDB *db)
}
static krb5_error_code
+DB_set_sync(krb5_context context, HDB *db, int on)
+{
+ mdb_info *mi = (mdb_info *)db->hdb_db;
+
+ mdb_env_set_flags(mi->e, MDB_NOSYNC, !on);
+ return mdb_env_sync(mi->e, 0);
+}
+
+static krb5_error_code
DB_lock(krb5_context context, HDB *db, int operation)
{
db->lock_count++;
@@ -240,6 +249,10 @@ DB__put(krb5_context context, HDB *db, int replace,
mdb_txn_abort(txn);
else
code = mdb_txn_commit(txn);
+ /*
+ * No need to call mdb_env_sync(); it's done automatically if MDB_NOSYNC is
+ * not set.
+ */
if(code == MDB_KEYEXIST)
return HDB_ERR_EXISTS;
return code;
@@ -265,6 +278,10 @@ DB__del(krb5_context context, HDB *db, krb5_data key)
mdb_txn_abort(txn);
else
code = mdb_txn_commit(txn);
+ /*
+ * No need to call mdb_env_sync(); it's done automatically if MDB_NOSYNC is
+ * not set.
+ */
if(code == MDB_NOTFOUND)
return HDB_ERR_NOENTRY;
return code;
@@ -394,6 +411,7 @@ hdb_mdb_create(krb5_context context, HDB **db,
(*db)->hdb__put = DB__put;
(*db)->hdb__del = DB__del;
(*db)->hdb_destroy = DB_destroy;
+ (*db)->hdb_set_sync = DB_set_sync;
return 0;
}
#endif /* HAVE_LMDB */