From: Hallvard B Furuseth Date: Fri, 19 Aug 2011 18:35:25 +0000 (+0200) Subject: Wrap O_DSYNC in MDB_DSYNC. X-Git-Tag: OPENLDAP_REL_ENG_2_4_27~148^2~84 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5b3b522313893982163b59027ab775e488ca868a;p=openldap Wrap O_DSYNC in MDB_DSYNC. If O_DSYNC is not defined, that may be due to poor compiler options. We could fall back to the less efficient O_SYNC, but it seems better to let the user learn of the problem and give better compiler options. --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 3de7e1d71b..84c4482267 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -55,6 +55,14 @@ typedef ULONG pgno_t; #include "midl.h" +/* Note: If O_DSYNC is undefined but exists in /usr/include, + * preferably set some compiler flag to get the definition. + * Otherwise compile with the less efficient -DMDB_DSYNC=O_SYNC. + */ +#ifndef MDB_DSYNC +# define MDB_DSYNC O_DSYNC +#endif + #ifndef DEBUG #define DEBUG 1 #endif @@ -1407,7 +1415,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode) if ((rc = mdb_env_open2(env, flags)) == MDB_SUCCESS) { /* synchronous fd for meta writes */ if (!(flags & (MDB_RDONLY|MDB_NOSYNC))) - oflags |= O_DSYNC; + oflags |= MDB_DSYNC; if ((env->me_mfd = open(dpath, oflags, mode)) == -1) { rc = errno; goto leave;