Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building on (unsupported) CentOS 7 #2496

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading