From e3c87a412475330b668d99d23ea0c612f2a59294 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 12 Jul 2021 21:26:24 +0200 Subject: [PATCH] Check for the availability of flock(). --- configure.ac | 2 +- src/conf.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) 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)); -- 2.39.5