Skip to content

Commit

Permalink
Merge pull request #2496 from pqarmitage/updates
Browse files Browse the repository at this point in the history
Fix building on (unsupported) CentOS 7
  • Loading branch information
pqarmitage authored Nov 6, 2024
2 parents 4659749 + 7d2b85d commit 7076f55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 15 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
signs="d"
WARN_SIGN=""
])
CFLAGS="$CFLAGS -Werror=format $WARN_SIGN"
CFLAGS="$SAV_CFLAGS -Werror=format $WARN_SIGN"
for field in t tv.tv_sec tv.tv_usec ts.tv_sec ts.tv_nsec; do
for sign in $signs; do
for len in "" l ll; do
Expand Down Expand Up @@ -1695,7 +1695,7 @@ AC_CHECK_LIB(magic, magic_open,
AM_CONDITIONAL([MAGIC], [test $MAGIC -eq 1])
unset LIBS
dnl -- Check for the following variables introduced at various times into Linux
dnl -- Check for the following definitions introduced at various times into Linux
dnl --RTAX_QUICKACK dnl -- Linux 3.11
dnl --FRA_SUPPRESS_PREFIXLEN dnl -- Linux 3.12
dnl --FRA_SUPPRESS_IFGROUP dnl -- Linux 3.12
Expand Down Expand Up @@ -1736,6 +1736,19 @@ for flag in IFA_FLAGS; do
fi
done
dnl -- Linux 3.15
AC_CHECK_DECLS([F_OFD_SETLK], [], [],
[[
#include <unistd.h>
#include <fcntl.h>
]])
for flag in F_OFD_SETLK; do
AS_VAR_COPY([decl_var], [ac_cv_have_decl_$flag])
if test ${decl_var} = yes; then
add_system_opt[${flag}]
fi
done
dnl - Introduced in Linux 5.18
AC_CHECK_DECLS([IFA_PROTO], [], [], [[#include <linux/if_addr.h>]])
for flag in IFA_PROTO; do
Expand Down
4 changes: 4 additions & 0 deletions keepalived/core/pidfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ create_pidfile(pidfile_t *pidf)
struct stat st, fd_st;
int error;
int ret;
#if HAVE_DECL_F_OFD_SETLK == 1
struct flock fl = { .l_type = F_WRLCK, .l_whence = SEEK_SET, .l_start = 0, .l_len = 0 };
#endif

for (;;) {
/* We want to create the file with permissions rw-r--r-- */
Expand All @@ -177,6 +179,7 @@ create_pidfile(pidfile_t *pidf)
return true;
}

#if HAVE_DECL_F_OFD_SETLK == 1
fl.l_pid = 0;
while ((ret = fcntl(pidf->fd, F_OFD_SETLK, &fl)) && errno == EINTR);
if (ret) {
Expand All @@ -187,6 +190,7 @@ create_pidfile(pidfile_t *pidf)

break;
}
#endif

/* Make sure the file has not been removed/moved */
if (stat(pidf->path, &st)) {
Expand Down

0 comments on commit 7076f55

Please sign in to comment.