From: Guus Sliepen Date: Mon, 12 Jul 2021 19:26:24 +0000 (+0200) Subject: Check for the availability of flock(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=e3c87a412475330b668d99d23ea0c612f2a59294;p=meshlink-tiny Check for the availability of flock(). --- diff --git a/configure.ac b/configure.ac index 022bba7..f349de1 100644 --- a/configure.ac +++ b/configure.ac @@ -128,7 +128,7 @@ MeshLink_ATTRIBUTE(__malloc__) MeshLink_ATTRIBUTE(__warn_unused_result__) dnl Checks for library functions. -AC_CHECK_FUNCS([asprintf fchmod fork gettimeofday random pselect select setns strdup usleep getifaddrs freeifaddrs], +AC_CHECK_FUNCS([asprintf fchmod flock fork gettimeofday random pselect select setns strdup usleep getifaddrs freeifaddrs], [], [], [#include "$srcdir/src/have.h"] ) diff --git a/src/conf.c b/src/conf.c index 6ceb23c..cae7bd1 100644 --- a/src/conf.c +++ b/src/conf.c @@ -483,9 +483,7 @@ bool main_config_lock(meshlink_handle_t *mesh, const char *lock_filename) { fcntl(fileno(mesh->lockfile), F_SETFD, FD_CLOEXEC); #endif -#ifdef HAVE_MINGW - // TODO: use _locking()? -#else +#ifdef HAVE_FLOCK if(flock(fileno(mesh->lockfile), LOCK_EX | LOCK_NB) != 0) { logger(NULL, MESHLINK_ERROR, "Cannot lock %s: %s\n", lock_filename, strerror(errno));