CCS_CFLAGS
PKGCONFIGINIT_LIBS
PKGCONFIGINIT_CFLAGS
-PKG_CONFIG_LIBDIR
-PKG_CONFIG_PATH
PKG_CONFIG
POW_LIB
LIBOBJS
enable_readline
enable_realtime
with_clvmd
+with_clvmd_pidfile
enable_cmirrord
with_cmirrord_pidfile
enable_debug
CPPFLAGS
CPP
PKG_CONFIG
-PKG_CONFIG_PATH
-PKG_CONFIG_LIBDIR
PKGCONFIGINIT_CFLAGS
PKGCONFIGINIT_LIBS
CCS_CFLAGS
* all (autodetect)
* none (disable build)
[TYPE=none]
+ --with-clvmd-pidfile=PATH
+ clvmd pidfile [/var/run/clvmd.pid]
--with-cmirrord-pidfile=PATH
cmirrord pidfile [/var/run/cmirrord.pid]
--with-optimisation=OPT C optimisation flag [OPT=-O2]
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
- PKG_CONFIG_PATH
- directories to add to pkg-config's search path
- PKG_CONFIG_LIBDIR
- path overriding pkg-config's built-in search path
PKGCONFIGINIT_CFLAGS
C compiler flags for PKGCONFIGINIT, overriding pkg-config
PKGCONFIGINIT_LIBS
pkg_config_init() {
-
-
-
-
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
$as_echo "no" >&6; }
PKG_CONFIG=""
fi
+
fi
pkg_failed=no
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$PKGCONFIGINIT_PKG_ERRORS" >&5
- { $as_echo "$as_me:$LINENO: result: pkg-config initialized" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ { $as_echo "$as_me:$LINENO: result: pkg-config initialized" >&5
$as_echo "pkg-config initialized" >&6; }
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
{ $as_echo "$as_me:$LINENO: result: pkg-config initialized" >&5
$as_echo "pkg-config initialized" >&6; }
else
PKGCONFIGINIT_LIBS=$pkg_cv_PKGCONFIGINIT_LIBS
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
-
+ :
fi
PKGCONFIG_INIT=1
}
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$CCS_PKG_ERRORS" >&5
- NOTFOUND=0
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ NOTFOUND=0
for ac_header in ccs.h
do
HAVE_CCS=yes
fi
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
NOTFOUND=0
for ac_header in ccs.h
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$GULM_PKG_ERRORS" >&5
- NOTFOUND=0
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ NOTFOUND=0
for ac_header in libgulm.h
do
HAVE_GULM=yes
fi
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
NOTFOUND=0
for ac_header in libgulm.h
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$CMAN_PKG_ERRORS" >&5
- NOTFOUND=0
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ NOTFOUND=0
for ac_header in libcman.h
do
HAVE_CMAN=yes
fi
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
NOTFOUND=0
for ac_header in libcman.h
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$COROSYNC_PKG_ERRORS" >&5
- $bailout
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
+ $bailout
+elif test $pkg_failed = untried; then
$bailout
else
COROSYNC_CFLAGS=$pkg_cv_COROSYNC_CFLAGS
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$QUORUM_PKG_ERRORS" >&5
- $bailout
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
+ $bailout
+elif test $pkg_failed = untried; then
$bailout
else
QUORUM_CFLAGS=$pkg_cv_QUORUM_CFLAGS
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$SALCK_PKG_ERRORS" >&5
- $bailout
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
+ $bailout
+elif test $pkg_failed = untried; then
$bailout
else
SALCK_CFLAGS=$pkg_cv_SALCK_CFLAGS
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$CONFDB_PKG_ERRORS" >&5
- HAVE_CONFDB=no
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
+ HAVE_CONFDB=no
+elif test $pkg_failed = untried; then
HAVE_CONFDB=no
else
CONFDB_CFLAGS=$pkg_cv_CONFDB_CFLAGS
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$CPG_PKG_ERRORS" >&5
- $bailout
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
+ { $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
+ $bailout
+elif test $pkg_failed = untried; then
$bailout
else
CPG_CFLAGS=$pkg_cv_CPG_CFLAGS
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
# Put the nasty error message in config.log where it belongs
echo "$DLM_PKG_ERRORS" >&5
- NOTFOUND=0
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ NOTFOUND=0
for ac_header in libdlm.h
do
HAVE_DLM=yes
fi
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
NOTFOUND=0
for ac_header in libdlm.h
fi
fi
+################################################################################
+if test "x$CLVMD" != xnone; then
+
+# Check whether --with-clvmd-pidfile was given.
+if test "${with_clvmd_pidfile+set}" = set; then
+ withval=$with_clvmd_pidfile; CLVMD_PIDFILE=$withval
+else
+ CLVMD_PIDFILE="/var/run/clvmd.pid"
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define CLVMD_PIDFILE "$CLVMD_PIDFILE"
+_ACEOF
+
+fi
+
################################################################################
{ $as_echo "$as_me:$LINENO: checking whether to build cluster mirror log daemon" >&5
$as_echo_n "checking whether to build cluster mirror log daemon... " >&6; }
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
Alternatively, you may set the environment variables SACKPT_CFLAGS
and SACKPT_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&5
+See the pkg-config man page for more details.
+" >&5
$as_echo "$as_me: error: Package requirements (libSaCkpt) were not met:
$SACKPT_PKG_ERRORS
Alternatively, you may set the environment variables SACKPT_CFLAGS
and SACKPT_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&2;}
+See the pkg-config man page for more details.
+" >&2;}
{ (exit 1); exit 1; }; }
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it
SACKPT_LIBS=$pkg_cv_SACKPT_LIBS
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
-
+ :
fi
if test x$HAVE_CPG != xyes; then
if test $pkg_failed = yes; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
Alternatively, you may set the environment variables CPG_CFLAGS
and CPG_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&5
+See the pkg-config man page for more details.
+" >&5
$as_echo "$as_me: error: Package requirements (libcpg) were not met:
$CPG_PKG_ERRORS
Alternatively, you may set the environment variables CPG_CFLAGS
and CPG_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&2;}
+See the pkg-config man page for more details.
+" >&2;}
{ (exit 1); exit 1; }; }
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it
CPG_LIBS=$pkg_cv_CPG_LIBS
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
-
+ :
fi
fi
fi
return pthread_mutex_unlock(&_global_mutex);
}
-/* Store pid in pidfile. */
-static int _storepid(int lf)
-{
- int len;
- char pid[8];
-
- if ((len = snprintf(pid, sizeof(pid), "%u\n", getpid())) < 0)
- return 0;
-
- if (len > (int) sizeof(pid))
- len = (int) sizeof(pid);
-
- if (write(lf, pid, (size_t) len) != len)
- return 0;
-
- fsync(lf);
-
- return 1;
-}
-
/* Check, if a device exists. */
static int _fill_device_data(struct thread_status *ts)
{
}
-static int _lock_pidfile(void)
-{
- int lf;
- char pidfile[] = DMEVENTD_PIDFILE;
-
- if ((lf = open(pidfile, O_CREAT | O_RDWR, 0644)) < 0)
- exit(EXIT_OPEN_PID_FAILURE);
-
- if (flock(lf, LOCK_EX | LOCK_NB) < 0)
- exit(EXIT_LOCKFILE_INUSE);
-
- if (!_storepid(lf))
- exit(EXIT_FAILURE);
-
- return 0;
-}
-
#ifdef linux
/*
* Protection against OOM killer if kernel supports it
}
#endif
+static void remove_lockfile(void)
+{
+ unlink(DMEVENTD_PIDFILE);
+}
+
static void _daemonize(void)
{
int child_status;
/* Problem with child. Determine what it is by exit code */
switch (WEXITSTATUS(child_status)) {
- case EXIT_LOCKFILE_INUSE:
- fprintf(stderr, "Another dmeventd daemon is already running\n");
- break;
case EXIT_DESC_CLOSE_FAILURE:
case EXIT_DESC_OPEN_FAILURE:
- case EXIT_OPEN_PID_FAILURE:
case EXIT_FIFO_FAILURE:
case EXIT_CHDIR_FAILURE:
default:
openlog("dmeventd", LOG_PID, LOG_DAEMON);
- _lock_pidfile(); /* exits if failure */
+ if (dm_create_lockfile(DMEVENTD_PIDFILE) == 0)
+ exit(EXIT_FAILURE);
+
+ atexit(remove_lockfile);
/* Set the rest of the signals to cause '_exit_now' to be set */
signal(SIGINT, &_exit_handler);
return prev_fail || fclose_fail ? EOF : 0;
}
+
+int dm_create_lockfile(const char *lockfile)
+{
+ int fd, value;
+ size_t bufferlen;
+ ssize_t write_out;
+ struct flock lock;
+ char buffer[50];
+
+ if((fd = open(lockfile, O_CREAT | O_WRONLY,
+ (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
+ log_error("Cannot open lockfile [%s], error was [%s]",
+ lockfile, strerror(errno));
+ return 0;
+ }
+
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+ if (fcntl(fd, F_SETLK, &lock) < 0) {
+ if (errno != EACCES && errno != EAGAIN)
+ log_error("Cannot lock lockfile [%s], error was [%s]",
+ lockfile, strerror(errno));
+ else
+ log_error("process is already running");
+
+ goto fail;
+ }
+
+ if (ftruncate(fd, 0) < 0) {
+ log_error("Cannot truncate pidfile [%s], error was [%s]",
+ lockfile, strerror(errno));
+
+ goto fail;
+ }
+
+ memset(buffer, 0, sizeof(buffer));
+ snprintf(buffer, sizeof(buffer)-1, "%u\n", getpid());
+
+ bufferlen = strlen(buffer);
+ write_out = write(fd, buffer, bufferlen);
+
+ if ((write_out < 0) || (write_out == 0 && errno)) {
+ log_error("Cannot write pid to pidfile [%s], error was [%s]",
+ lockfile, strerror(errno));
+
+ goto fail;
+ }
+
+ if ((write_out == 0) || (write_out < bufferlen)) {
+ log_error("Cannot write pid to pidfile [%s], shortwrite of"
+ "[%" PRIsize_t "] bytes, expected [%" PRIsize_t "]\n",
+ lockfile, write_out, bufferlen);
+
+ goto fail;
+ }
+
+ if ((value = fcntl(fd, F_GETFD, 0)) < 0) {
+ log_error("Cannot get close-on-exec flag from pidfile [%s], "
+ "error was [%s]", lockfile, strerror(errno));
+
+ goto fail;
+ }
+ value |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, value) < 0) {
+ log_error("Cannot set close-on-exec flag from pidfile [%s], "
+ "error was [%s]", lockfile, strerror(errno));
+
+ goto fail;
+ }
+
+ return 1;
+
+fail:
+ if (close(fd))
+ stack;
+ if (unlink(lockfile))
+ stack;
+
+ return 0;
+}