From: Howard Chu Date: Fri, 12 Aug 2011 06:20:16 +0000 (-0700) Subject: Add mdb_version() X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~107 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9f0ec92a995cbabb1e3bc09a872b35442b965db;p=openldap Add mdb_version() --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index c37a21bc70..b0b572dfef 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -437,6 +437,15 @@ memnrcmp(const void *s1, size_t n1, const void *s2, size_t n2) return *p1 - *p2; } +char * +mdb_version(int *maj, int *min, int *pat) +{ + *maj = MDB_VERSION_MAJOR; + *min = MDB_VERSION_MINOR; + *pat = MDB_VERSION_PATCH; + return MDB_VERSION_STRING; +} + int mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b) { @@ -596,10 +605,10 @@ mdb_touch(MDB_txn *txn, MDB_pageparent *pp) } int -mdb_env_sync(MDB_env *env) +mdb_env_sync(MDB_env *env, int force) { int rc = 0; - if (!F_ISSET(env->me_flags, MDB_NOSYNC)) { + if (force || !F_ISSET(env->me_flags, MDB_NOSYNC)) { if (fsync(env->me_fd)) rc = errno; } @@ -899,9 +908,9 @@ mdb_txn_commit(MDB_txn *txn) free(dp); } - if ((n = mdb_env_sync(env)) != 0 || + if ((n = mdb_env_sync(env, 0)) != 0 || (n = mdb_env_write_meta(txn)) != MDB_SUCCESS || - (n = mdb_env_sync(env)) != 0) { + (n = mdb_env_sync(env, 0)) != 0) { mdb_txn_abort(txn); return n; } diff --git a/libraries/libmdb/mdb.h b/libraries/libmdb/mdb.h index dc9bf5f236..dfd35a020c 100644 --- a/libraries/libmdb/mdb.h +++ b/libraries/libmdb/mdb.h @@ -35,7 +35,14 @@ #define MDB_VERSION_MAJOR 0 #define MDB_VERSION_MINOR 8 #define MDB_VERSION_PATCH 0 -#define MDB_VERSION_FULL ((MDB_VERSION_MAJOR << 24) | (MDB_VERSION_MINOR << 16) | MDB_VERSION_PATCH) +#define MDB_VERINT(a,b,c) ((a << 24) | (b << 16) | c) +#define MDB_VERSION_FULL \ + MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH) +#define MDB_VERSION_DATE "August 11, 2011" +#define MDB_VERSTR(a,b,c,d) "MDB " #a "." #b "." #c ": (" #d ")" +#define MDB_VERFOO(a,b,c,d) MDB_VERSTR(a,b,c,d) +#define MDB_VERSION_STRING \ + MDB_VERFOO(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH,MDB_VERSION_DATE) struct MDB_cursor; struct MDB_txn; @@ -103,10 +110,11 @@ typedef struct MDB_stat { unsigned long ms_entries; } MDB_stat; +char *mdb_version(int *major, int *minor, int *patch); int mdb_env_create(MDB_env **env); int mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode); int mdb_env_stat(MDB_env *env, MDB_stat *stat); -int mdb_env_sync(MDB_env *env); +int mdb_env_sync(MDB_env *env, int force); void mdb_env_close(MDB_env *env); int mdb_env_get_flags(MDB_env *env, unsigned int *flags); int mdb_env_get_path(MDB_env *env, const char **path);