From d87ee20e0bf7fc751f75412082df307647165d56 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 6 Sep 2016 17:56:13 +0200 Subject: [PATCH] Clean up strange fcntl result check ...and check !MDB_CLOEXEC in an 'if' rather than '#if' to match its non-zero usage. --- libraries/liblmdb/mdb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index b8ecfd8779..087cb98bc1 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4818,9 +4818,9 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl) #ifdef O_CLOEXEC /* Linux: Open file and set FD_CLOEXEC atomically */ # define MDB_CLOEXEC O_CLOEXEC #else - int fdflags; # define MDB_CLOEXEC 0 #endif + int fdflags; #endif #ifdef MDB_USE_SYSV_SEM int semid; @@ -4848,10 +4848,10 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl) } goto fail; } -#if ! ((MDB_CLOEXEC) || defined(_WIN32)) +#ifndef _WIN32 /* Lose record locks when exec*() */ - if ((fdflags = fcntl(env->me_lfd, F_GETFD) | FD_CLOEXEC) >= 0) - fcntl(env->me_lfd, F_SETFD, fdflags); + if (!(MDB_CLOEXEC) && (fdflags = fcntl(env->me_lfd, F_GETFD)) != -1) + fcntl(env->me_lfd, F_SETFD, fdflags | FD_CLOEXEC); #endif if (!(env->me_flags & MDB_NOTLS)) { -- 2.39.5